Skip to content

Commit

Permalink
Prevent NPEs in bad util.spawn_entity args
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Aug 27, 2013
1 parent ca4cb0f commit 4bae903
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/main/java/net/aufdemrand/denizen/tags/core/UtilTags.java
Expand Up @@ -425,13 +425,19 @@ else if (type.equalsIgnoreCase("ENTITY_IS_SPAWNED")) {
// @description
// Returns a spawned copy of the chosen entity type.
// -->
else if (type.equalsIgnoreCase("SPAWN_ENTITY")) {
else if (type.equalsIgnoreCase("SPAWN_ENTITY")
&& event.hasTypeContext() && event.hasSubTypeContext()) {
dEntity ent = dEntity.valueOf(event.getTypeContext());
if (ent.isSpawned())
event.setReplaced(ent.getAttribute(attribute.fulfill(2)));
else {
ent.spawnAt(dLocation.valueOf(event.getSubTypeContext()));
event.setReplaced(ent.getAttribute(attribute.fulfill(2)));
if (ent != null) {
if (ent.isSpawned())
event.setReplaced(ent.getAttribute(attribute.fulfill(2)));
else {
dLocation spawnAt = dLocation.valueOf(event.getSubTypeContext());
if (spawnAt != null) {
ent.spawnAt(spawnAt);
event.setReplaced(ent.getAttribute(attribute.fulfill(2)));
}
}
}
}

Expand Down

0 comments on commit 4bae903

Please sign in to comment.