Skip to content

Commit

Permalink
Add <e@entity.is_npc> and <e@entity.is_mob>
Browse files Browse the repository at this point in the history
  • Loading branch information
aufdemrand committed Sep 11, 2013
1 parent 3342163 commit 4942cff
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/main/java/net/aufdemrand/denizen/objects/dEntity.java
Expand Up @@ -1183,6 +1183,29 @@ else if ((float) getLivingEntity().getHealth() / maxHealth < 1)
.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <e@entity.is_npc>
// @returns Element(Boolean)
// @description
// Returns if the entity is actually a NPC.
// -->
if (attribute.startsWith("is_npc")) {
return new Element(CitizensAPI.getNPCRegistry().isNPC(getBukkitEntity()))
.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <e@entity.is_mob>
// @returns Element(Boolean)
// @description
// Returns if the entity is a mob. This excludes players and NPCs.
// -->
if (attribute.startsWith("is_mob")) {
if (!(getBukkitEntity() instanceof Player) && !CitizensAPI.getNPCRegistry().isNPC(getBukkitEntity()))
return Element.TRUE.getAttribute(attribute.fulfill(1));
else return Element.FALSE.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <e@entity.prefix>
// @returns Element
Expand Down

0 comments on commit 4942cff

Please sign in to comment.