Added Death Listener
This commit is contained in:
parent
3801b4fc40
commit
f60952ee3f
3 changed files with 23 additions and 8 deletions
|
@ -3,6 +3,7 @@ package alisolarflare.magic;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import alisolarflare.Module;
|
import alisolarflare.Module;
|
||||||
|
import alisolarflare.magic.tricks.AliArrowDeathListener;
|
||||||
import alisolarflare.magic.tricks.AliArrowListener;
|
import alisolarflare.magic.tricks.AliArrowListener;
|
||||||
import alisolarflare.magic.tricks.BoomBowListener;
|
import alisolarflare.magic.tricks.BoomBowListener;
|
||||||
|
|
||||||
|
@ -11,6 +12,7 @@ public class MagicModule extends Module{
|
||||||
@Override
|
@Override
|
||||||
public void register(JavaPlugin plugin) {
|
public void register(JavaPlugin plugin) {
|
||||||
registerListener(plugin, new AliArrowListener(plugin));
|
registerListener(plugin, new AliArrowListener(plugin));
|
||||||
|
registerListener(plugin, new AliArrowDeathListener());
|
||||||
registerListener(plugin, new BoomBowListener());
|
registerListener(plugin, new BoomBowListener());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
17
src/alisolarflare/magic/tricks/AliArrowDeathListener.java
Normal file
17
src/alisolarflare/magic/tricks/AliArrowDeathListener.java
Normal 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());
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,7 +10,6 @@ import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
@ -92,13 +91,10 @@ public class BoomBowListener implements Listener {
|
||||||
player.getWorld().spawnParticle(Particle.EXPLOSION_HUGE, playerLocation, 2);
|
player.getWorld().spawnParticle(Particle.EXPLOSION_HUGE, playerLocation, 2);
|
||||||
player.damage(7.0, player);
|
player.damage(7.0, player);
|
||||||
boomBow.setDurability((short) (boomBow.getDurability() + 3));
|
boomBow.setDurability((short) (boomBow.getDurability() + 3));
|
||||||
|
if(boomBow.getDurability() < 0){
|
||||||
|
player.getInventory().setItemInMainHand(null);
|
||||||
|
player.getWorld().playSound(playerLocation, Sound.ENTITY_ITEM_BREAK, 0, 0);
|
||||||
|
}
|
||||||
}
|
|
||||||
public void FlyBowBoostDeath(PlayerDeathEvent event){
|
|
||||||
event.getEntity().getServer().broadcastMessage("[boombow debug]: "+event.getEntity().getLastDamageCause().getCause().toString());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue