Interface ClickContext
public interface ClickContext
Everything about one inventory click inside an open view, plus convenient actions
to react to it (mutate contents, navigate, play sounds).
Handlers run on the player's Netty thread. Keep them fast and do not block. For
expensive work, use the Velocity scheduler and mutate contents() when it
completes.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanback()Returns to the previous view, if any.The decoded click type.voidclose()Closes the view.contents()The live contents of the open view.context()The per-open key/value context.intdefault booleanisGui()True when the click landed in the top (GUI) half of the window.booleanTrue when the click landed in the player-inventory half of the window.default booleanShortcut forclickType().isShift().voidOpens another view, pushing the current one onto the back-history.voidopenReplacing(View view) Opens another view without pushing history.com.velocitypowered.api.proxy.Playerplayer()The player who clicked.voidplaySound(com.github.retrooper.packetevents.protocol.sound.Sound sound) Plays a sound only this player hears (volume 1, pitch 1).voidplaySound(com.github.retrooper.packetevents.protocol.sound.Sound sound, float volume, float pitch) Plays a sound only this player hears.intThe raw button id from the click packet.intrawMode()The raw click mode ordinal from the click packet (pickup, quick-move, swap, ...).intslot()The clicked slot, or-999for clicks outside the window.slotPos()The row/column of the clicked slot, ornullfor outside/player-inventory clicks.intstateId()The client's window state id from the click packet, or-1if absent.view()The view being clicked.
-
Method Details
-
player
com.velocitypowered.api.proxy.Player player()The player who clicked. -
slot
int slot()The clicked slot, or-999for clicks outside the window. -
clickType
ClickType clickType()The decoded click type. -
hotbarKey
int hotbarKey() -
slotPos
Slot slotPos()The row/column of the clicked slot, ornullfor outside/player-inventory clicks. -
isPlayerInventory
boolean isPlayerInventory()True when the click landed in the player-inventory half of the window. -
isGui
default boolean isGui()True when the click landed in the top (GUI) half of the window. -
isShiftClick
default boolean isShiftClick()Shortcut forclickType().isShift(). -
view
View view()The view being clicked. -
contents
ViewContents contents()The live contents of the open view. Handlers may mutate it directly. -
context
ViewContext context()The per-open key/value context. -
rawButton
int rawButton()The raw button id from the click packet. -
rawMode
int rawMode()The raw click mode ordinal from the click packet (pickup, quick-move, swap, ...). -
stateId
int stateId()The client's window state id from the click packet, or-1if absent. -
close
void close()Closes the view. -
open
Opens another view, pushing the current one onto the back-history. -
openReplacing
Opens another view without pushing history. -
back
boolean back()Returns to the previous view, if any. -
playSound
void playSound(com.github.retrooper.packetevents.protocol.sound.Sound sound) Plays a sound only this player hears (volume 1, pitch 1). -
playSound
void playSound(com.github.retrooper.packetevents.protocol.sound.Sound sound, float volume, float pitch) Plays a sound only this player hears.
-