summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/bukkit/event/entity/EntityTargetLivingEntityEvent.java
blob: f5010b1e3e0d72dc9f15c0ff393f1466ae78aed5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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);
        }
    }
}