#(renssus) Why isnt it degister the NPC

23 messages · Page 1 of 1 (latest)

raw wadi
#
        Hub.getInstance().getLogger().info("Removing all NPCs created by this plugin...");

        for (NPC npc : npcs) {
            if (npc.isSpawned()) {
                npc.despawn();
                CitizensAPI.getNPCRegistry().deregister(npc);
                Hub.getInstance().getLogger().info("Removed NPC: " + npc.getName());

            }
            CitizensAPI.getNPCRegistry().deregister(npc);
            Hub.getInstance().getLogger().info("Deregister NPC: " + npc.getName());

        }

        npcs.clear();
    } ```

it is getting trigged tho
tender flameBOT
#

(renssus) Why isnt it degister the NPC

tender flameBOT
#

Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.

next zephyr
#

just call npc.destroy()

#

but that looks correct

#

if it's not working as you expect then you have a logic error in your code

urban flameBOT
#
Thread Closing Reminder

Has your issue been resolved, or your question been answered?
If so, please use the </resolved:1028673926114594866> command to close your thread.
Or </invalid:1028673926898909185> if it's not possible to resolve.

If not yet resolved, please reply below to tell us what you still need.

(Note that if there is no reply for a few days, this thread will eventually close itself.)

#

@raw wadi

raw wadi
#

But there are still the npc

next zephyr
#

But otherwise there is a logic error in your code

raw wadi
# next zephyr As I said use the destroy method
        Hub.getInstance().getLogger().info("Removing all NPCs created by this plugin...");

        for (NPC npc : npcs) {
            if (npc.isSpawned()) {
                npc.destroy();
                Hub.getInstance().getLogger().info("Removed NPC: " + npc.getName());

            }
            npc.destroy();
            Hub.getInstance().getLogger().info("Destoryed NPC: " + npc.getName());

        }
    }```


Rhat isnt working
next zephyr
#

Outside of this code

raw wadi
#

wdym?

next zephyr
#

As in you are respawning the NPCs elsewhere or the wrong NPCs are being removed

raw wadi
#

i am spawning them, and despawning them

Despawn = on disable
Enable = on eable

next zephyr
#

To simplify it for you maybe just use the temporary registry?

raw wadi
#

there is a thing like that💀

#

where can I find that?