Class SpigotCommandSender

java.lang.Object
me.github.simonplays15.betterbansystem.core.player.BaseCommandSender
me.github.simonplays15.betterbansystem.core.player.SpigotCommandSender
All Implemented Interfaces:
org.bukkit.command.CommandSender, org.bukkit.permissions.Permissible, org.bukkit.permissions.ServerOperator

public class SpigotCommandSender extends BaseCommandSender implements org.bukkit.command.CommandSender
SpigotCommandSender is a class that represents a command sender in the Spigot server. It extends the BaseCommandSender class and implements the CommandSender interface. It provides methods for sending messages, checking permissions, getting the name of the sender, and determining the type of sender.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.bukkit.command.CommandSender

    org.bukkit.command.CommandSender.Spigot
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for the SpigotCommandSender class.
    SpigotCommandSender (org.bukkit.command.CommandSender base)
    SpigotCommandSender is a class that represents a command sender in the Spigot plugin for Bukkit.
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull org.bukkit.permissions.PermissionAttachment
    addAttachment (@NotNull org.bukkit.plugin.Plugin plugin)
    Adds a permission attachment for the specified plugin to this command sender.
    @Nullable org.bukkit.permissions.PermissionAttachment
    addAttachment (@NotNull org.bukkit.plugin.Plugin plugin, int priority)
    Adds a permission attachment to this sender for the specified plugin with the given priority.
    @NotNull org.bukkit.permissions.PermissionAttachment
    addAttachment (@NotNull org.bukkit.plugin.Plugin plugin, @NotNull String s, boolean b)
    Adds a permission attachment to the command sender.
    @Nullable org.bukkit.permissions.PermissionAttachment
    addAttachment (@NotNull org.bukkit.plugin.Plugin plugin, @NotNull String s, boolean b, int i)
    Adds a permission attachment to this command sender.
    org.bukkit.command.CommandSender
    Retrieves the base CommandSender associated with this object.
    @NotNull Set<org.bukkit.permissions.PermissionAttachmentInfo>
    Retrieves the effective permissions of the command sender.
    @NotNull String
    Retrieves the name of the command sender.
    Retrieves the type of the command sender.
    @NotNull org.bukkit.Server
    Returns the server associated with this command sender.
    boolean
    hasPermission (@NotNull String s)
    Checks if the command sender has the specified permission.
    boolean
    hasPermission (@NotNull org.bukkit.permissions.Permission permission)
    Checks if the command sender has the specified permission.
    boolean
    isOp()
    Determines whether the command sender has operator permissions.
    boolean
    isPermissionSet (@NotNull String s)
    Determines whether the command sender has the specified permission.
    boolean
    isPermissionSet (@NotNull org.bukkit.permissions.Permission permission)
    Checks if the command sender has the specified permission.
    static @NotNull SpigotCommandSender
    of (Object sender)
    Converts an object to a SpigotCommandSender.
    void
    Recalculates the permissions of the command sender.
    void
    removeAttachment (@NotNull org.bukkit.permissions.PermissionAttachment permissionAttachment)
    Removes a permission attachment from the command sender.
    void
    sendMessage (@NotNull String string)
    Sends a message to the command sender with the specified string.
    void
    sendMessage (@NotNull String @NotNull ... strings)
    Sends a message or multiple messages to the command sender.
    void
    sendMessage (@Nullable UUID uuid, @NotNull String s)
    Sends a message to the specified player identified by their UUID.
    void
    sendMessage (@Nullable UUID uuid, @NotNull String... strings)
    This method sends a message or multiple messages to the command sender.
    void
    setOp (boolean b)
    Sets the op status of the command sender.
    @NotNull org.bukkit.command.CommandSender.Spigot
    Retrieves the Spigot for this command sender.

    Methods inherited from class me.github.simonplays15.betterbansystem.core.player.BaseCommandSender

    isBlock, isConsole, isOther, isPlayer

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SpigotCommandSender

      public SpigotCommandSender (org.bukkit.command.CommandSender base)
      SpigotCommandSender is a class that represents a command sender in the Spigot plugin for Bukkit. It extends the BaseCommandSender class and provides additional functionality to identify the type of sender.
    • SpigotCommandSender

      public SpigotCommandSender (Object base)
      Constructor for the SpigotCommandSender class. Initializes a new instance of the SpigotCommandSender class with the given base object.
      Parameters:
      base - The base object of type Object, representing the command sender.
  • Method Details

    • of

      @Contract("_ -> new") @NotNull public static @NotNull SpigotCommandSender of (Object sender)
      Converts an object to a SpigotCommandSender.
      Parameters:
      sender - the object to convert
      Returns:
      a new instance of SpigotCommandSender
    • getSenderType

      public CommandSenderType getSenderType()
      Retrieves the type of the command sender.
      Specified by:
      getSenderType in class BaseCommandSender
      Returns:
      The CommandSenderType representing the type of the command sender.
    • getBase

      public org.bukkit.command.CommandSender getBase()
      Retrieves the base CommandSender associated with this object.
      Returns:
      the base CommandSender object
    • sendMessage

      public void sendMessage (@NotNull @NotNull String string)
      Sends a message to the command sender with the specified string. The message is prefixed with the prefix retrieved from BetterBanSystem.
      Specified by:
      sendMessage in interface org.bukkit.command.CommandSender
      Specified by:
      sendMessage in class BaseCommandSender
      Parameters:
      string - the string message to send
    • sendMessage

      public void sendMessage (@NotNull @NotNull String @NotNull ... strings)
      Sends a message or multiple messages to the command sender.
      Specified by:
      sendMessage in interface org.bukkit.command.CommandSender
      Specified by:
      sendMessage in class BaseCommandSender
      Parameters:
      strings - the messages to be sent to the command sender
      Throws:
      NullPointerException - if strings is null
    • sendMessage

      public void sendMessage (@Nullable @Nullable UUID uuid, @NotNull @NotNull String s)
      Sends a message to the specified player identified by their UUID.
      Specified by:
      sendMessage in interface org.bukkit.command.CommandSender
      Specified by:
      sendMessage in class BaseCommandSender
      Parameters:
      uuid - The UUID of the player to send the message to. Can be null if the message is intended for all players.
      s - The message to send.
    • sendMessage

      public void sendMessage (@Nullable @Nullable UUID uuid, @NotNull @NotNull String... strings)
      This method sends a message or multiple messages to the command sender.
      Specified by:
      sendMessage in interface org.bukkit.command.CommandSender
      Specified by:
      sendMessage in class BaseCommandSender
      Parameters:
      uuid - The UUID of the command sender to send the message to. Can be null for console.
      strings - The messages to be sent to the command sender.
    • getServer

      @NotNull public @NotNull org.bukkit.Server getServer()
      Returns the server associated with this command sender.
      Specified by:
      getServer in interface org.bukkit.command.CommandSender
      Returns:
      The server associated with this command sender.
    • getName

      @NotNull public @NotNull String getName()
      Retrieves the name of the command sender.
      Specified by:
      getName in interface org.bukkit.command.CommandSender
      Specified by:
      getName in class BaseCommandSender
      Returns:
      the name of the command sender
    • spigot

      @NotNull public @NotNull org.bukkit.command.CommandSender.Spigot spigot()
      Retrieves the Spigot for this command sender.
      Specified by:
      spigot in interface org.bukkit.command.CommandSender
      Returns:
      the Spigot for this command sender.
    • isPermissionSet

      public boolean isPermissionSet (@NotNull @NotNull String s)
      Determines whether the command sender has the specified permission.
      Specified by:
      isPermissionSet in interface org.bukkit.permissions.Permissible
      Parameters:
      s - the permission to check
      Returns:
      true if the command sender has the permission, false otherwise
    • isPermissionSet

      public boolean isPermissionSet (@NotNull @NotNull org.bukkit.permissions.Permission permission)
      Checks if the command sender has the specified permission.
      Specified by:
      isPermissionSet in interface org.bukkit.permissions.Permissible
      Parameters:
      permission - the permission to check
      Returns:
      true if the command sender has the permission, false otherwise
    • hasPermission

      public boolean hasPermission (@NotNull @NotNull String s)
      Checks if the command sender has the specified permission.
      Specified by:
      hasPermission in interface org.bukkit.permissions.Permissible
      Specified by:
      hasPermission in class BaseCommandSender
      Parameters:
      s - the permission to check
      Returns:
      true if the command sender has the permission, false otherwise
    • hasPermission

      public boolean hasPermission (@NotNull @NotNull org.bukkit.permissions.Permission permission)
      Checks if the command sender has the specified permission.
      Specified by:
      hasPermission in interface org.bukkit.permissions.Permissible
      Parameters:
      permission - the permission to check
      Returns:
      true if the command sender has the permission, false otherwise
    • addAttachment

      @NotNull public @NotNull org.bukkit.permissions.PermissionAttachment addAttachment (@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull String s, boolean b)
      Adds a permission attachment to the command sender.
      Specified by:
      addAttachment in interface org.bukkit.permissions.Permissible
      Parameters:
      plugin - the plugin that owns the attachment
      s - the permission string
      b - the value of the permission
      Returns:
      the PermissionAttachment object representing the added attachment
    • addAttachment

      @NotNull public @NotNull org.bukkit.permissions.PermissionAttachment addAttachment (@NotNull @NotNull org.bukkit.plugin.Plugin plugin)
      Adds a permission attachment for the specified plugin to this command sender.
      Specified by:
      addAttachment in interface org.bukkit.permissions.Permissible
      Parameters:
      plugin - the plugin that owns the attachment
      Returns:
      the newly created PermissionAttachment
    • addAttachment

      @Nullable public @Nullable org.bukkit.permissions.PermissionAttachment addAttachment (@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull String s, boolean b, int i)
      Adds a permission attachment to this command sender.
      Specified by:
      addAttachment in interface org.bukkit.permissions.Permissible
      Parameters:
      plugin - the plugin that owns this attachment
      s - the permission string
      b - the value of the permission
      i - the ticks remaining for the attachment (useful for temporary permissions)
      Returns:
      the permission attachment that was added
    • addAttachment

      @Nullable public @Nullable org.bukkit.permissions.PermissionAttachment addAttachment (@NotNull @NotNull org.bukkit.plugin.Plugin plugin, int priority)
      Adds a permission attachment to this sender for the specified plugin with the given priority.
      Specified by:
      addAttachment in interface org.bukkit.permissions.Permissible
      Parameters:
      plugin - The plugin that owns the attachment
      priority - The priority of the attachment
      Returns:
      The newly created PermissionAttachment, or null if it was not possible to create one
    • removeAttachment

      public void removeAttachment (@NotNull @NotNull org.bukkit.permissions.PermissionAttachment permissionAttachment)
      Removes a permission attachment from the command sender.
      Specified by:
      removeAttachment in interface org.bukkit.permissions.Permissible
      Parameters:
      permissionAttachment - the permission attachment to remove
    • recalculatePermissions

      public void recalculatePermissions()
      Recalculates the permissions of the command sender.

      This method delegates the task of recalculating permissions to the Permissible.recalculatePermissions() method of the base command sender object.

      Specified by:
      recalculatePermissions in interface org.bukkit.permissions.Permissible
    • getEffectivePermissions

      @NotNull public @NotNull Set<org.bukkit.permissions.PermissionAttachmentInfo> getEffectivePermissions()
      Retrieves the effective permissions of the command sender.
      Specified by:
      getEffectivePermissions in interface org.bukkit.permissions.Permissible
      Returns:
      a Set of PermissionAttachmentInfo representing the effective permissions of the command sender
    • isOp

      public boolean isOp()
      Determines whether the command sender has operator permissions.
      Specified by:
      isOp in interface org.bukkit.permissions.ServerOperator
      Returns:
      true if the command sender has operator permissions, false otherwise
    • setOp

      public void setOp (boolean b)
      Sets the op status of the command sender.
      Specified by:
      setOp in interface org.bukkit.permissions.ServerOperator
      Parameters:
      b - the op status to set