Interface CommandSender

All Superinterfaces:
Permissible, ServerOperator
All Known Subinterfaces:
ICommandBlock
All Known Implementing Classes:
BlockEntityCommandBlock, CapturingCommandSender, ConsoleCommandSender, ExecutorCommandSender, NPCCommandSender, Player, RemoteConsoleCommandSender

public interface CommandSender extends Permissible
能发送命令的对象。
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 Details

    • sendMessage

      void sendMessage(String message)
      给命令发送者返回信息。
      Sends a message to the command sender.
      Parameters:
      message - 要发送的信息。
      Message to send.
      Since:
      Nukkit 1.0 | Nukkit API 1.0.0
      See Also:
    • sendMessage

      void sendMessage(TextContainer message)
      给命令发送者返回信息。
      Sends a message to the command sender.
      Parameters:
      message - 要发送的信息。
      Message to send.
      Since:
      Nukkit 1.0 | Nukkit API 1.0.0
    • getServer

      Server getServer()
      返回命令发送者所在的服务器。
      Returns the server of the command sender.
      Returns:
      命令发送者所在的服务器。
      the server of the command sender.
      Since:
      Nukkit 1.0 | Nukkit API 1.0.0
    • getName

      @Nonnull String 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

      @PowerNukkitXOnly @Since("1.6.0.0-PNX") default boolean 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

      @PowerNukkitXOnly @Since("1.6.0.0-PNX") @Nullable default Entity asEntity()
    • asPlayer

      @PowerNukkitXOnly @Since("1.6.0.0-PNX") @Nullable default Player asPlayer()
    • getPosition

      @PowerNukkitXOnly @Since("1.6.0.0-PNX") @Nonnull default Position getPosition()
    • getLocation

      @PowerNukkitXOnly @Since("1.6.0.0-PNX") @Nonnull default Location getLocation()