mirror of
https://github.com/Minestom/Minestom.git
synced 2024-06-23 21:15:01 +02:00
48 lines
1.3 KiB
Java
48 lines
1.3 KiB
Java
package net.minestom.server.event.player;
|
|
|
|
import net.minestom.server.entity.Entity;
|
|
import net.minestom.server.entity.Player;
|
|
import net.minestom.server.event.trait.EntityInstanceEvent;
|
|
import net.minestom.server.event.trait.PlayerEvent;
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
/**
|
|
* Called when a {@link Player} interacts (right-click) with an {@link Entity}.
|
|
*/
|
|
public class PlayerEntityInteractEvent implements PlayerEvent, EntityInstanceEvent {
|
|
|
|
private final Player player;
|
|
private final Entity entityTarget;
|
|
private final Player.Hand hand;
|
|
|
|
public PlayerEntityInteractEvent(@NotNull Player player, @NotNull Entity entityTarget, @NotNull Player.Hand hand) {
|
|
this.player = player;
|
|
this.entityTarget = entityTarget;
|
|
this.hand = hand;
|
|
}
|
|
|
|
/**
|
|
* Gets the {@link Entity} with who {@link #getPlayer()} is interacting.
|
|
*
|
|
* @return the {@link Entity}
|
|
*/
|
|
@NotNull
|
|
public Entity getTarget() {
|
|
return entityTarget;
|
|
}
|
|
|
|
/**
|
|
* Gets with which hand the player interacted with the entity.
|
|
*
|
|
* @return the hand
|
|
*/
|
|
@NotNull
|
|
public Player.Hand getHand() {
|
|
return hand;
|
|
}
|
|
|
|
@Override
|
|
public @NotNull Player getPlayer() {
|
|
return player;
|
|
}
|
|
} |