This commit is contained in:
Luca 2021-11-22 19:39:47 +01:00
parent 55017fb201
commit da2fe2dbc1
2 changed files with 6 additions and 11 deletions

View File

@ -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);
}
}
}

View File

@ -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);