Class CommandSenderAdapter
java.lang.Object
me.remigio07.chatplugin.api.server.util.adapter.user.CommandSenderAdapter
Environment indipendent (Bukkit and Sponge) command sender adapter.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCommandSenderAdapter(Object commandSender) Constructs a command sender adapter that accepts one of the following specified as input:CommandSenderfor Bukkit environmentsCommandSourcefor Sponge environments -
Method Summary
Modifier and TypeMethodDescriptionorg.bukkit.command.CommandSenderGets the command sender adapted for Bukkit environments.booleanChecks if another object is an instance ofCommandSenderAdapterand 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.inthashCode()Gets this sender's hash code.booleanhasPermission(String permission) Checks if this command sender has the specified permission.booleanChecks if this command sender is the console or a command block.booleanisLoaded()Checks if this command sender is a player and loaded.booleanisPlayer()Checks if this command sender is a player.voidsendMessage(String message) Sends a plain message to this command sender.org.spongepowered.api.command.CommandSourceGets the command sender adapted for Sponge environments.Gets this player's correspondingChatPluginServerPlayerobject.
-
Field Details
-
CONSOLE
Represents the console.
-
-
Constructor Details
-
CommandSenderAdapter
Constructs a command sender adapter that accepts one of the following specified as input:CommandSenderfor Bukkit environmentsCommandSourcefor 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
nullifisConsole().- 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 correspondingChatPluginServerPlayerobject.Will return
nullif the player is not loaded.- Returns:
- Corresponding
ChatPluginServerPlayer
-
equals
Checks if another object is an instance ofCommandSenderAdapterand 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.
-