chore: Add method to delete npc using UUID

This commit is contained in:
D3v1s0m 2025-04-18 12:26:23 +05:30
parent affa0f4c84
commit c34a665692
No known key found for this signature in database
GPG key ID: FA1F770C7B1D40C1
2 changed files with 14 additions and 0 deletions

View file

@ -65,6 +65,12 @@ public interface NpcRegistry {
*/ */
void delete(String id); void delete(String id);
/**
* Deletes an NPC entry by its UUID
* @param uuid The UUID of the NPC entry
*/
void delete(UUID uuid);
/** /**
* Register an NPC to this registry * Register an NPC to this registry
* NpcEntry instances can be obtained through the NpcSerializer classes * NpcEntry instances can be obtained through the NpcSerializer classes

View file

@ -202,6 +202,14 @@ public class NpcRegistryImpl implements NpcRegistry {
storage.deleteNpc(entry); storage.deleteNpc(entry);
} }
@Override
public void delete(UUID uuid) {
NpcEntryImpl entry = npcUuidLookupMap.get(uuid);
if (entry == null) return;
unregister(entry);
storage.deleteNpc(entry);
}
public void switchIds(String oldId, String newId) { public void switchIds(String oldId, String newId) {
NpcEntryImpl entry = getById(oldId); NpcEntryImpl entry = getById(oldId);
delete(oldId); delete(oldId);