Solved Arraylist gets emptied bug

Discussion in 'Plugin Development' started by CraterHater, Nov 8, 2016.

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

    CraterHater

    Hey,

    I have got an ArrayList called qnpcs, it stores Entity objects. But when a player leaves the chunk the entity gets automatically removed from the ArrayList. Any ideas how this could be happening? I am never removing an entity manually so that can't be it.
     
  2. Offline

    ipodtouch0218

    The entities are getting unloaded, so they cannot exist anymore.
    JGC sees that the entity in the HashMap is null, and removes it.
     
  3. Offline

    CraterHater

  4. Offline

    Zombie_Striker

    @CraterHater
    You can make sure the chunks do not unload. Listen to ChunkUnloadEvent, and if that chunk contains an entity from the map, cancel the event (stop it from unloading). Just remember that you will need to unload those chunks sometimes, or else your lag may increase.
     
  5. Offline

    CraterHater

Thread Status:
Not open for further replies.

Share This Page