Record Class CommandLogger

java.lang.Object
java.lang.Record
cn.nukkit.command.utils.CommandLogger

@PowerNukkitXOnly @Since("1.19.60-r1") public record CommandLogger(Command command, CommandSender sender, String commandLabel, String[] args, CommandOutputContainer outputContainer, Plugin plugin) extends Record
  • Constructor Details

    • CommandLogger

      public CommandLogger(Command command, CommandSender sender, String commandLabel, String[] args)
    • CommandLogger

      public CommandLogger(Command command, CommandSender sender, String commandLabel, String[] args, CommandOutputContainer outputContainer)
    • CommandLogger

      public CommandLogger(Command command, CommandSender sender, String commandLabel, String[] args, Plugin plugin)
    • CommandLogger

      public CommandLogger(Command command, CommandSender sender, String commandLabel, String[] args, CommandOutputContainer outputContainer, Plugin plugin)
      Creates an instance of a CommandLogger record class.
      Parameters:
      command - the value for the command record component
      sender - the value for the sender record component
      commandLabel - the value for the commandLabel record component
      args - the value for the args record component
      outputContainer - the value for the outputContainer record component
      plugin - the value for the plugin record component
  • Method Details

    • addSuccess

      public CommandLogger addSuccess(String message)
    • addSuccess

      public CommandLogger addSuccess(String key, List<String> params)
    • addSuccess

      public CommandLogger addSuccess(String key, String... params)
      添加一条命令成功执行的消息,参数可以是纯文本,也可以是客戶端的多语言文本key.
      默认输出颜色白色

      Add a message that the command was successfully executed, the parameters can be plain text or the client's multilingual text key.
      Default output color white

      Parameters:
      key - the key
      params - the params
    • addError

      public CommandLogger addError(String message)
      添加一条命令错误执行的消息,参数可以是纯文本,也可以是客戶端的多语言文本key.
      默认输出颜色红色

      Add a command error message, either plain text or the client's multilingual text key.
      Default output color red

      Parameters:
      message - the message
      Returns:
      the command logger
    • addError

      public CommandLogger addError(String key, String... params)
      添加一条命令执行失败的错误消息,参数可以是纯文本,也可以是客戶端的多语言文本key.
      默认输出颜色红色

      Add a command execution failure error message, either plain text or the client's multilingual text key.
      Default output color red

      Parameters:
      key - 语言文本key/错误信息
      params - 语言文本参数/空
      Returns:
      the command logger
    • addMessage

      public CommandLogger addMessage(String key)
      添加一条消息,参数可以是纯文本,也可以是客户端,服务端,以及PluginI18n中的多语言文本,默认输出颜色红色

      Add a message, the parameters can be plain text, or client-side, server-side, and multilingual text in PluginI18n, default output color red

      Parameters:
      key - the key
      Returns:
      the command logger
    • addMessage

      public CommandLogger addMessage(String key, String... params)
      添加一条消息,参数可以是纯文本,也可以是客户端,服务端,以及PluginI18n中的多语言文本,默认输出颜色红色

      Add a message, the parameters can be plain text, or client-side, server-side, and multilingual text in PluginI18n, default output color red

      Parameters:
      key - the key
      params - the params
      Returns:
      the command logger
    • addSyntaxErrors

      public CommandLogger addSyntaxErrors(int errorIndex)
      添加一条默认的命令格式错误信息,会提示命令发送者在指定索引处发生错误

      Add a default command format error message that will alert the command sender of an error at the specified index

      Parameters:
      errorIndex - 发生错误的参数索引
    • addNoTargetMatch

      public CommandLogger addNoTargetMatch()
      添加一条目标选择器没有匹配目标的错误信息

      Add an error message that the target selector matches too many targets

    • addTooManyTargets

      public CommandLogger addTooManyTargets()
      添加一条目标选择器匹配目标过多的错误信息
    • addNumTooSmall

      public CommandLogger addNumTooSmall(int errorIndex, int minimum)
      添加一条参数过小的错误信息,会提示命令发送者指定位置的参数最小值不能低于minimum

      Add an error message that the parameter is too small, prompting the command sender to specify a location where the minimum value of the parameter cannot be less than minimum

      Parameters:
      errorIndex - 发生错误的参数索引
      minimum - 允许的最小值
    • addDoubleTooBig

      public CommandLogger addDoubleTooBig(int errorIndex, double maximum)
      添加一条Double参数过大的错误信息,会提示命令发送者指定位置的参数最大值不能超过maximum

      Add a Double parameter too large error message, which will prompt the command sender to specify that the maximum value of the parameter at the location cannot exceed maximum

      Parameters:
      errorIndex - 发生错误的参数索引
      maximum - 允许的最大值
    • addDoubleTooSmall

      public CommandLogger addDoubleTooSmall(int errorIndex, double minimum)
      添加一条Double参数过小的错误信息,会提示命令发送者指定位置的参数最小值不能低于minimum

      Add a Double parameter is too small error message, which will prompt the command sender to specify the minimum value of the parameter at the location cannot be less than minimum

      Parameters:
      errorIndex - 发生错误的参数索引
      minimum - 允许的最小值
    • addOutOfWorld

      public CommandLogger addOutOfWorld()
      添加一条无法访问世界外的方块的错误信息

      Add an error message about not being able to access squares outside the world

      Returns:
      the command logger
    • output

      public void output()
      输出outputContainer中的所有信息.
    • output

      public void output(boolean broadcast)
      输出outputContainer中的所有信息.
      Parameters:
      broadcast - the broadcast
    • successCount

      public CommandLogger successCount(int successCount)
      标记outputContainer的成功数量
      Parameters:
      successCount - the success count
      Returns:
      the command logger
    • outputObjectWhisper

      public void outputObjectWhisper(Player receiver, String key, String... params)
      输出给指定目标一条反馈信息

      Output a feedback message to the specified receiver

      Parameters:
      receiver - 命令目标
      key - the key
      params - 给命令目标的反馈信息参数
    • outputObjectWhisper

      public void outputObjectWhisper(Player receiver, String rawtext, Object... params)
      输出给指定目标一条反馈信息

      Output a feedback message to the specified receiver

      Parameters:
      rawtext - 给命令目标的反馈信息
      receiver - 命令目标
      params - 给命令目标的反馈信息参数
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • command

      public Command command()
      Returns the value of the command record component.
      Returns:
      the value of the command record component
    • sender

      public CommandSender sender()
      Returns the value of the sender record component.
      Returns:
      the value of the sender record component
    • commandLabel

      public String commandLabel()
      Returns the value of the commandLabel record component.
      Returns:
      the value of the commandLabel record component
    • args

      public String[] args()
      Returns the value of the args record component.
      Returns:
      the value of the args record component
    • outputContainer

      public CommandOutputContainer outputContainer()
      Returns the value of the outputContainer record component.
      Returns:
      the value of the outputContainer record component
    • plugin

      public Plugin plugin()
      Returns the value of the plugin record component.
      Returns:
      the value of the plugin record component