diff --git a/src/main/java/net/aufdemrand/denizen/objects/dEntity.java b/src/main/java/net/aufdemrand/denizen/objects/dEntity.java index 9b32414666..63dab62db7 100644 --- a/src/main/java/net/aufdemrand/denizen/objects/dEntity.java +++ b/src/main/java/net/aufdemrand/denizen/objects/dEntity.java @@ -483,32 +483,33 @@ else if (entity_type.name().matches("FALLING_BLOCK")) { ent = location.getWorld().spawnFallingBlock(location, material, materialData); entity = ent; } - else if (entity_type.name().matches("PIG_ZOMBIE")) { - - // Give pig zombies golden swords by default, unless data2 specifies - // a different weapon - if (dItem.matches(data2) == false) { - data2 = "gold_sword"; - } - - ((PigZombie) entity).getEquipment() - .setItemInHand(dItem.valueOf(data2).getItemStack()); - } - else if (entity_type.name().matches("SKELETON")) { - - // Give skeletons bows by default, unless data2 specifies - // a different weapon - if (dItem.matches(data2) == false) { - data2 = "bow"; - } - - ((Skeleton) entity).getEquipment() - .setItemInHand(dItem.valueOf(data2).getItemStack()); - } else { ent = location.getWorld().spawnEntity(location, entity_type); entity = ent; + + if (entity_type.name().matches("PIG_ZOMBIE")) { + + // Give pig zombies golden swords by default, unless data2 specifies + // a different weapon + if (dItem.matches(data1) == false) { + data1 = "gold_sword"; + } + + ((PigZombie) entity).getEquipment() + .setItemInHand(dItem.valueOf(data1).getItemStack()); + } + else if (entity_type.name().matches("SKELETON")) { + + // Give skeletons bows by default, unless data2 specifies + // a different weapon + if (dItem.matches(data2) == false) { + data2 = "bow"; + } + + ((Skeleton) entity).getEquipment() + .setItemInHand(dItem.valueOf(data2).getItemStack()); + } // If there is some special subtype data associated with this dEntity, // use the setSubtype method to set it in a clean, object-oriented @@ -869,6 +870,14 @@ public String getAttribute(Attribute attribute) { return new dLocation(entity.getLocation().add(0, -1, 0)) .getAttribute(attribute.fulfill(2)); + // <-- + // -> dLocation + // returns a dLocation of the entity's eyes. + // --> + if (attribute.startsWith("eye_location")) + return new dLocation(getEyeLocation()) + .getAttribute(attribute.fulfill(1)); + // <-- // -> dLocation // Returns the dLocation of the entity. diff --git a/src/main/java/net/aufdemrand/denizen/objects/dPlayer.java b/src/main/java/net/aufdemrand/denizen/objects/dPlayer.java index 3ead3d23da..7612a69da7 100644 --- a/src/main/java/net/aufdemrand/denizen/objects/dPlayer.java +++ b/src/main/java/net/aufdemrand/denizen/objects/dPlayer.java @@ -521,14 +521,6 @@ else if (attribute.startsWith("list.offline")) { if (attribute.startsWith("name")) return new Element(player_name).getAttribute(attribute.fulfill(1)); - // <-- - // -> dLocation - // returns a dLocation of the player's eyes. - // --> - if (attribute.startsWith("eyes")) - return new dLocation(getEyeLocation()) - .getAttribute(attribute.fulfill(1)); - // <-- // -> dLocation // returns a dLocation of the player's 'compass target'. diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/entity/ShootCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/entity/ShootCommand.java index f1242c5999..61db4331a5 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/entity/ShootCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/entity/ShootCommand.java @@ -22,6 +22,7 @@ import net.aufdemrand.denizen.utilities.entity.Position; import net.aufdemrand.denizen.utilities.entity.Rotation; +import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; @@ -129,9 +130,9 @@ public void execute(final ScriptEntry scriptEntry) throws CommandExecutionExcept .add(originEntity.getEyeLocation().getDirection()) .subtract(0, 0.4, 0)); - // If an entity is doing the shooting, get its LivingEntity + // If a living entity is doing the shooting, get its LivingEntity - LivingEntity shooter = originEntity.isLivingEntity() ? originEntity.getLivingEntity() : null; + LivingEntity shooter = (originEntity != null && originEntity.isLivingEntity()) ? originEntity.getLivingEntity() : null; final dLocation destination = scriptEntry.hasObject("destination") ? (dLocation) scriptEntry.getObject("destination") :