1.15.2 I'm having issues with removing mobs from unloaded chunks(pets)

Discussion in 'Spigot Plugin Development' started by hidden1nin, Feb 23, 2020.

  1. My pets plugin has a hashmap of owner (key) and pet( object) and when a player teleports i want to remove their pet and spawn a totally new one. and this works fine when the player warps to loaded chunks like 12 chunks withion eachother or loaded chunks like spawn, but when they go home where the chunks are unloaded the pets are duplicating!
    Code (Java):
        public static void removepet(Player p) {
            if(Pets.get(p)!=null) {
  2. I added a cool down to its spawn time and now it works?? i think that java was running the code twice in one tick but i feel like thats not even possible..