Setting Target Entity doesn't seem to be working

Discussion in 'Plugin Development' started by Orcem12, May 19, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    Orcem12

    I'm trying to set to the target not to be the player. But when the player joins the Player Array I have named 'IncappedPlayers'; the player is still attacked. Any advice?
    Here's my code:
    Code:
        @EventHandler
        public void EntityIgnore(EntityTargetLivingEntityEvent e){
            if(e.getEntityType() == EntityType.PLAYER){
                Player entity = (Player)e.getEntity();
                if(plugin.IncappedPlayers.contains(entity) && e.getTarget() == entity){
                    e.setTarget(null);
                }
            }
        }
     
  2. Offline

    coldandtired

    e.getEntity() is the mob doing the targeting. Not sure if this event gets raised for players targeting other players.
     
  3. Offline

    Orcem12

    There is only 2 Target Events. This one and EntityTargetEvent

    Any ideas anyone?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 25, 2016
  4. Offline

    FanAs

    It's bukkit issue, jail also can't do this.
     
  5. Offline

    Njol

    Can't you even find event.getTarget()? (Typing "e." usually brings up a list of all available methods)
     
  6. Offline

    Orcem12

    Yes, that is what I used. Bukkit reported it a bug. e.getTarget() should work but it doesn't.
     
  7. Offline

    Njol

    No, it's not what you used:
    If you changed your code in the meantime you should post the updated code.
     
Thread Status:
Not open for further replies.

Share This Page