Skip to content

Commit

Permalink
some dEntity cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Oct 26, 2015
1 parent 79bb720 commit f7e6e03
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions src/main/java/net/aufdemrand/denizen/objects/dEntity.java
Expand Up @@ -1619,7 +1619,7 @@ else if (mtr.angle == BlockFace.EAST) {
// Returns whether the entity can see the specified other entity.
// -->
if (attribute.startsWith("can_see")) {
if (attribute.hasContext(1) && dEntity.matches(attribute.getContext(1))) {
if (isLivingEntity() && attribute.hasContext(1) && dEntity.matches(attribute.getContext(1))) {
dEntity toEntity = dEntity.valueOf(attribute.getContext(1));
if (toEntity != null && toEntity.isSpawned())
return new Element(getLivingEntity().hasLineOfSight(toEntity.getBukkitEntity())).getAttribute(attribute.fulfill(1));
Expand All @@ -1633,9 +1633,10 @@ else if (mtr.angle == BlockFace.EAST) {
// @description
// returns the location of the entity's eyes.
// -->
if (attribute.startsWith("eye_location"))
if (attribute.startsWith("eye_location")) {
return new dLocation(getEyeLocation())
.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <e@entity.eye_height>
Expand All @@ -1644,13 +1645,11 @@ else if (mtr.angle == BlockFace.EAST) {
// @description
// Returns the height of the entity's eyes above its location.
// -->
if (attribute.startsWith("eye_height") || attribute.startsWith("eye_height")) {
if (isLivingEntity())
if (attribute.startsWith("eye_height")) {
if (isLivingEntity()) {
return new Element(getLivingEntity().getEyeHeight())
.getAttribute(attribute.fulfill(1));
else
return new Element("null")
.getAttribute(attribute.fulfill(1));
}
}

// <--[tag]
Expand Down Expand Up @@ -1748,9 +1747,12 @@ else if (mtr.angle == BlockFace.EAST) {
// @description
// Returns whether the entity can pick up items.
// -->
if (attribute.startsWith("can_pickup_items"))
return new Element(getLivingEntity().getCanPickupItems())
.getAttribute(attribute.fulfill(1));
if (attribute.startsWith("can_pickup_items")) {
if (isLivingEntity()) {
return new Element(getLivingEntity().getCanPickupItems())
.getAttribute(attribute.fulfill(1));
}
}

// <--[tag]
// @attribute <e@entity.fallingblock_material>
Expand Down Expand Up @@ -1808,8 +1810,6 @@ else if (mtr.angle == BlockFace.EAST) {
return new dEntity(getLivingEntity().getLeashHolder())
.getAttribute(attribute.fulfill(1));
}
else return new Element("null")
.getAttribute(attribute.fulfill(1));
}

// <--[tag]
Expand Down Expand Up @@ -1837,10 +1837,9 @@ else return new Element("null")
// -->
if (attribute.startsWith("shooter") ||
attribute.startsWith("get_shooter")) {
if (isProjectile() && hasShooter())
if (isProjectile() && hasShooter()) {
return getShooter().getAttribute(attribute.fulfill(1));
else return new Element("null")
.getAttribute(attribute.fulfill(1));
}
}

// <--[tag]
Expand Down Expand Up @@ -1903,9 +1902,10 @@ else if (!getLivingEntity().getActivePotionEffects().isEmpty()) {
// @description
// Returns whether the animal entity is capable of mating with another of its kind.
// -->
if (attribute.startsWith("can_breed"))
if (attribute.startsWith("can_breed")) {
return new Element(((Ageable) getLivingEntity()).canBreed())
.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <e@entity.breeding>
Expand All @@ -1914,9 +1914,10 @@ else if (!getLivingEntity().getActivePotionEffects().isEmpty()) {
// @description
// Returns whether the animal entity is trying to with another of its kind.
// -->
if (attribute.startsWith("breeding") || attribute.startsWith("is_breeding"))
if (attribute.startsWith("breeding") || attribute.startsWith("is_breeding")) {
return new Element(((CraftAnimals) getLivingEntity()).getHandle().ce())
.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <e@entity.has_passenger>
Expand Down

0 comments on commit f7e6e03

Please sign in to comment.