Class ClickPreprocessor

java.lang.Object
net.minestom.server.inventory.click.ClickPreprocessor

public final class ClickPreprocessor extends Object
Preprocesses click packets, turning them into Click instances for further processing.
  • Constructor Details

    • ClickPreprocessor

      public ClickPreprocessor()
  • Method Details

    • clearCache

      public void clearCache()
    • isCreativeClick

      public boolean isCreativeClick(@NotNull @NotNull Click click, boolean hasCursorItem)
      Determines whether or not a click is creative only. This should match client behaviour, including edge cases like middle clicks (item clones) being sent in survival when there is an item in the cursor (which would make it a no-op), hence the parameter. This function can be overridden if modifying the creative check logic is desired, since WindowListener directly depends on this.
      Parameters:
      click - the click to check
      hasCursorItem - if the client has an item in the cursor (for checking Click.Middle)
      Returns:
      if the click is creative only
    • processClick

      @Nullable public @Nullable Click processClick(@NotNull @NotNull ClientClickWindowPacket packet, @Nullable @Nullable Integer containerSize)
      Processes the provided click packet, turning it into a Click.
      Parameters:
      packet - the raw click packet
      containerSize - the size of the open container, or null if the player inventory is open
      Returns:
      the processed click, or nothing if the click takes place over multiple packets and this is not the final one (e.g. a drag)