diff --git a/src/cz/boosik/boosCooldown/boosCoolDown.java b/src/cz/boosik/boosCooldown/boosCoolDown.java index 5b1d194..5032a19 100644 --- a/src/cz/boosik/boosCooldown/boosCoolDown.java +++ b/src/cz/boosik/boosCooldown/boosCoolDown.java @@ -28,7 +28,6 @@ public class boosCoolDown extends JavaPlugin { public static boolean permissions = false; @SuppressWarnings("static-access") - @Override public void onEnable() { pdfFile = this.getDescription(); @@ -57,7 +56,6 @@ public class boosCoolDown extends JavaPlugin { } - @Override public void onDisable() { if (boosConfigManager.getClearOnRestart() == true) { boosCoolDownManager.clear(); diff --git a/src/cz/boosik/boosCooldown/boosCoolDownEntityListener.java b/src/cz/boosik/boosCooldown/boosCoolDownEntityListener.java new file mode 100644 index 0000000..443360e --- /dev/null +++ b/src/cz/boosik/boosCooldown/boosCoolDownEntityListener.java @@ -0,0 +1,34 @@ +package cz.boosik.boosCooldown; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityListener; + +import util.boosChat; + +public class boosCoolDownEntityListener extends EntityListener { + private final boosCoolDown plugin; + + public boosCoolDownEntityListener(boosCoolDown instance) { + plugin = instance; + } + + public void onEntityDamage(EntityDamageEvent event) { + if (event.isCancelled()) { + return; + } + + Entity entity = event.getEntity(); + if(entity != null && entity instanceof Player) { + Player player = (Player)entity; + if(player != null) { + if(boosWarmUpManager.hasWarmUps(player)) { + boosChat.sendMessageToPlayer(player,boosConfigManager.getWarmUpCancelledMessage()); + boosWarmUpManager.cancelWarmUps(player); + } + + } + } + } +} diff --git a/src/cz/boosik/boosCooldown/boosWarmUpManager.java b/src/cz/boosik/boosCooldown/boosWarmUpManager.java index c70075b..16df442 100644 --- a/src/cz/boosik/boosCooldown/boosWarmUpManager.java +++ b/src/cz/boosik/boosCooldown/boosWarmUpManager.java @@ -57,11 +57,14 @@ public class boosWarmUpManager { } public static void cancelWarmUps(Player player) { - removeWarmUpProcess(player.getName()); + for(String key: playercommands.keySet()) { + if(key.startsWith(player.getName())) { + removeWarmUpProcess(key); + } + } } public static boolean hasWarmUps(Player player) { - boosChat.sendMessageToServer( "haswarmup" ); for(String key: playercommands.keySet()) { if(key.startsWith(player.getName())) { return true;