get entity by UUID loop not working

Discussion in 'Plugin Development' started by Raxor1234, Aug 7, 2015.

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

    Raxor1234

    as the title says. It dosent work when u try to get an entity that is far away, or an entity that is outside of a loaded chunk, how could I fix this? this is my code:

    for(Entity en: Super.cfg.getServer().getWorld(p.getWorld().getName()).getEntities()){
    if(en.getUniqueId().toString().equals(getConfig().getString(p.getUniqueId().toString()))){
    Wolf w = (Wolf) en;
    w.teleport(p);
    p.sendMessage(ChatPrefix + ChatColor.GOLD + w.getCustomName() + ChatColor.GREEN + " has been teleported to you.");
    break;
    }
    }
     
  2. Offline

    Eos

    what event are you using? Is this a command?

    Why are you using break, break's are used to exit for loops, you should be using return not break.

    Edit:
    Didn't see the for
     
    Last edited: Aug 7, 2015
  3. Offline

    SuperOriginal

    Yes they do.
     
  4. Offline

    Raxor1234

    "for" it is a for loop

    Why does that for loop wont work if you're really far away? is it because entities get unloaded when u are far away from them ? help!
     
    Last edited by a moderator: Aug 8, 2015
  5. Offline

    Raxor1234

Thread Status:
Not open for further replies.

Share This Page