diff --git a/api/src/main/java/lol/pyr/znpcsplus/api/npc/NpcRegistry.java b/api/src/main/java/lol/pyr/znpcsplus/api/npc/NpcRegistry.java index 8a39418..2d41981 100644 --- a/api/src/main/java/lol/pyr/znpcsplus/api/npc/NpcRegistry.java +++ b/api/src/main/java/lol/pyr/znpcsplus/api/npc/NpcRegistry.java @@ -65,6 +65,12 @@ public interface NpcRegistry { */ 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 * NpcEntry instances can be obtained through the NpcSerializer classes diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcRegistryImpl.java b/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcRegistryImpl.java index 0dc8a1a..43f0a9f 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcRegistryImpl.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcRegistryImpl.java @@ -202,6 +202,14 @@ public class NpcRegistryImpl implements NpcRegistry { 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) { NpcEntryImpl entry = getById(oldId); delete(oldId);