geforkt von Mirrors/Paper
[Bleeding] Add new sub-event for target goals, and DEFEND_VILLAGE TargetReason. Fixes BUKKIT-935
By: feildmaster <admin@feildmaster.com>
Dieser Commit ist enthalten in:
Ursprung
2a716ddd7e
Commit
dc73238490
@ -9,14 +9,13 @@ import org.bukkit.event.HandlerList;
|
|||||||
*/
|
*/
|
||||||
public class EntityTargetEvent extends EntityEvent implements Cancellable {
|
public class EntityTargetEvent extends EntityEvent implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private boolean cancel;
|
private boolean cancel = false;
|
||||||
private Entity target;
|
private Entity target;
|
||||||
private final TargetReason reason;
|
private final TargetReason reason;
|
||||||
|
|
||||||
public EntityTargetEvent(final Entity entity, final Entity target, final TargetReason reason) {
|
public EntityTargetEvent(final Entity entity, final Entity target, final TargetReason reason) {
|
||||||
super(entity);
|
super(entity);
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.cancel = false;
|
|
||||||
this.reason = reason;
|
this.reason = reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,6 +111,10 @@ public class EntityTargetEvent extends EntityEvent implements Cancellable {
|
|||||||
* When the entity has no target, so the entity randomly chooses one.
|
* When the entity has no target, so the entity randomly chooses one.
|
||||||
*/
|
*/
|
||||||
RANDOM_TARGET,
|
RANDOM_TARGET,
|
||||||
|
/**
|
||||||
|
* When an entity selects a target while defending a village.
|
||||||
|
*/
|
||||||
|
DEFEND_VILLAGE,
|
||||||
/**
|
/**
|
||||||
* For custom calls to the event
|
* For custom calls to the event
|
||||||
*/
|
*/
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren