Class ExecutorCommandSender
- All Implemented Interfaces:
CommandSender
,Permissible
,ServerOperator
-
Constructor Summary
ConstructorDescriptionExecutorCommandSender
(CommandSender executor, Entity entity, Location executeLocation) -
Method Summary
Modifier and TypeMethodDescriptionaddAttachment
(Plugin plugin) addAttachment
(Plugin plugin, String name) addAttachment
(Plugin plugin, String name, Boolean value) asEntity()
如果发送者是一个实体,返回执行该命令的实体.asPlayer()
如果发送者是一个玩家,返回执行该命令的玩家.getName()
返回命令发送者的名称.
如果命令发送者是一个玩家,将会返回他的玩家名字(name)不是显示名字(display name).
如果命令发送者是控制台,将会返回"CONSOLE"
.
当你需要判断命令的执行者是不是控制台时,可以用这个:
if(sender instanceof ConsoleCommandSender) .....;
返回命令发送者所在的服务器.boolean
hasPermission
(Permission permission) boolean
hasPermission
(String name) boolean
isEntity()
请使用这个方法来检查发送者是否是一个实体,而不是使用代码"xxx instanceof Entity"
.
因为发送者可能不是"Entity"
的一个实例,但实际上它是以一个实体的身份执行命令(例如:"ExecutorCommandSender"
)boolean
isOp()
返回这个对象是不是服务器管理员。
Returns if this object is an operator.boolean
isPermissionSet
(Permission permission) boolean
isPermissionSet
(String name) boolean
isPlayer()
void
void
removeAttachment
(PermissionAttachment attachment) void
sendCommandOutput
(CommandOutputContainer container) Send command output.void
sendMessage
(TextContainer message) 给命令发送者返回信息.void
sendMessage
(String message) 给命令发送者返回信息.void
setOp
(boolean value) 把这个对象设置成服务器管理员。
Sets this object to be an operator or not to be.
-
Constructor Details
-
ExecutorCommandSender
public ExecutorCommandSender(@NotNull CommandSender executor, @Nullable Entity entity, @Nullable Location executeLocation)
-
-
Method Details
-
sendMessage
Description copied from interface:CommandSender
给命令发送者返回信息.Sends a message to the command sender.
- Specified by:
sendMessage
in interfaceCommandSender
- Parameters:
message
- 要发送的信息.
Message to send.- See Also:
-
sendMessage
Description copied from interface:CommandSender
给命令发送者返回信息.Sends a message to the command sender.
- Specified by:
sendMessage
in interfaceCommandSender
- Parameters:
message
- 要发送的信息.
Message to send.
-
sendCommandOutput
@PowerNukkitXOnly @Since("1.19.60-r1") public void sendCommandOutput(CommandOutputContainer container) Description copied from interface:CommandSender
Send command output.- Specified by:
sendCommandOutput
in interfaceCommandSender
- Parameters:
container
- the container
-
getServer
Description copied from interface:CommandSender
返回命令发送者所在的服务器.Returns the server of the command sender.
- Specified by:
getServer
in interfaceCommandSender
- Returns:
- 命令发送者所在的服务器.
the server of the command sender.
-
getName
Description copied from interface:CommandSender
返回命令发送者的名称.
如果命令发送者是一个玩家,将会返回他的玩家名字(name)不是显示名字(display name).
如果命令发送者是控制台,将会返回"CONSOLE"
.
当你需要判断命令的执行者是不是控制台时,可以用这个:
if(sender instanceof ConsoleCommandSender) .....;
Returns the name of the command sender.
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) .....;
- Specified by:
getName
in interfaceCommandSender
- Returns:
- 命令发送者的名称.
the name of the command sender. - See Also:
-
isPlayer
public boolean isPlayer()- Specified by:
isPlayer
in interfaceCommandSender
- Returns:
- 发送者是否为玩家
whether the sender is an player
-
isEntity
public boolean isEntity()Description copied from interface:CommandSender
请使用这个方法来检查发送者是否是一个实体,而不是使用代码"xxx instanceof Entity"
.
因为发送者可能不是"Entity"
的一个实例,但实际上它是以一个实体的身份执行命令(例如:"ExecutorCommandSender"
)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"
)- Specified by:
isEntity
in interfaceCommandSender
- Returns:
- 发送者是否为实体
whether the sender is an entity
-
asEntity
Description copied from interface:CommandSender
如果发送者是一个实体,返回执行该命令的实体.return the entity who execute the command if the sender is a entity.
- Specified by:
asEntity
in interfaceCommandSender
- Returns:
- 实体对象
Entity instance
-
asPlayer
Description copied from interface:CommandSender
如果发送者是一个玩家,返回执行该命令的玩家.return the player who execute the command if the sender is a player.
- Specified by:
asPlayer
in interfaceCommandSender
- Returns:
- 玩家对象
Player instance
-
getPosition
- Specified by:
getPosition
in interfaceCommandSender
- Returns:
- 返回发送者的Position
return the sender's position.
-
getLocation
- Specified by:
getLocation
in interfaceCommandSender
- Returns:
- 返回发送者克隆过的Location
return the sender's location.
-
isOp
public boolean isOp()Description copied from interface:ServerOperator
返回这个对象是不是服务器管理员。
Returns if this object is an operator.- Specified by:
isOp
in interfaceServerOperator
- Returns:
- 这个对象是不是服务器管理员。
if this object is an operator.
-
setOp
public void setOp(boolean value) Description copied from interface:ServerOperator
把这个对象设置成服务器管理员。
Sets this object to be an operator or not to be.- Specified by:
setOp
in interfaceServerOperator
- Parameters:
value
-true
为授予管理员,false
为取消管理员。
true
for giving this operator orfalse
for cancelling.
-
isPermissionSet
- Specified by:
isPermissionSet
in interfacePermissible
-
isPermissionSet
- Specified by:
isPermissionSet
in interfacePermissible
-
hasPermission
- Specified by:
hasPermission
in interfacePermissible
-
hasPermission
- Specified by:
hasPermission
in interfacePermissible
-
addAttachment
- Specified by:
addAttachment
in interfacePermissible
-
addAttachment
- Specified by:
addAttachment
in interfacePermissible
-
addAttachment
- Specified by:
addAttachment
in interfacePermissible
-
removeAttachment
- Specified by:
removeAttachment
in interfacePermissible
-
recalculatePermissions
public void recalculatePermissions()- Specified by:
recalculatePermissions
in interfacePermissible
-
getEffectivePermissions
- Specified by:
getEffectivePermissions
in interfacePermissible
-
getExecutor
-