Skip to content

Commit

Permalink
Fix NPC navigator NPEs
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Oct 8, 2013
1 parent 804c9f0 commit abcea44
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/java/net/aufdemrand/denizen/objects/dNPC.java
Expand Up @@ -559,7 +559,7 @@ && getCitizen().getTrait(ConstantsTrait.class).getConstant(attribute.getContext(
// returns whether the NPC is in combat.
// -->
if (attribute.startsWith("navigator.is_fighting"))
return new Element(getNavigator().getEntityTarget().isAggressive())
return new Element(getNavigator().getEntityTarget() != null && getNavigator().getEntityTarget().isAggressive())
.getAttribute(attribute.fulfill(2));

// <--[tag]
Expand All @@ -569,7 +569,7 @@ && getCitizen().getTrait(ConstantsTrait.class).getConstant(attribute.getContext(
// returns the entity type of the target.
// -->
if (attribute.startsWith("navigator.target_type"))
return new Element(getNavigator().getTargetType().toString())
return new Element(getNavigator().getTargetType() == null ? "null": getNavigator().getTargetType().toString())
.getAttribute(attribute.fulfill(2));

// <--[tag]
Expand All @@ -579,7 +579,7 @@ && getCitizen().getTrait(ConstantsTrait.class).getConstant(attribute.getContext(
// returns the entity being targeted.
// -->
if (attribute.startsWith("navigator.target_entity"))
return (getNavigator().getEntityTarget().getTarget() != null
return (getNavigator().getEntityTarget() != null && getNavigator().getEntityTarget().getTarget() != null
? new dEntity(getNavigator().getEntityTarget().getTarget()).getAttribute(attribute.fulfill(2))
: "null");

Expand Down

0 comments on commit abcea44

Please sign in to comment.