Class CommandSenderAdapter
java.lang.Object
me.remigio07.chatplugin.api.server.util.adapter.user.CommandSenderAdapter
Environment indipendent (Bukkit and Sponge) command sender adapter.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCommandSenderAdapter
(Object commandSender) Constructs a command sender adapter that accepts one of the following specified as input:CommandSender
for Bukkit environmentsCommandSource
for Sponge environments -
Method Summary
Modifier and TypeMethodDescriptionorg.bukkit.command.CommandSender
Gets the command sender adapted for Bukkit environments.boolean
Checks if another object is an instance ofCommandSenderAdapter
and if the sender specified by the constructor is equal to the other object's one.getName()
Gets this command sender's name.getUUID()
Gets this command sender's UUID.int
hashCode()
Gets this sender's hash code.boolean
hasPermission
(String permission) Checks if this command sender has the specified permission.boolean
Checks if this command sender is the console or a command block.boolean
isLoaded()
Checks if this command sender is a player and loaded.boolean
isPlayer()
Checks if this command sender is a player.void
sendMessage
(String message) Sends a plain message to this command sender.org.spongepowered.api.command.CommandSource
Gets the command sender adapted for Sponge environments.Gets this player's correspondingChatPluginServerPlayer
object.
-
Field Details
-
CONSOLE
Represents the console.
-
-
Constructor Details
-
CommandSenderAdapter
Constructs a command sender adapter that accepts one of the following specified as input:CommandSender
for Bukkit environmentsCommandSource
for Sponge environments
- Parameters:
commandSender
- Command sender object
-
-
Method Details
-
bukkitValue
public org.bukkit.command.CommandSender bukkitValue()Gets the command sender adapted for Bukkit environments.- Returns:
- Bukkit-adapted command sender
- Throws:
UnsupportedOperationException
- If!
Environment.isBukkit()
-
spongeValue
public org.spongepowered.api.command.CommandSource spongeValue()Gets the command sender adapted for Sponge environments.- Returns:
- Sponge-adapted command sender
- Throws:
UnsupportedOperationException
- If!
Environment.isSponge()
-
isConsole
public boolean isConsole()Checks if this command sender is the console or a command block.- Returns:
- Whether this is the console
-
isPlayer
public boolean isPlayer()Checks if this command sender is a player.- Returns:
!
isConsole()
-
isLoaded
public boolean isLoaded()Checks if this command sender is a player and loaded.- Returns:
toServerPlayer()
!= null
-
getName
Gets this command sender's name.- Returns:
- Command sender's name
-
getUUID
Gets this command sender's UUID.Will return
null
ifisConsole()
.- Returns:
- Command sender's UUID
-
hasPermission
Checks if this command sender has the specified permission.- Parameters:
permission
- Permission to check- Returns:
- Whether this command sender has the permission
-
sendMessage
Sends a plain message to this command sender.- Parameters:
message
- Message to send
-
toServerPlayer
Gets this player's correspondingChatPluginServerPlayer
object.Will return
null
if the player is not loaded.- Returns:
- Corresponding
ChatPluginServerPlayer
-
equals
Checks if another object is an instance ofCommandSenderAdapter
and if the sender specified by the constructor is equal to the other object's one. -
hashCode
public int hashCode()Gets this sender's hash code.Will return the hash code of the sender specified by the constructor.
-