Skip to content

Commit

Permalink
Fix issue when NPC is not present when building a Listener.
Browse files Browse the repository at this point in the history
  • Loading branch information
aufdemrand committed May 23, 2013
1 parent ce47e93 commit b2ee615
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Expand Up @@ -148,7 +148,7 @@ public void load(Player player, dNPC npc, String listenerId, String listenerType
public void save() {
denizen.getSaves().set("Listeners." + player.getName() + "." + listenerId + ".Listener Type", listenerType);
denizen.getSaves().set("Listeners." + player.getName() + "." + listenerId + ".Finish Script", scriptName);
denizen.getSaves().set("Listeners." + player.getName() + "." + listenerId + ".Linked NPCID", npc.getId());
if (npc != null) denizen.getSaves().set("Listeners." + player.getName() + "." + listenerId + ".Linked NPCID", npc.getId());
onSave();
try {
if (!saveable.isEmpty())
Expand Down
Expand Up @@ -133,7 +133,9 @@ public void playerJoin(PlayerJoinEvent event) {
// People tend to worry when they see long-ass stacktraces.. let's catch them.
try {
String type = denizen.getSaves().getString(path + listenerId + ".Listener Type");
dNPC npc = DenizenAPI.getDenizenNPC(CitizensAPI.getNPCRegistry().getById(denizen.getSaves().getInt(path + listenerId + ".Linked NPCID")));
dNPC npc = null;
if (denizen.getSaves().contains(path + listenerId + ".Linked NPCID"))
npc = DenizenAPI.getDenizenNPC(CitizensAPI.getNPCRegistry().getById(denizen.getSaves().getInt(path + listenerId + ".Linked NPCID")));
if (get(type) == null) return;
dB.log(event.getPlayer().getName() + " has a LISTENER in progress. Loading '" + listenerId + "'.");
get(type).createInstance(event.getPlayer(), listenerId).load(event.getPlayer(), npc, listenerId, type);
Expand Down

0 comments on commit b2ee615

Please sign in to comment.