Class PlayerChangeHeldSlotEvent
java.lang.Object
net.minestom.server.event.player.PlayerChangeHeldSlotEvent
- All Implemented Interfaces:
Event, CancellableEvent, EntityEvent, EntityInstanceEvent, InstanceEvent, PlayerEvent, PlayerInstanceEvent
public class PlayerChangeHeldSlotEvent
extends Object
implements PlayerInstanceEvent, CancellableEvent
Called when a player change his held slot (by pressing 1-9 keys).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the ItemStack in the slot the player will holdGets the ItemStack in the player's currently held slotbyteGets the slot which the player will hold.byteGets the slot number that the player is currently holdingGets the player.bytegetSlot()Deprecated, for removal: This API element is subject to removal in a future version.booleanGets if theEventshould be cancelled or not.voidsetCancelled(boolean cancel) Marks theEventas cancelled or not.voidsetNewSlot(byte slot) Changes the final held slot of the player.voidsetSlot(byte slot) Deprecated, for removal: This API element is subject to removal in a future version.UsesetNewSlot(byte)insteadMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface EntityInstanceEvent
getInstanceMethods inherited from interface PlayerEvent
getEntity
-
Constructor Details
-
PlayerChangeHeldSlotEvent
-
-
Method Details
-
getSlot
Deprecated, for removal: This API element is subject to removal in a future version.UsegetNewSlot()instead.Gets the slot which the player will hold.- Returns:
- the future slot
-
getOldSlot
public byte getOldSlot()Gets the slot number that the player is currently holding- Returns:
- The slot index that the player currently is holding
-
getNewSlot
public byte getNewSlot()Gets the slot which the player will hold.- Returns:
- the future slot
-
setSlot
Deprecated, for removal: This API element is subject to removal in a future version.UsesetNewSlot(byte)insteadChanges the final held slot of the player.- Parameters:
slot- the new held slot- Throws:
IllegalArgumentException- ifslotis not between 0 and 8
-
setNewSlot
public void setNewSlot(byte slot) Changes the final held slot of the player.- Parameters:
slot- the new held slot- Throws:
IllegalArgumentException- ifslotis not between 0 and 8
-
getItemInOldSlot
Gets the ItemStack in the player's currently held slot- Returns:
- The ItemStack in the player's currently held slot
-
getItemInNewSlot
Gets the ItemStack in the slot the player will hold- Returns:
- The ItemStack in the final held slot of the player
-
isCancelled
public boolean isCancelled()Description copied from interface:CancellableEventGets if theEventshould be cancelled or not.- Specified by:
isCancelledin interfaceCancellableEvent- Returns:
- true if the event should be cancelled
-
setCancelled
public void setCancelled(boolean cancel) Description copied from interface:CancellableEventMarks theEventas cancelled or not.- Specified by:
setCancelledin interfaceCancellableEvent- Parameters:
cancel- true if the event should be cancelled, false otherwise
-
getPlayer
Description copied from interface:PlayerEventGets the player.- Specified by:
getPlayerin interfacePlayerEvent- Returns:
- the player
-
getNewSlot()instead.