diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/bukkit/event/entity/EntityTargetEvent.java | 7 | ||||
-rw-r--r-- | src/main/java/org/bukkit/event/entity/EntityTargetLivingEntityEvent.java | 32 |
2 files changed, 37 insertions, 2 deletions
diff --git a/src/main/java/org/bukkit/event/entity/EntityTargetEvent.java b/src/main/java/org/bukkit/event/entity/EntityTargetEvent.java index 1329bfd2..6f891acf 100644 --- a/src/main/java/org/bukkit/event/entity/EntityTargetEvent.java +++ b/src/main/java/org/bukkit/event/entity/EntityTargetEvent.java @@ -9,14 +9,13 @@ import org.bukkit.event.HandlerList; */ public class EntityTargetEvent extends EntityEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); - private boolean cancel; + private boolean cancel = false; private Entity target; private final TargetReason reason; public EntityTargetEvent(final Entity entity, final Entity target, final TargetReason reason) { super(entity); this.target = target; - this.cancel = false; this.reason = reason; } @@ -113,6 +112,10 @@ public class EntityTargetEvent extends EntityEvent implements Cancellable { */ RANDOM_TARGET, /** + * When an entity selects a target while defending a village. + */ + DEFEND_VILLAGE, + /** * For custom calls to the event */ CUSTOM diff --git a/src/main/java/org/bukkit/event/entity/EntityTargetLivingEntityEvent.java b/src/main/java/org/bukkit/event/entity/EntityTargetLivingEntityEvent.java new file mode 100644 index 00000000..f5010b1e --- /dev/null +++ b/src/main/java/org/bukkit/event/entity/EntityTargetLivingEntityEvent.java @@ -0,0 +1,32 @@ +package org.bukkit.event.entity; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; + +/** + * Called when an Entity targets a {@link LivingEntity} and can only target LivingEntity's. + */ +public class EntityTargetLivingEntityEvent extends EntityTargetEvent{ + public EntityTargetLivingEntityEvent(final Entity entity, final LivingEntity target, final TargetReason reason) { + super(entity, target, reason); + } + + public LivingEntity getTarget() { + return (LivingEntity) super.getTarget(); + } + + /** + * Set the Entity that you want the mob to target. + * It is possible to be null, null will cause the entity to be + * target-less. + * <p /> + * Must be a LivingEntity, or null + * + * @param target The entity to target + */ + public void setTarget(Entity target) { + if (target == null || target instanceof LivingEntity) { + super.setTarget(target); + } + } +} |