Hello, I am trying to that when the player dies is a to a spectator mode, so the unseen to all players of the game. The problem is, that even hiding the zombies continue attack, also I have tried to do so invisible, but does not work. Code:java public void onPlayerDeath(PlayerDeathEvent event) { Player player = event.getEntity().getPlayer(); if(event.getEntity().getPlayer().isDead()) { player.setAllowFlight(true); player.setHealth(20); for(Player players : Bukkit.getOnlinePlayers()) { if(GamePlayers[game].contains(players.getName())) { players.hidePlayer(player); players.sendMessage("[V] The player " + player.getName()+ " has died"); } } }} I also tried that if the player is in the array, it can not be attacked, but the zombies followed even when invisible Code:java public void onEntityDamage(EntityDamageEvent event) { if(event.getEntity() instanceof Player) { Player player = (Player)event.getEntity(); if(Spectators.contains(player.getName())) { event.setCancelled(true); } }}
Code:java public void onEntityTargetLivingEntity(EntityTargetLivingEntityEvent e) { //if target == spectator { e.setCancelled(true); }}
Yes, already have this: Code:java @EventHandlerpublic void onEntityTarget(EntityTargetLivingEntityEvent event) {Player player = (Player) event.getTarget();player.sendMessage("TEST");if(Spectators.contains(player.getName())) {event.setCancelled(true);}} But continue attacking PD: I got an error: Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_7_R1.entity.CraftVillager cannot be cast to org.bukkit.entity.Player
Error solved, but they continue attacking :S. I think, this is caused because entities have already selected target
Probably because they respawn close to the mobs.. So if they spawn far away, and teleport back to the mobs it won't do that.