Class NodeClickContext
java.lang.Object
io.github.somesourcecode.someguiapi.scene.action.NodeClickContext
Represents the context of a node click.
It contains information about the type of click that was performed and the player that clicked.
-
Constructor Summary
ConstructorsConstructorDescriptionNodeClickContext(int x, int y, org.bukkit.event.inventory.ClickType type, org.bukkit.entity.Player player, int hotBarButton) Creates a new node click context. -
Method Summary
Modifier and TypeMethodDescriptionvoidconsume()Consumes the click.intReturns the hot bar button that was clicked.org.bukkit.entity.PlayerReturns the player that clicked the node.intgetSlotX()Returns the x coordinate of the slot that was clicked.intgetSlotY()Returns the y coordinate of the slot that was clicked.org.bukkit.event.inventory.ClickTypegetType()Returns the type of click that was performed.booleanReturns true if the click has been consumed; false otherwise.booleanReturn true if the click was a hot bar click; false otherwise.booleanReturn true if the click was a left click; false otherwise.booleanReturn true if the click was a right click; false otherwise.booleanReturn true if the click was a shift click; false otherwise.
-
Constructor Details
-
NodeClickContext
public NodeClickContext(int x, int y, org.bukkit.event.inventory.ClickType type, org.bukkit.entity.Player player, int hotBarButton) Creates a new node click context.- Parameters:
x- the x coordinate of the slot that was clickedy- the y coordinate of the slot that was clickedtype- the type of click that was performedplayer- the player that clicked the nodehotBarButton- the hot bar button that was clicked
-
-
Method Details
-
getSlotX
public int getSlotX()Returns the x coordinate of the slot that was clicked. This is the slot's x coordinate in the inventory, and not relative to the nodes bounds.- Returns:
- the x coordinate of the slot that was clicked
-
getSlotY
public int getSlotY()Returns the y coordinate of the slot that was clicked. This is the slot's y coordinate in the inventory, and not relative to the nodes bounds.- Returns:
- the y coordinate of the slot that was clicked
-
getType
public org.bukkit.event.inventory.ClickType getType()Returns the type of click that was performed.- Returns:
- the type of click that was performed
-
isLeftClick
public boolean isLeftClick()Return true if the click was a left click; false otherwise. This method is equivalent to callinggetType().isLeftClick().- Returns:
- whether the click was a left click
-
isRightClick
public boolean isRightClick()Return true if the click was a right click; false otherwise. This method is equivalent to callinggetType().isRightClick().- Returns:
- whether the click was a right click
-
isShiftClick
public boolean isShiftClick()Return true if the click was a shift click; false otherwise. This method is equivalent to callinggetType().isShiftClick().- Returns:
- whether the click was a shift click
-
isHotBarClick
public boolean isHotBarClick()Return true if the click was a hot bar click; false otherwise.- Returns:
- whether the click was a hot bar click
-
getPlayer
public org.bukkit.entity.Player getPlayer()Returns the player that clicked the node.- Returns:
- the player that clicked the node
-
getHotBarButton
public int getHotBarButton()Returns the hot bar button that was clicked. If the click was not a hot bar click, this method returns -1.- Returns:
- the hot bar button that was clicked
-
isConsumed
public boolean isConsumed()Returns true if the click has been consumed; false otherwise.- Returns:
- whether the click has been consumed
-
consume
public void consume()Consumes the click. Once a click has been consumed,isConsumed()will returntrue.
-