Hide all npcs on plugin disable

This commit is contained in:
D3v1s0m 2023-06-22 18:42:33 +05:30
parent 28300cded5
commit 08d69f6848
No known key found for this signature in database
GPG Key ID: 3B6EC35367B8D82E
2 changed files with 5 additions and 0 deletions

@ -143,6 +143,7 @@ public class ZNpcsPlus extends JavaPlugin {
log(ChatColor.WHITE + " * Loading data...");
npcRegistry.reload();
shutdownTasks.add(npcRegistry::unload);
shutdownTasks.add(scheduler::cancelAll);
shutdownTasks.add(userManager::shutdown);
shutdownTasks.add(adventure::close);

@ -146,4 +146,8 @@ public class NpcRegistryImpl implements NpcRegistry {
if (!npcIdLookupMap.containsKey(id)) return;
npcIdLookupMap.remove(id).getNpc().delete();
}
public void unload() {
npcList.forEach(npcEntry -> npcEntry.getNpc().getViewers().forEach(npcEntry.getNpc()::UNSAFE_hide));
}
}