Minestom/src/main/java/net/minestom/server/event/entity/EntityAttackEvent.java

34 lines
823 B
Java
Raw Normal View History

package net.minestom.server.event.entity;
2019-08-21 16:50:52 +02:00
2020-04-24 03:25:58 +02:00
import net.minestom.server.entity.Entity;
2021-10-06 20:40:17 +02:00
import net.minestom.server.event.trait.EntityInstanceEvent;
2020-10-24 16:33:13 +02:00
import org.jetbrains.annotations.NotNull;
2019-08-21 16:50:52 +02:00
2020-05-28 19:15:55 +02:00
/**
* Called when a player does a left click on an entity or with
2020-10-24 16:33:13 +02:00
* {@link net.minestom.server.entity.EntityCreature#attack(Entity)}.
2020-05-28 19:15:55 +02:00
*/
2021-10-06 20:40:17 +02:00
public class EntityAttackEvent implements EntityInstanceEvent {
2019-08-21 16:50:52 +02:00
2021-06-02 07:09:15 +02:00
private final Entity entity;
2020-07-24 16:11:48 +02:00
private final Entity target;
2019-08-21 16:50:52 +02:00
2020-10-24 16:33:13 +02:00
public EntityAttackEvent(@NotNull Entity source, @NotNull Entity target) {
2021-06-02 07:09:15 +02:00
this.entity = source;
2019-08-21 16:50:52 +02:00
this.target = target;
}
2021-06-02 07:09:15 +02:00
@Override
public @NotNull Entity getEntity() {
return entity;
}
2020-05-28 19:15:55 +02:00
/**
* @return the target of the attack
*/
2020-10-24 16:33:13 +02:00
@NotNull
2019-08-21 16:50:52 +02:00
public Entity getTarget() {
return target;
}
}