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 Type
    Method
    Description
    boolean
    Returns to the previous view, if any.
    The decoded click type.
    void
    Closes the view.
    The live contents of the open view.
    The per-open key/value context.
    int
    The pressed hotbar key in [0, 8] when clickType() is ClickType.NUMBER_KEY, otherwise -1.
    default boolean
    True when the click landed in the top (GUI) half of the window.
    boolean
    True when the click landed in the player-inventory half of the window.
    default boolean
    Shortcut for clickType().isShift().
    void
    open(View view)
    Opens another view, pushing the current one onto the back-history.
    void
    Opens another view without pushing history.
    com.velocitypowered.api.proxy.Player
    The player who clicked.
    void
    playSound(com.github.retrooper.packetevents.protocol.sound.Sound sound)
    Plays a sound only this player hears (volume 1, pitch 1).
    void
    playSound(com.github.retrooper.packetevents.protocol.sound.Sound sound, float volume, float pitch)
    Plays a sound only this player hears.
    int
    The raw button id from the click packet.
    int
    The raw click mode ordinal from the click packet (pickup, quick-move, swap, ...).
    int
    The clicked slot, or -999 for clicks outside the window.
    The row/column of the clicked slot, or null for outside/player-inventory clicks.
    int
    The client's window state id from the click packet, or -1 if absent.
    The view being clicked.
  • Method Details

    • player

      com.velocitypowered.api.proxy.Player player()
      The player who clicked.
    • slot

      int slot()
      The clicked slot, or -999 for clicks outside the window.
    • clickType

      ClickType clickType()
      The decoded click type.
    • hotbarKey

      int hotbarKey()
      The pressed hotbar key in [0, 8] when clickType() is ClickType.NUMBER_KEY, otherwise -1.
    • slotPos

      Slot slotPos()
      The row/column of the clicked slot, or null for 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 for clickType().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 -1 if absent.
    • close

      void close()
      Closes the view.
    • open

      void open(View view)
      Opens another view, pushing the current one onto the back-history.
    • openReplacing

      void openReplacing(View view)
      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.