Skip to content

Commit

Permalink
add some npc id validation
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Sep 9, 2018
1 parent 277cae3 commit 6b44e5d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Expand Up @@ -219,14 +219,14 @@ public void onSpawn(NPCSpawnEvent event) {
*/
@EventHandler
public void despawn(NPCDespawnEvent event) {
dNPC npc = getDenizen(event.getNPC().getId());
dNPC npc = getDenizen(event.getNPC());

// Do world script event 'On NPC Despawns'
if (npc != null) {
if (npc != null && npc.isValid()) {
OldEventManager.doEvents(Arrays.asList("npc despawns"), new BukkitScriptEntryData(null, npc), null);
}

if (npc != null) {
if (npc != null && npc.isValid()) {
npc.action("despawn", null);
}
}
Expand Down
3 changes: 3 additions & 0 deletions plugin/src/main/java/net/aufdemrand/denizen/objects/dNPC.java
Expand Up @@ -151,6 +151,9 @@ public dNPC(NPC citizensNPC) {
}

public NPC getCitizen() {
if (npcid < 0) {
return null;
}
NPC npc = CitizensAPI.getNPCRegistry().getById(npcid);
if (npc == null) {
//dB.echoError(new RuntimeException("StackTraceOutput"));
Expand Down

0 comments on commit 6b44e5d

Please sign in to comment.