Skip to content

Commit

Permalink
Allow construction of dInventories with valid holders that have null …
Browse files Browse the repository at this point in the history
…locations, thus hopefully solving issues #483 and #450
  • Loading branch information
davidcernat committed Oct 21, 2013
1 parent b47db30 commit df2cbfc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
5 changes: 4 additions & 1 deletion src/main/java/net/aufdemrand/denizen/objects/dInventory.java
Expand Up @@ -215,7 +215,10 @@ else if (holder instanceof Entity) {
}
else {
idType = "location";
idHolder = getLocation().identify();
if (getLocation() != null)
idHolder = getLocation().identify();
else
idHolder = "null";
}
}
else {
Expand Down
Expand Up @@ -216,7 +216,8 @@ public void run() {
scriptEntry.getPlayer(),
scriptEntry.getNPC());
ScriptQueue queue = InstantQueue.getQueue(ScriptQueue._getNextId()).addEntries(entries);
queue.addDefinition("location", lastEntity.getLocation().identify());
if (lastEntity.getLocation() != null)
queue.addDefinition("location", lastEntity.getLocation().identify());
queue.addDefinition("pushed_entities", entityList.toString());
queue.addDefinition("last_entity", lastEntity.identify());
queue.start();
Expand Down
Expand Up @@ -2647,18 +2647,12 @@ public void inventoryCloseEvent(InventoryCloseEvent event) {
Player player = (Player) event.getPlayer();
String type = event.getInventory().getType().name();

// TODO: Find out why this would ever throw an NPE (Issue #450) - then prevent that NPE
try {
context.put("inventory", new dInventory(event.getInventory()));
context.put("inventory", new dInventory(event.getInventory()));

doEvents(Arrays.asList
("player closes inventory",
"player closes " + type),
null, player, context);
}
catch (NullPointerException e) {
dB.echoError("Ignoring error #450, bug the developers about this...");
}
doEvents(Arrays.asList
("player closes inventory",
"player closes " + type),
null, player, context);
}

// <--[event]
Expand Down

0 comments on commit df2cbfc

Please sign in to comment.