diff --git a/src/main/java/rip/tilly/bedwars/listeners/RandomListeners.java b/src/main/java/rip/tilly/bedwars/listeners/RandomListeners.java index ad08a6d..dcef73f 100644 --- a/src/main/java/rip/tilly/bedwars/listeners/RandomListeners.java +++ b/src/main/java/rip/tilly/bedwars/listeners/RandomListeners.java @@ -5,9 +5,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.*; import org.bukkit.event.entity.CreatureSpawnEvent; -import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.FoodLevelChangeEvent; -import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.hanging.HangingBreakEvent; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerToggleFlightEvent; @@ -91,13 +89,4 @@ public class RandomListeners implements Listener { event.setCancelled(true); } } - - @EventHandler - public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { - PlayerData playerData = this.plugin.getPlayerDataManager().getPlayerData(event.getEntity().getUniqueId()); - - if (playerData.getPlayerState() != PlayerState.PLAYING) { - event.setCancelled(true); - } - } } diff --git a/src/main/java/rip/tilly/bedwars/listeners/game/DamageListener.java b/src/main/java/rip/tilly/bedwars/listeners/game/DamageListener.java index db79824..ded6acd 100644 --- a/src/main/java/rip/tilly/bedwars/listeners/game/DamageListener.java +++ b/src/main/java/rip/tilly/bedwars/listeners/game/DamageListener.java @@ -13,6 +13,7 @@ import rip.tilly.bedwars.events.PlayerKillEvent; import rip.tilly.bedwars.game.Game; import rip.tilly.bedwars.game.GameState; import rip.tilly.bedwars.playerdata.PlayerData; +import rip.tilly.bedwars.playerdata.PlayerState; import rip.tilly.bedwars.utils.CC; public class DamageListener implements Listener { @@ -85,6 +86,11 @@ public class DamageListener implements Listener { PlayerData playerData = this.plugin.getPlayerDataManager().getPlayerData(player.getUniqueId()); PlayerData damagerData = this.plugin.getPlayerDataManager().getPlayerData(damager.getUniqueId()); + if (playerData.getPlayerState() != PlayerState.PLAYING || damagerData.getPlayerState() != PlayerState.PLAYING) { + event.setCancelled(true); + return; + } + Game game = this.plugin.getGameManager().getGame(player.getUniqueId()); if (game == null) { event.setDamage(0);