Class PlayerCommandEvent

java.lang.Object
me.internalizable.numdrassl.api.event.player.PlayerCommandEvent
All Implemented Interfaces:
Cancellable

public class PlayerCommandEvent extends Object implements Cancellable
Event fired when a player executes a command (chat message starting with /). This is fired BEFORE the command is processed.

This event is cancellable. If cancelled, the command will not be executed.

If the command is handled by a plugin, set cancelled to true to prevent the command from being sent to the backend server.

  • Constructor Details

    • PlayerCommandEvent

      public PlayerCommandEvent(@Nonnull Player player, @Nonnull String commandLine)
  • Method Details

    • getPlayer

      @Nonnull public Player getPlayer()
      Get the player who executed the command.
      Returns:
      the player
    • getCommand

      @Nonnull public String getCommand()
      Get the command name (without leading slash).
      Returns:
      the command name
    • getArgs

      @Nonnull public String[] getArgs()
      Get the command arguments.
      Returns:
      the arguments array
    • getCommandLine

      @Nonnull public String getCommandLine()
      Get the full command line (with leading slash).
      Returns:
      the full command line
    • shouldForwardToServer

      public boolean shouldForwardToServer()
      Check if this command should be forwarded to the backend server. Set to false if the proxy handles this command.
      Returns:
      true if should forward to server
    • setForwardToServer

      public void setForwardToServer(boolean forward)
      Set whether this command should be forwarded to the backend server.
      Parameters:
      forward - true to forward, false to handle at proxy level
    • isCancelled

      public boolean isCancelled()
      Description copied from interface: Cancellable
      Check if this event has been cancelled.
      Specified by:
      isCancelled in interface Cancellable
      Returns:
      true if the event is cancelled
    • setCancelled

      public void setCancelled(boolean cancelled)
      Description copied from interface: Cancellable
      Set whether this event is cancelled.
      Specified by:
      setCancelled in interface Cancellable
      Parameters:
      cancelled - true to cancel the event