Check if an entity is a player

Discussion in 'Plugin Development' started by Taco, Jan 9, 2011.

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

    Taco

    I found that there is an entity.getEntityID() method, but what would that return should the entity be a player?
     
  2. Offline

    Hidendra

    Pretty sure ID is just a unique identifier for the entity.

    Code:
    if(entity instanceof Player) {
        /* It's a player or npc (but not a monster/animal) ! */
    }
    
     
  3. Offline

    Taco

    Thanks :D
     
  4. Offline

    Purre

    I think you can use this
    Code:
    Entity entity = event.getEntity();
    if (entity instanceof Player) {
       //Important: The class Player, not a variable. This works because Entity is a subclass of Player
       //Do stuff here
    }
    
    EDIT: I was too late :(
     
Thread Status:
Not open for further replies.

Share This Page