Class PlayerInputEvent

java.lang.Object
net.minestom.server.event.player.PlayerInputEvent
All Implemented Interfaces:
Event, EntityEvent, EntityInstanceEvent, InstanceEvent, PlayerEvent, PlayerInstanceEvent

public final class PlayerInputEvent extends Object implements PlayerInstanceEvent
Called when a player's input state changes. This is raw input data and does not take into account any game mechanics.
For example, this event may say a player has their jump key held down even if they are in a situation where they can not actually jump.
  • Constructor Summary

    Constructors
    Constructor
    Description
    PlayerInputEvent(Player player, boolean oldForward, boolean oldBackward, boolean oldLeft, boolean oldRight, boolean oldJump, boolean oldShift, boolean oldSprint)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the player.
    boolean
    Returns true if the player has just pressed the backward key (typically the 'S' key).
    boolean
    Returns true if the player has just pressed the forward key (typically the 'W' key).
    boolean
    Returns true if the player has just pressed the jump key (typically the spacebar).
    boolean
    Returns true if the player has just pressed the left key (typically the 'A' key).
    boolean
    Returns true if the player has just pressed the right key (typically the 'D' key).
    boolean
    Returns true if the player has just pressed the shift key (typically the left shift key).
    boolean
    Returns true if the player has just pressed the sprint key (typically the left control key).
    boolean
    Returns true if the player has just released the backward key (typically the 'S' key).
    boolean
    Returns true if the player has just released the forward key (typically the 'W' key).
    boolean
    Returns true if the player has just released the jump key (typically the spacebar).
    boolean
    Returns true if the player has just released the left key (typically the 'A' key).
    boolean
    Returns true if the player has just released the right key (typically the 'D' key).
    boolean
    Returns true if the player has just released the shift key (typically the left shift key).
    boolean
    Returns true if the player has just released the sprint key (typically the left control key).
    boolean
    Returns true if the player is currently holding the backward key (typically the 'S' key).
    boolean
    Returns true if the player is currently holding the forward key (typically the 'W' key).
    boolean
    Returns true if the player is currently holding the jump key (typically the spacebar).
    boolean
    Returns true if the player is currently holding the left key (typically the 'A' key).
    boolean
    Returns true if the player is currently holding the right key (typically the 'D' key).
    boolean
    Returns true if the player is currently holding the shift key (typically the left shift key).
    boolean
    Returns true if the player is currently holding the sprint key (typically the left control key).

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface EntityInstanceEvent

    getInstance

    Methods inherited from interface PlayerEvent

    getEntity
  • Constructor Details

    • PlayerInputEvent

      public PlayerInputEvent(Player player, boolean oldForward, boolean oldBackward, boolean oldLeft, boolean oldRight, boolean oldJump, boolean oldShift, boolean oldSprint)
  • Method Details

    • getPlayer

      public Player getPlayer()
      Description copied from interface: PlayerEvent
      Gets the player.
      Specified by:
      getPlayer in interface PlayerEvent
      Returns:
      the player
    • isHoldingForwardKey

      public boolean isHoldingForwardKey()
      Returns true if the player is currently holding the forward key (typically the 'W' key).
      Returns:
      true if the player is currently holding the forward key (typically the 'W' key)
    • hasPressedForwardKey

      public boolean hasPressedForwardKey()
      Returns true if the player has just pressed the forward key (typically the 'W' key).
      Returns:
      true if the player has just pressed the forward key (typically the 'W' key)
    • hasReleasedForwardKey

      public boolean hasReleasedForwardKey()
      Returns true if the player has just released the forward key (typically the 'W' key).
      Returns:
      true if the player has just released the forward key (typically the 'W' key)
    • isHoldingBackwardKey

      public boolean isHoldingBackwardKey()
      Returns true if the player is currently holding the backward key (typically the 'S' key).
      Returns:
      true if the player is currently holding the backward key (typically the 'S' key)
    • hasPressedBackwardKey

      public boolean hasPressedBackwardKey()
      Returns true if the player has just pressed the backward key (typically the 'S' key).
      Returns:
      true if the player has just pressed the backward key (typically the 'S' key)
    • hasReleasedBackwardKey

      public boolean hasReleasedBackwardKey()
      Returns true if the player has just released the backward key (typically the 'S' key).
      Returns:
      true if the player has just released the backward key (typically the 'S' key)
    • isHoldingLeftKey

      public boolean isHoldingLeftKey()
      Returns true if the player is currently holding the left key (typically the 'A' key).
      Returns:
      true if the player is currently holding the left key (typically the 'A' key)
    • hasPressedLeftKey

      public boolean hasPressedLeftKey()
      Returns true if the player has just pressed the left key (typically the 'A' key).
      Returns:
      true if the player has just pressed the left key (typically the 'A' key)
    • hasReleasedLeftKey

      public boolean hasReleasedLeftKey()
      Returns true if the player has just released the left key (typically the 'A' key).
      Returns:
      true if the player has just released the left key (typically the 'A' key)
    • isHoldingRightKey

      public boolean isHoldingRightKey()
      Returns true if the player is currently holding the right key (typically the 'D' key).
      Returns:
      true if the player is currently holding the right key (typically the 'D' key)
    • hasPressedRightKey

      public boolean hasPressedRightKey()
      Returns true if the player has just pressed the right key (typically the 'D' key).
      Returns:
      true if the player has just pressed the right key (typically the 'D' key)
    • hasReleasedRightKey

      public boolean hasReleasedRightKey()
      Returns true if the player has just released the right key (typically the 'D' key).
      Returns:
      true if the player has just released the right key (typically the 'D' key)
    • isHoldingJumpKey

      public boolean isHoldingJumpKey()
      Returns true if the player is currently holding the jump key (typically the spacebar).
      Returns:
      true if the player is currently holding the jump key (typically the spacebar)
      API Note:
      If the player has auto-jump enabled, for 1 tick this will return true even if the player is not actually holding the jump key but may continue if they start holding it themselves.
    • hasPressedJumpKey

      public boolean hasPressedJumpKey()
      Returns true if the player has just pressed the jump key (typically the spacebar).
      Returns:
      true if the player has just pressed the jump key (typically the spacebar)
      API Note:
      If the player has auto-jump enabled, for 1 tick this will return true even if the player did not actually press the jump key.
    • hasReleasedJumpKey

      public boolean hasReleasedJumpKey()
      Returns true if the player has just released the jump key (typically the spacebar).
      Returns:
      true if the player has just released the jump key (typically the spacebar)
      API Note:
      If the player has auto-jump enabled, for 1 tick after auto-jump triggers if the player does not start holding the key themselves this will return true.
    • isHoldingShiftKey

      public boolean isHoldingShiftKey()
      Returns true if the player is currently holding the shift key (typically the left shift key).
      Returns:
      true if the player is currently holding the shift key (typically the left shift key)
    • hasPressedShiftKey

      public boolean hasPressedShiftKey()
      Returns true if the player has just pressed the shift key (typically the left shift key).
      Returns:
      true if the player has just pressed the shift key (typically the left shift key)
    • hasReleasedShiftKey

      public boolean hasReleasedShiftKey()
      Returns true if the player has just released the shift key (typically the left shift key).
      Returns:
      true if the player has just released the shift key (typically the left shift key)
    • isHoldingSprintKey

      public boolean isHoldingSprintKey()
      Returns true if the player is currently holding the sprint key (typically the left control key).
      Returns:
      true if the player is currently holding the sprint key (typically the left control key)
      API Note:
      This method only reports the state of the sprint key itself, not other ways to start sprinting such as double-tapping the forward key.
    • hasPressedSprintKey

      public boolean hasPressedSprintKey()
      Returns true if the player has just pressed the sprint key (typically the left control key).
      Returns:
      true if the player has just pressed the sprint key (typically the left control key)
      API Note:
      This method only reports the state of the sprint key itself, not other ways to start sprinting such as double-tapping the forward key.
    • hasReleasedSprintKey

      public boolean hasReleasedSprintKey()
      Returns true if the player has just released the sprint key (typically the left control key).
      Returns:
      true if the player has just released the sprint key (typically the left control key)
      API Note:
      This method only reports the state of the sprint key itself, not other ways to start sprinting such as double-tapping the forward key.