Interface CommandSenderWrapper
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 Summary
Modifier and TypeMethodDescription@Nullable PlayerReturns thePlayerthat is being wrapped.Returns theCommandSenderthat is being wrapped.getName()Remotes the name of the sender.Returns the object that's being referenced.@Nullable RemotePlayerReturns theRemotePlayerthat is being wrapped.@Nullable UUIDRemotes the uuid of the sender.booleanhasPermission(String name) Returns whether the sender has a given permission.booleanhasPermission(Permission perm) Returns whether the sender has a given permission.booleanReturns whether an online player executed this.booleanReturns whether it was the console that executed the command.booleanisLocal()Returns whether this object is wrapping a sender this is located on this server.booleanisPlayer()Returns whether it was a player who executed the command.booleanisRemote()Returns whether this object is wrapping a sender this is located on another server.booleanReturns whether it's a player on a remote server.voidsendMessage(String message) Sends a message to the sender.voidsendMessage(String... messages) Sends multiple messages to the sender.voidsendMessage(net.md_5.bungee.api.chat.BaseComponent... components) Sends a single message that persists of the following components.static CommandSenderWrapperwrap(RemotePlayer player) Constructs a new instance with a reference of the given player.static CommandSenderWrapperwrap(CommandSender sender) Constructs a new instance with a reference of the given sender.static CommandSenderWrapperwrap(CommandSender sender, boolean hasOP) Constructs a new instance with a reference of the given sender.static CommandSenderWrapperwrapConsole(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 benullif 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
truewhen an actualPlayeris 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
truewhen an actualRemotePlayeris being referenced.
-
isConsole
boolean isConsole()Returns whether it was the console that executed the command.- Returns:
- Returns
truewhen a console is the sender (either remotely and local)
-
isPlayer
boolean isPlayer()Returns whether it was a player who executed the command.- Returns:
- Returns
truewhen 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
truewhen 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
truewhen the sender is located on another server
-
getReference
Object getReference()Returns the object that's being referenced. This may be aCommandSenderor aRemotePlayer.- Returns:
- The instance that's being wrapped
-
getCommandSender
CommandSender getCommandSender()Returns theCommandSenderthat is being wrapped.Returns
nullwhen it is not being wrapped.- Returns:
- The
CommandSenderthat is being wrapped. May benull
-
getBukkitPlayer
Returns thePlayerthat is being wrapped.Returns
nullwhen the player is not on this server or when it's not a player.- Returns:
- The
Playerthat is being wrapped. May benull
-
getRemotePlayer
Returns theRemotePlayerthat is being wrapped.Returns
nullwhen the player is not on a remote server.- Returns:
- The
RemotePlayerthat 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 whenhasOPis 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 whenhasOPis 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
-