#What is better for performance?

1 messages · Page 1 of 1 (latest)

narrow otter
#

I'm trying access all ZombieVillagers in the server to do operations on them on a schedule.
I know that with Bukkit.getWords() and World.getEntitiesByClass() I can get a list of all the ZombieVillagers in each world.
But I wonder which one is better for performance:
1.- Using Bukkit.getWords() and World.getEntitiesByClass() each time I want to check on the ZombieVillagers.
2.- Using Bukkit.getWords() and World.getEntitiesByClass() at the start of the plugin, storing the list, and then Listen to any EntitySpawn / EntityDeath events to update the list, and run operations off of that.
3.- Another way I haven't thought about that you might suggest.