Class NPCCommandSender

java.lang.Object
cn.nukkit.command.NPCCommandSender
All Implemented Interfaces:
CommandSender, Permissible, ServerOperator

@PowerNukkitXOnly @Since("1.6.0.0-PNX") public class NPCCommandSender extends Object implements CommandSender
  • Field Details

  • Constructor Details

  • Method Details

    • getInitiator

      public Player getInitiator()
    • getNpc

      public EntityNPCEntity getNpc()
    • sendMessage

      public void sendMessage(String message)
      Description copied from interface: CommandSender
      给命令发送者返回信息.

      Sends a message to the command sender.

      Specified by:
      sendMessage in interface CommandSender
      Parameters:
      message - 要发送的信息.
      Message to send.
      See Also:
    • sendMessage

      public void sendMessage(TextContainer message)
      Description copied from interface: CommandSender
      给命令发送者返回信息.

      Sends a message to the command sender.

      Specified by:
      sendMessage in interface CommandSender
      Parameters:
      message - 要发送的信息.
      Message to send.
    • sendCommandOutput

      @Since("1.19.60-r1") public void sendCommandOutput(CommandOutputContainer container)
      Description copied from interface: CommandSender
      Send command output.
      Specified by:
      sendCommandOutput in interface CommandSender
      Parameters:
      container - the container
    • getServer

      public Server getServer()
      Description copied from interface: CommandSender
      返回命令发送者所在的服务器.

      Returns the server of the command sender.

      Specified by:
      getServer in interface CommandSender
      Returns:
      命令发送者所在的服务器.
      the server of the command sender.
    • getName

      @NotNull public String 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 interface CommandSender
      Returns:
      命令发送者的名称.
      the name of the command sender.
      See Also:
    • isPlayer

      public boolean isPlayer()
      Specified by:
      isPlayer in interface CommandSender
      Returns:
      发送者是否为玩家
      whether the sender is an player
    • isEntity

      @Since("1.6.0.0-PNX") @PowerNukkitOnly 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 interface CommandSender
      Returns:
      发送者是否为实体
      whether the sender is an entity
    • asEntity

      @Since("1.6.0.0-PNX") @PowerNukkitOnly @Nullable public Entity asEntity()
      Description copied from interface: CommandSender
      如果发送者是一个实体,返回执行该命令的实体.

      return the entity who execute the command if the sender is a entity.

      Specified by:
      asEntity in interface CommandSender
      Returns:
      实体对象
      Entity instance
    • asPlayer

      @Since("1.6.0.0-PNX") @PowerNukkitOnly @Nullable public Player asPlayer()
      Description copied from interface: CommandSender
      如果发送者是一个玩家,返回执行该命令的玩家.

      return the player who execute the command if the sender is a player.

      Specified by:
      asPlayer in interface CommandSender
      Returns:
      玩家对象
      Player instance
    • getPosition

      @Since("1.6.0.0-PNX") @PowerNukkitOnly @NotNull public Position getPosition()
      Specified by:
      getPosition in interface CommandSender
      Returns:
      返回发送者的Position
      return the sender's position.
    • getLocation

      @Since("1.6.0.0-PNX") @PowerNukkitOnly @NotNull public Location getLocation()
      Specified by:
      getLocation in interface CommandSender
      Returns:
      返回发送者克隆过的Location
      return the sender's location.
    • isPermissionSet

      public boolean isPermissionSet(String name)
      Specified by:
      isPermissionSet in interface Permissible
    • isPermissionSet

      public boolean isPermissionSet(Permission permission)
      Specified by:
      isPermissionSet in interface Permissible
    • hasPermission

      public boolean hasPermission(String name)
      Specified by:
      hasPermission in interface Permissible
    • hasPermission

      public boolean hasPermission(Permission permission)
      Specified by:
      hasPermission in interface Permissible
    • addAttachment

      public PermissionAttachment addAttachment(Plugin plugin)
      Specified by:
      addAttachment in interface Permissible
    • addAttachment

      public PermissionAttachment addAttachment(Plugin plugin, String name)
      Specified by:
      addAttachment in interface Permissible
    • addAttachment

      public PermissionAttachment addAttachment(Plugin plugin, String name, Boolean value)
      Specified by:
      addAttachment in interface Permissible
    • removeAttachment

      public void removeAttachment(PermissionAttachment attachment)
      Specified by:
      removeAttachment in interface Permissible
    • recalculatePermissions

      public void recalculatePermissions()
      Specified by:
      recalculatePermissions in interface Permissible
    • getEffectivePermissions

      public Map<String,PermissionAttachmentInfo> getEffectivePermissions()
      Specified by:
      getEffectivePermissions in interface Permissible
    • isOp

      public boolean isOp()
      Description copied from interface: ServerOperator
      返回这个对象是不是服务器管理员。
      Returns if this object is an operator.
      Specified by:
      isOp in interface ServerOperator
      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 interface ServerOperator
      Parameters:
      value - true为授予管理员,false为取消管理员。
      true for giving this operator or false for cancelling.