Skip to content

Commit

Permalink
Allow location origin in Shoot. Spawn Skeletons and Pigmen with items…
Browse files Browse the repository at this point in the history
… in dEntity by default. Change <player.eyes> into <entity.eye_location>
  • Loading branch information
davidcernat committed Aug 14, 2013
1 parent 7502b87 commit e35188e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 32 deletions.
53 changes: 31 additions & 22 deletions src/main/java/net/aufdemrand/denizen/objects/dEntity.java
Expand Up @@ -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
Expand Down Expand Up @@ -869,6 +870,14 @@ public String getAttribute(Attribute attribute) {
return new dLocation(entity.getLocation().add(0, -1, 0))
.getAttribute(attribute.fulfill(2));

// <--
// <entity.eye_location> -> dLocation
// returns a dLocation of the entity's eyes.
// -->
if (attribute.startsWith("eye_location"))
return new dLocation(getEyeLocation())
.getAttribute(attribute.fulfill(1));

// <--
// <entity.location> -> dLocation
// Returns the dLocation of the entity.
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/net/aufdemrand/denizen/objects/dPlayer.java
Expand Up @@ -521,14 +521,6 @@ else if (attribute.startsWith("list.offline")) {
if (attribute.startsWith("name"))
return new Element(player_name).getAttribute(attribute.fulfill(1));

// <--
// <player.eyes> -> dLocation
// returns a dLocation of the player's eyes.
// -->
if (attribute.startsWith("eyes"))
return new dLocation(getEyeLocation())
.getAttribute(attribute.fulfill(1));

// <--
// <player.compass.target> -> dLocation
// returns a dLocation of the player's 'compass target'.
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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") :
Expand Down

0 comments on commit e35188e

Please sign in to comment.