public interface CommandSender extends Permissible
可以是一个玩家或者一个控制台。
That can be a player or a console.
CommandExecutor.onCommand(org.cloudburstmc.server.command.CommandSender, org.cloudburstmc.server.command.Command, java.lang.String, java.lang.String[])| Modifier and Type | Method and Description |
|---|---|
String |
getName()
返回命令发送者的名称。
Returns the name of the command sender. |
Server |
getServer()
返回命令发送者所在的服务器。
Returns the server of the command sender. |
boolean |
isPlayer() |
void |
sendMessage(String message)
给命令发送者返回信息。
Sends a message to the command sender. |
void |
sendMessage(TextContainer message)
给命令发送者返回信息。
Sends a message to the command sender. |
addAttachment, addAttachment, addAttachment, getEffectivePermissions, hasPermission, hasPermission, isPermissionSet, isPermissionSet, recalculatePermissions, removeAttachmentisOp, setOpvoid sendMessage(String message)
message - 要发送的信息。TextFormatvoid sendMessage(TextContainer message)
message - 要发送的信息。Server getServer()
String getName()
如果命令发送者是一个玩家,将会返回他的玩家名字(name)不是显示名字(display name)。
如果命令发送者是控制台,将会返回"CONSOLE"。
If this command sender is a player, will return his/her player name(not display name).
If it is a console, will return "CONSOLE".
当你需要判断命令的执行者是不是控制台时,可以用这个:
When you need to determine if the sender is a console, use this:
if(sender instanceof ConsoleCommandSender) .....;
Player.getName(),
ConsoleCommandSender.getName(),
PluginDescriptionboolean isPlayer()
Copyright © 2020. All rights reserved.