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
#(renssus) Why isnt it degister the NPC
23 messages · Page 1 of 1 (latest)
(renssus) Why isnt it degister the NPC
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.
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
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
Its eunning as it the logger gets trigged
But there are still the npc
As I said use the destroy method
But otherwise there is a logic error in your code
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
If npc is spawned remove this line but still it seems like a logic problem
Outside of this code
wdym?
As in you are respawning the NPCs elsewhere or the wrong NPCs are being removed
yes?
i am spawning them, and despawning them
Despawn = on disable
Enable = on eable
To simplify it for you maybe just use the temporary registry?