Solved Is there a way to get an entity from its unique id?

Discussion in 'Plugin Development' started by rippin, Jul 29, 2014.

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

    rippin

    For players you can do getPlayer(UUID) is there a way to do this for mobs? If not I'll just store the LivingEntity object I guess but I was wondering if a similar method existed.
     
  2. Offline

    fireblast709

    rippin you would have to loop over all entities and compare UUIDs (which Bukkit does behind the scenes for players). Also if you want to store Entities, make sure you use weak referencing (I can suggest a data type depending on your structure). Especially since cleanup is not always possible due to missing entity events (like despawning because there is no player nearby)
     
  3. Offline

    rippin

    Yeah I was just wondering if it existed. I probably will still store the UUID just to be safe and loop through all the entities to check if it still exist . Thanks though.
     
Thread Status:
Not open for further replies.

Share This Page