Added Death Listener

This commit is contained in:
alisolarflare 2016-11-05 05:17:13 -04:00
parent 3801b4fc40
commit f60952ee3f
3 changed files with 23 additions and 8 deletions

View file

@ -3,6 +3,7 @@ package alisolarflare.magic;
import org.bukkit.plugin.java.JavaPlugin;
import alisolarflare.Module;
import alisolarflare.magic.tricks.AliArrowDeathListener;
import alisolarflare.magic.tricks.AliArrowListener;
import alisolarflare.magic.tricks.BoomBowListener;
@ -11,6 +12,7 @@ public class MagicModule extends Module{
@Override
public void register(JavaPlugin plugin) {
registerListener(plugin, new AliArrowListener(plugin));
registerListener(plugin, new AliArrowDeathListener());
registerListener(plugin, new BoomBowListener());
}
}

View file

@ -0,0 +1,17 @@
package alisolarflare.magic.tricks;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
public class AliArrowDeathListener implements Listener{
@EventHandler
public void onBoomBowDeath(PlayerDeathEvent event){
Player player = event.getEntity();
if (player.getKiller() != player)
return;
player.sendMessage(player.getLastDamageCause().toString());
player.sendMessage(event.getEventName());
}
}

View file

@ -10,7 +10,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
@ -92,13 +91,10 @@ public class BoomBowListener implements Listener {
player.getWorld().spawnParticle(Particle.EXPLOSION_HUGE, playerLocation, 2);
player.damage(7.0, player);
boomBow.setDurability((short) (boomBow.getDurability() + 3));
}
public void FlyBowBoostDeath(PlayerDeathEvent event){
event.getEntity().getServer().broadcastMessage("[boombow debug]: "+event.getEntity().getLastDamageCause().getCause().toString());
if(boomBow.getDurability() < 0){
player.getInventory().setItemInMainHand(null);
player.getWorld().playSound(playerLocation, Sound.ENTITY_ITEM_BREAK, 0, 0);
}
}
}