From f60952ee3f87f985d9054dfb53f283b771214622 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Sat, 5 Nov 2016 05:17:13 -0400 Subject: [PATCH] Added Death Listener --- src/alisolarflare/magic/MagicModule.java | 2 ++ .../magic/tricks/AliArrowDeathListener.java | 17 +++++++++++++++++ .../magic/tricks/BoomBowListener.java | 12 ++++-------- 3 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 src/alisolarflare/magic/tricks/AliArrowDeathListener.java diff --git a/src/alisolarflare/magic/MagicModule.java b/src/alisolarflare/magic/MagicModule.java index 2b37e22..fff9034 100644 --- a/src/alisolarflare/magic/MagicModule.java +++ b/src/alisolarflare/magic/MagicModule.java @@ -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()); } } diff --git a/src/alisolarflare/magic/tricks/AliArrowDeathListener.java b/src/alisolarflare/magic/tricks/AliArrowDeathListener.java new file mode 100644 index 0000000..388e1e1 --- /dev/null +++ b/src/alisolarflare/magic/tricks/AliArrowDeathListener.java @@ -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()); + } +} diff --git a/src/alisolarflare/magic/tricks/BoomBowListener.java b/src/alisolarflare/magic/tricks/BoomBowListener.java index 6e97525..dbbc977 100644 --- a/src/alisolarflare/magic/tricks/BoomBowListener.java +++ b/src/alisolarflare/magic/tricks/BoomBowListener.java @@ -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); + } } }