Merge pull request #2 from TBMCPlugins/AliBranch

Gave Ali a custom arrow trail
This commit is contained in:
alisolarflare 2016-06-24 05:00:48 -04:00 committed by GitHub
commit ca304f708a
10 changed files with 76 additions and 3 deletions

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<projectDescription> <projectDescription>
<name>TheButtonMultiDevPlugin</name> <name>ButtonLaboratoryPlugin</name>
<comment></comment> <comment></comment>
<projects> <projects>
</projects> </projects>

BIN
ButtonLaboratoryPlugin.jar Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,3 +1,3 @@
main: buttondevteam.MainPlugin main: buttondevteam.MainPlugin
version: 1.0.0 version: 1.0.0
name: ButtonMultiDevPlugin name: ButtonLaboratoryPlugin

View file

@ -5,9 +5,12 @@ import java.util.logging.Logger;
import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import buttondevteam.alisolarflare.aliarrowtrail.AliArrowListener;
public class MainPlugin extends JavaPlugin{ public class MainPlugin extends JavaPlugin{
private PluginDescriptionFile pdfFile; private PluginDescriptionFile pdfFile;
private Logger logger; private Logger logger;
private AliArrowListener aliArrowListener;
public void onEnable(){ public void onEnable(){
//Logs "Plugin Enabled", registers commands //Logs "Plugin Enabled", registers commands
@ -31,7 +34,8 @@ public class MainPlugin extends JavaPlugin{
//Example Event: getServer().getPluginManager().registerEvents(midnightListener, this); //Example Event: getServer().getPluginManager().registerEvents(midnightListener, this);
//INIT //INIT
aliArrowListener = new AliArrowListener(this);
//EVENTS //EVENTS
getServer().getPluginManager().registerEvents(aliArrowListener, this);
} }
} }

View file

@ -0,0 +1,39 @@
package buttondevteam.alisolarflare.aliarrowtrail;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import buttondevteam.MainPlugin;
public class AliArrowListener implements Listener {
private final MainPlugin plugin;
public AliArrowListener(MainPlugin plugin){
this.plugin = plugin;
}
@SuppressWarnings("deprecation")
@EventHandler
public void onProjectileLaunch(ProjectileLaunchEvent event){
try{
if(!(event.getEntity().getType() == EntityType.ARROW)){
return;
}
Projectile projectile = event.getEntity();
if (!(projectile.getShooter().equals(plugin.getServer().getPlayer("Ali")))){
return;
}
Arrow arrow = (Arrow) projectile;
if (!(arrow.isCritical())){
return;
}
AliArrowTask aliArrowTask = new AliArrowTask(plugin,arrow);
aliArrowTask.runTaskTimer(plugin, 2, 1);
}catch(Exception e){
return;
}
}
}

View file

@ -0,0 +1,30 @@
package buttondevteam.alisolarflare.aliarrowtrail;
import org.bukkit.Particle;
import org.bukkit.entity.Arrow;
import org.bukkit.scheduler.BukkitRunnable;
import buttondevteam.MainPlugin;
public class AliArrowTask extends BukkitRunnable{
MainPlugin plugin;
Arrow arrow;
public AliArrowTask(MainPlugin plugin, Arrow arrow){
this.plugin = plugin;
this.arrow = arrow;
}
@Override
public void run() {
arrow.getWorld().spawnParticle(Particle.VILLAGER_HAPPY, arrow.getLocation(), 1);
if (arrow.isOnGround() || arrow.isDead()){
this.cancel();
}
}
}