Minestom/src/main/java/net/minestom/server/event/player/PlayerUseItemEvent.java

49 lines
1.0 KiB
Java
Raw Normal View History

package net.minestom.server.event.player;
2019-08-21 16:50:52 +02:00
2020-04-24 03:25:58 +02:00
import net.minestom.server.entity.Player;
import net.minestom.server.event.CancellableEvent;
2020-04-24 03:25:58 +02:00
import net.minestom.server.item.ItemStack;
2019-08-21 16:50:52 +02:00
/**
2020-10-15 21:16:31 +02:00
* Event when an item is used without clicking a block.
*/
2020-04-18 15:35:37 +02:00
public class PlayerUseItemEvent extends CancellableEvent {
2019-08-21 16:50:52 +02:00
2020-07-24 16:11:48 +02:00
private final Player player;
private final Player.Hand hand;
private final ItemStack itemStack;
2019-08-21 16:50:52 +02:00
2020-05-30 22:32:12 +02:00
public PlayerUseItemEvent(Player player, Player.Hand hand, ItemStack itemStack) {
this.player = player;
2019-08-21 16:50:52 +02:00
this.hand = hand;
this.itemStack = itemStack;
}
2020-05-30 22:32:12 +02:00
/**
2020-10-15 21:16:31 +02:00
* Gets the player who used an item.
2020-05-30 22:32:12 +02:00
*
* @return the player
*/
public Player getPlayer() {
return player;
}
/**
2020-10-15 21:16:31 +02:00
* Gets which hand the player used.
2020-05-30 22:32:12 +02:00
*
* @return the hand used
*/
2019-08-21 16:50:52 +02:00
public Player.Hand getHand() {
return hand;
}
2020-05-30 22:32:12 +02:00
/**
2020-10-15 21:16:31 +02:00
* Gets the item which have been used.
2020-05-30 22:32:12 +02:00
*
* @return the item
*/
2019-08-21 16:50:52 +02:00
public ItemStack getItemStack() {
return itemStack;
}
}