Package cn.nukkit.command
Interface CommandSender
- All Superinterfaces:
Permissible
,ServerOperator
- All Known Subinterfaces:
ICommandBlock
- All Known Implementing Classes:
BlockEntityCommandBlock
,CapturingCommandSender
,ConsoleCommandSender
,ExecutorCommandSender
,NPCCommandSender
,Player
,RemoteConsoleCommandSender
能发送命令的对象。
Who sends commands.
Who sends commands.
可以是一个玩家或者一个控制台或者一个实体或者其他。
That can be a player or a console.
- Since:
- Nukkit 1.0 | Nukkit API 1.0.0
- Author:
- MagicDroidX(code) @ Nukkit Project, 粉鞋大妈(javadoc) @ Nukkit Project, smartcmd(code) @ PowerNukkitX Project
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault Entity
asEntity()
default Player
asPlayer()
default Location
getName()
返回命令发送者的名称。
Returns the name of the command sender.default Position
EntitySelector 返回命令发送者所在的服务器。
Returns the server of the command sender.default boolean
isEntity()
boolean
isPlayer()
void
sendMessage
(TextContainer message) 给命令发送者返回信息。
Sends a message to the command sender.void
sendMessage
(String message) 给命令发送者返回信息。
Sends a message to the command sender.Methods inherited from interface cn.nukkit.permission.Permissible
addAttachment, addAttachment, addAttachment, getEffectivePermissions, hasPermission, hasPermission, isPermissionSet, isPermissionSet, recalculatePermissions, removeAttachment
Methods inherited from interface cn.nukkit.permission.ServerOperator
isOp, setOp
-
Method Details
-
sendMessage
给命令发送者返回信息。
Sends a message to the command sender.- Parameters:
message
- 要发送的信息。
Message to send.- Since:
- Nukkit 1.0 | Nukkit API 1.0.0
- See Also:
-
sendMessage
给命令发送者返回信息。
Sends a message to the command sender.- Parameters:
message
- 要发送的信息。
Message to send.- Since:
- Nukkit 1.0 | Nukkit API 1.0.0
-
getServer
Server getServer()EntitySelector 返回命令发送者所在的服务器。
Returns the server of the command sender.- Returns:
- 命令发送者所在的服务器。
the server of the command sender. - Since:
- Nukkit 1.0 | Nukkit API 1.0.0
-
getName
返回命令发送者的名称。
Returns the name of the command sender.如果命令发送者是一个玩家,将会返回他的玩家名字(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) .....;
- Returns:
- 命令发送者的名称。
the name of the command sender. - Since:
- Nukkit 1.0 | Nukkit API 1.0.0
- See Also:
-
isPlayer
boolean isPlayer() -
isEntity
- Returns:
- whether the sender is an entity
please use this method to check whether the sender is an entity instead of using code"xxx instanceof Entity"
because the sender may not an instance of"Entity"
but in fact it is executing commands identity as an entity(eg:"ExecutorCommandSender"
)
-
asEntity
-
asPlayer
-
getPosition
-
getLocation
-