Interface CommandSenderWrapper
- All Known Implementing Classes:
CommandSenderWrapper.BukkitWrapper
,CommandSenderWrapper.RemoteConsoleWrapper
,CommandSenderWrapper.RemotePlayerWrapper
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.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
static class
static class
-
Method Summary
Modifier and TypeMethodDescription@Nullable Player
Returns thePlayer
that is being wrapped.Returns theCommandSender
that is being wrapped.getName()
Remotes the name of the sender.Returns the object that's being referenced.@Nullable RemotePlayer
Returns theRemotePlayer
that is being wrapped.@Nullable UUID
Remotes the uuid of the sender.boolean
hasPermission
(String name) Returns whether the sender has a given permission.boolean
hasPermission
(Permission perm) Returns whether the sender has a given permission.boolean
Returns whether an online player executed this.boolean
Returns whether it was the console that executed the command.boolean
isLocal()
Returns whether this object is wrapping a sender this is located on this server.boolean
isPlayer()
Returns whether it was a player who executed the command.boolean
isRemote()
Returns whether this object is wrapping a sender this is located on another server.boolean
Returns whether it's a player on a remote server.void
sendMessage
(String message) Sends a message to the sender.void
sendMessage
(String... messages) Sends multiple messages to the sender.void
sendMessage
(net.md_5.bungee.api.chat.BaseComponent... components) Sends a single message that persists of the following components.static CommandSenderWrapper
wrap
(RemotePlayer player) Constructs a new instance with a reference of the given player.static CommandSenderWrapper
wrap
(CommandSender sender) Constructs a new instance with a reference of the given sender.static CommandSenderWrapper
wrap
(CommandSender sender, boolean hasOP) Constructs a new instance with a reference of the given sender.static CommandSenderWrapper
wrapConsole
(RemoteServer server) Wraps the console of the given server.
-
Method Details
-
getName
String getName()Remotes the name of the sender.For Bukkit Players:
CommandSender.getName()
For Remote Players:RemotePlayer.getName()
For Console: Console- Returns:
- The name of the sender
-
getUniqueId
Remotes the uuid of the sender. May benull
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 usegetBukkitPlayer()
.- Returns:
- Returns
true
when an actualPlayer
is being referenced.
-
isRemotePlayer
boolean isRemotePlayer()Returns whether it's a player on a remote server.If this method returns
true
, you may usegetRemotePlayer()
.- Returns:
- Returns
true
when an actualRemotePlayer
is being referenced.
-
isConsole
boolean isConsole()Returns whether it was the console that executed the command.- Returns:
- Returns
true
when a console is the sender (either remotely and local)
-
isPlayer
boolean isPlayer()Returns whether it was a player who executed the command.- Returns:
- Returns
true
when a player is the sender (either remotely and local)
-
isLocal
boolean isLocal()Returns whether this object is wrapping a sender this is located on this server.- Returns:
- Returns
true
when the sender is located on this server
-
isRemote
boolean isRemote()Returns whether this object is wrapping a sender this is located on another server.- Returns:
- Returns
true
when the sender is located on another server
-
getReference
Object getReference()Returns the object that's being referenced. This may be aCommandSender
or aRemotePlayer
.- Returns:
- The instance that's being wrapped
-
getCommandSender
CommandSender getCommandSender()Returns theCommandSender
that is being wrapped.Returns
null
when it is not being wrapped.- Returns:
- The
CommandSender
that is being wrapped. May benull
-
getBukkitPlayer
Returns thePlayer
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 benull
-
getRemotePlayer
Returns theRemotePlayer
that is being wrapped.Returns
null
when the player is not on a remote server.- Returns:
- The
RemotePlayer
that is being wrapped. May benull
-
sendMessage
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
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
-
sendMessage
void sendMessage(net.md_5.bungee.api.chat.BaseComponent... components) Sends a single message that persists of the following components.For Bukkit Players:
Player.Spigot.sendMessage(BaseComponent...)
()}
For Bukkit Misc (only text):CommandSender.sendMessage(String)
()}
For Remote Players:RemotePlayer.sendMessage(BaseComponent...)
()}- Parameters:
components
- The components the chat message persists of
-
hasPermission
Returns whether the sender has a given permission.For Bukkit Players:
Permissible.hasPermission(String)
()} (Or whenhasOP
is true: Always true)
For Remote Players: Always true- Parameters:
name
- The permission that shall be checked
-
hasPermission
Returns whether the sender has a given permission.For Bukkit Players:
Permissible.hasPermission(Permission)
()} (Or whenhasOP
is true: Always true)
For Remote Players: Always true- Parameters:
perm
- The permission that shall be checked
-
wrap
Constructs a new instance with a reference of the given sender.- Parameters:
sender
- The sender that shall be wrapped- Returns:
- The wrapped sender
-
wrap
Constructs a new instance with a reference of the given sender.- Parameters:
sender
- The sender that shall be wrappedhasOP
-true
:hasPermission(String)
always return true;false
: usesPermissible.hasPermission(String)
- Returns:
- The wrapped sender
-
wrap
Constructs a new instance with a reference of the given player.- Parameters:
player
- The player that shall be wrapped- Returns:
- The wrapped player
-
wrapConsole
Wraps the console of the given server.- Parameters:
server
- The server of which the console shall be wrapped- Returns:
- The wrapped console
-