Interface CommandMap

All Known Implementing Classes:
SimpleCommandMap

public interface CommandMap
Author:
MagicDroidX (Nukkit Project)
  • Method Details

    • registerAll

      void registerAll(String fallbackPrefix, List<? extends Command> commands)
      注册全部命令
      Parameters:
      fallbackPrefix - 命令标签前缀,当命令label重复时用于区分
      commands - the commands
    • register

      boolean register(String fallbackPrefix, Command command)
      注册命令
      Parameters:
      fallbackPrefix - 命令标签前缀,当命令label重复时用于区分
      command - the command
      Returns:
      当命令label重复时返回false, 此时你无法使用label来获取和执行命令,不过你仍然可以使用fallbackPrefix:label来获取命令
    • register

      boolean register(String fallbackPrefix, Command command, String label)
      注册命令
      Parameters:
      fallbackPrefix - 命令标签前缀,当命令label重复时用于区分
      command - the command
      label - the label
      Returns:
      the boolean
    • registerSimpleCommands

      void registerSimpleCommands(Object object)
      注册一个基于注解开发的命令
      Parameters:
      object - the object
    • dispatch

      @Deprecated @DeprecationDetails(since="1.19.60-r1", reason="use CommandMap#executeCommand") default boolean dispatch(CommandSender sender, String cmdLine)
      Deprecated.
      执行命令
      Parameters:
      sender - the sender
      cmdLine - the cmd line
      Returns:
      the int
    • executeCommand

      @PowerNukkitXOnly @Since("1.19.60-r1") int executeCommand(CommandSender sender, String cmdLine)
      执行命令
      Parameters:
      sender - the sender
      cmdLine - the cmd line
      Returns:
      the int 返回0代表执行失败, 返回大于等于1代表执行成功
      Returns 0 for failed execution, greater than or equal to 1 for successful execution
    • clearCommands

      void clearCommands()
      清理全部的插件命令
    • getCommand

      Command getCommand(String name)
      从给定命令名称或者别名获取命令对象
      Parameters:
      name - the name
      Returns:
      the command