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
ConstructorsConstructorDescriptionSpigotCommandSender
(Object base) 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 TypeMethodDescription@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
getBase()
Retrieves the base CommandSender associated with this object.@NotNull Set<org.bukkit.permissions.PermissionAttachmentInfo>
Retrieves the effective permissions of the command sender.@NotNull String
getName()
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
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
spigot()
Retrieves the Spigot for this command sender.Methods inherited from class me.github.simonplays15.betterbansystem.core.player.BaseCommandSender
isBlock, isConsole, isOther, isPlayer
-
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
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
Converts an object to a SpigotCommandSender.- Parameters:
sender
- the object to convert- Returns:
- a new instance of SpigotCommandSender
-
getSenderType
Retrieves the type of the command sender.- Specified by:
getSenderType
in classBaseCommandSender
- 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
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 interfaceorg.bukkit.command.CommandSender
- Specified by:
sendMessage
in classBaseCommandSender
- Parameters:
string
- the string message to send
-
sendMessage
Sends a message or multiple messages to the command sender.- Specified by:
sendMessage
in interfaceorg.bukkit.command.CommandSender
- Specified by:
sendMessage
in classBaseCommandSender
- Parameters:
strings
- the messages to be sent to the command sender- Throws:
NullPointerException
- ifstrings
isnull
-
sendMessage
Sends a message to the specified player identified by their UUID.- Specified by:
sendMessage
in interfaceorg.bukkit.command.CommandSender
- Specified by:
sendMessage
in classBaseCommandSender
- 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
This method sends a message or multiple messages to the command sender.- Specified by:
sendMessage
in interfaceorg.bukkit.command.CommandSender
- Specified by:
sendMessage
in classBaseCommandSender
- 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 interfaceorg.bukkit.command.CommandSender
- Returns:
- The server associated with this command sender.
-
getName
Retrieves the name of the command sender.- Specified by:
getName
in interfaceorg.bukkit.command.CommandSender
- Specified by:
getName
in classBaseCommandSender
- 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 interfaceorg.bukkit.command.CommandSender
- Returns:
- the Spigot for this command sender.
-
isPermissionSet
Determines whether the command sender has the specified permission.- Specified by:
isPermissionSet
in interfaceorg.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 interfaceorg.bukkit.permissions.Permissible
- Parameters:
permission
- the permission to check- Returns:
- true if the command sender has the permission, false otherwise
-
hasPermission
Checks if the command sender has the specified permission.- Specified by:
hasPermission
in interfaceorg.bukkit.permissions.Permissible
- Specified by:
hasPermission
in classBaseCommandSender
- 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 interfaceorg.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 interfaceorg.bukkit.permissions.Permissible
- Parameters:
plugin
- the plugin that owns the attachments
- the permission stringb
- 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 interfaceorg.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 interfaceorg.bukkit.permissions.Permissible
- Parameters:
plugin
- the plugin that owns this attachments
- the permission stringb
- the value of the permissioni
- 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 interfaceorg.bukkit.permissions.Permissible
- Parameters:
plugin
- The plugin that owns the attachmentpriority
- 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 interfaceorg.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 interfaceorg.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 interfaceorg.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 interfaceorg.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 interfaceorg.bukkit.permissions.ServerOperator
- Parameters:
b
- the op status to set
-