Interface CommandSenderWrapper

All Known Implementing Classes:
CommandSenderWrapper.Bukkit, CommandSenderWrapper.Remote

public interface CommandSenderWrapper
This class is an alternative to Bukkit's CommandSender that extends to functionalities, such as forcing all permissions and allows the use of remote players RemotePlayer. It does this by wrapping those instances.

This is for instance used in commands to permit the remote execution.

  • Method Details

    • getName

      String getName()
      Remotes the name of the sender.

      For Bukkit Players: CommandSender.getName()
      For Remote Players: RemotePlayer.getName()

      Returns:
      The name of the sender
    • getUniqueId

      @Nullable @Nullable UUID getUniqueId()
      Remotes the uuid of the sender. May be null if it's not supported for the type.

      For Bukkit Players: Entity.getUniqueId()
      For Remote Players: RemotePlayer.getUniqueId()

      Returns:
      The uuid of the reference, might be null
    • isBukkitPlayer

      boolean isBukkitPlayer()
      Returns whether an online player executed this.

      If this method returns true, you may use getBukkitPlayer().

      Returns:
      Returns true when an actual Player is being referenced.
    • isRemotePlayer

      boolean isRemotePlayer()
      Returns whether it's a player on a remote server.

      If this method returns true, you may use getRemotePlayer().

      Returns:
      Returns true when an actual RemotePlayer is being referenced.
    • getReference

      Object getReference()
      Returns the object that's being referenced. This may be a CommandSender or a RemotePlayer.
      Returns:
      The instance that's being wrapped
    • getCommandSender

      CommandSender getCommandSender()
      Returns the CommandSender that is being wrapped.

      Returns null when it is not being wrapped.

      Returns:
      The CommandSender that is being wrapped. May be null
    • getBukkitPlayer

      @Nullable @Nullable Player getBukkitPlayer()
      Returns the Player that is being wrapped.

      Returns null when the player is not on this server or when it's not a player.

      Returns:
      The Player that is being wrapped. May be null
    • getRemotePlayer

      @Nullable @Nullable RemotePlayer getRemotePlayer()
      Returns the RemotePlayer that is being wrapped.

      Returns null when the player is not on a remote server.

      Returns:
      The RemotePlayer that is being wrapped. May be null
    • sendMessage

      void sendMessage(String message)
      Sends a message to the sender.

      For Bukkit Players: CommandSender.sendMessage(String) ()}
      For Remote Players: RemotePlayer.sendMessage(String...) ()}

      Parameters:
      message - The message that shall be sent
    • sendMessage

      void sendMessage(String... messages)
      Sends multiple messages to the sender.

      For Bukkit Players: CommandSender.sendMessage(String[]) ()}
      For Remote Players: RemotePlayer.sendMessage(String...) ()}

      Parameters:
      messages - The messages that shall be sent
    • hasPermission

      boolean hasPermission(String name)
      Returns whether the sender has a given permission.

      For Bukkit Players: Permissible.hasPermission(String) ()} (Or when hasOP is true: Always true)
      For Remote Players: Always true

      Parameters:
      name - The permission that shall be checked
    • hasPermission

      boolean hasPermission(Permission perm)
      Returns whether the sender has a given permission.

      For Bukkit Players: Permissible.hasPermission(Permission) ()} (Or when hasOP is true: Always true)
      For Remote Players: Always true

      Parameters:
      perm - The permission that shall be checked
    • wrap

      static CommandSenderWrapper wrap(CommandSender sender)
      Constructs a new instance with a reference of the given sender.
      Parameters:
      sender - The sender that shall be wrapped
      Returns:
      The wrapped sender
    • wrap

      static CommandSenderWrapper wrap(CommandSender sender, boolean hasOP)
      Constructs a new instance with a reference of the given sender.
      Parameters:
      sender - The sender that shall be wrapped
      hasOP - true: hasPermission(String) always return true; false: uses Permissible.hasPermission(String)
      Returns:
      The wrapped sender
    • wrap

      static CommandSenderWrapper wrap(RemotePlayer player)
      Constructs a new instance with a reference of the given player.
      Parameters:
      player - The player that shall be wrapped
      Returns:
      The wrapped player