Going from list of nearby entities to getting a player

Discussion in 'Plugin Development' started by ShadowLAX, Dec 19, 2013.

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

    ShadowLAX

    Hello bukkit. I am currently hung up on a problem. So, I start by getting a player's nearby entities. How would I go from the list of entities to seeing if one of those entities is a different player in an arraylist?

    Thanks!
     
  2. Offline

    Deleted user

    ShadowLAX
    Code:
    if(entity instanceof Player){
      Player p = (Entity) entity;
      if(arrayList.contains(p.getName()){
        // Do Stuff
      }
      // Do some more stuff
    }
     
  3. Offline

    ShadowLAX

    JHG0 That doesn't seem to be working... :(
    Code:
    Code:java
    1. List<Entity> entity = p.getNearbyEntities(6.0, 6.0, 6.0);
    2. if (entity instanceof Player) {
    3. Player player = (Player) entity;
    4. if (Main.arraylist.contains(player.getName()) == false) {
    5. p.removePotionEffect(PotionEffectType.CONFUSION);
    6.  
    7. }
    8. }
     
  4. Offline

    amhokies

    You need to loop through the list, and check if each individual Entity is a player.
    Also, Main.arraylist.contains(player.getName()) == false can be written as !Main.arraylist.contains(player.getName())
     
Thread Status:
Not open for further replies.

Share This Page