EntityTargetEvent disable target

Discussion in 'Spigot Plugin Development' started by Drank, Jun 29, 2015.

  1. Hi Spigot,
    I want to make it so that a specific player cannot be target by a Zombie, this is what a try, unforunaly it didn't worked:

    Code (Text):
        public void onTarget(EntityTargetEvent e){
            if (e.getTarget() instanceof Zombie && e.getEntity() instanceof Player){
                Player p = (Player) e.getEntity();
                if (p.getName().equals("Drank")){
    So when a player has a name of "Drank" he won't get attacked, but it don't work.
  2. I think you have it reversed. EntityTargetEvent#getTarget() should refer to the player and EntityTargetEvent#getEntity() should refer to the Zombie.
    • Like Like x 1