Skip to content

Commit

Permalink
Catch potential errors when dropped entities fail to spawn
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jan 15, 2015
1 parent fb26568 commit 4f163fd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/net/aufdemrand/denizen/objects/dEntity.java
Expand Up @@ -855,7 +855,7 @@ public boolean isSpawned() {
}

public boolean isValid() {
return entity.isValid();
return entity != null && entity.isValid();
}

public void remove() {
Expand Down
Expand Up @@ -116,7 +116,8 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
dB.echoDebug(scriptEntry, "Cannot drop multiples of this item because it is Unique!");
for (int x = 0; x < qty.asInt(); x++) {
dEntity e = new dEntity(location.getWorld().dropItemNaturally(location, item.getItemStack()));
e.setVelocity(e.getVelocity().multiply(speed != null ? speed.asDouble(): 1d));
if (e.isValid())
e.setVelocity(e.getVelocity().multiply(speed != null ? speed.asDouble(): 1d));
entityList.add(e.toString());
}
}
Expand Down

0 comments on commit 4f163fd

Please sign in to comment.