Skip to content

Commit

Permalink
Fix navigation NPE.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcernat committed Mar 8, 2013
1 parent 8106c4e commit efd84d0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
Expand Up @@ -531,7 +531,7 @@ public String asCommaSeparatedList() {
String returnList = "";

for (String string : values)
returnList = returnList + string + ",";
returnList = returnList + string + ", ";

return returnList.substring(0, returnList.length() - 1);
}
Expand Down
21 changes: 12 additions & 9 deletions src/main/java/net/aufdemrand/denizen/tags/core/NPCTags.java
Expand Up @@ -126,20 +126,23 @@ public void navBegin(NavigationBeginEvent event) {
if (!event.getNPC().hasTrait(AssignmentTrait.class)) return;
dNPC npc = DenizenAPI.getDenizenNPC(event.getNPC());
npc.action("begin navigation", null);
if (event.getNPC().getNavigator().getEntityTarget().isAggressive())
if (event.getNPC().getNavigator().getTargetType().toString() == "ENTITY")
{
Player player = null;
if (event.getNPC().getNavigator().getEntityTarget().isAggressive())
{
Player player = null;

// Check if the entity attacked by this NPC is a player
if (event.getNPC().getNavigator().getEntityTarget().getTarget() instanceof Player)
player = (Player) event.getNPC().getNavigator().getEntityTarget().getTarget();
// Check if the entity attacked by this NPC is a player
if (event.getNPC().getNavigator().getEntityTarget().getTarget() instanceof Player)
player = (Player) event.getNPC().getNavigator().getEntityTarget().getTarget();

npc.action("attack", player);
npc.action("attack", player);

npc.action("attack on "
+ event.getNPC().getNavigator().getEntityTarget().getTarget().getType().toString(), player);
npc.action("attack on "
+ event.getNPC().getNavigator().getEntityTarget().getTarget().getType().toString(), player);
}
previousLocations.put(event.getNPC().getId(), npc.getLocation());
}
previousLocations.put(event.getNPC().getId(), npc.getLocation());
}

@EventHandler
Expand Down

0 comments on commit efd84d0

Please sign in to comment.