Class SimpleCommandMap

java.lang.Object
cn.nukkit.command.SimpleCommandMap
All Implemented Interfaces:
CommandMap

public class SimpleCommandMap extends Object implements CommandMap
Author:
MagicDroidX (Nukkit Project)
  • Field Details

  • Constructor Details

    • SimpleCommandMap

      public SimpleCommandMap(Server server)
  • Method Details

    • registerAll

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

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

      public boolean register(String fallbackPrefix, Command command, String label)
      Description copied from interface: CommandMap
      注册命令
      Specified by:
      register in interface CommandMap
      Parameters:
      fallbackPrefix - 命令标签前缀,当命令label重复时用于区分
      command - the command
      label - the label
      Returns:
      the boolean
    • registerSimpleCommands

      public void registerSimpleCommands(Object object)
      Description copied from interface: CommandMap
      注册一个基于注解开发的命令
      Specified by:
      registerSimpleCommands in interface CommandMap
      Parameters:
      object - the object
    • parseArguments

      public static ArrayList<String> parseArguments(String cmdLine)
      解析给定文本,从中分割参数
      Parameters:
      cmdLine - the cmd line
      Returns:
      参数数组
    • executeCommand

      public int executeCommand(CommandSender sender, String cmdLine)
      Description copied from interface: CommandMap
      执行命令
      Specified by:
      executeCommand in interface CommandMap
      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

      public void clearCommands()
      Description copied from interface: CommandMap
      清理全部的插件命令
      Specified by:
      clearCommands in interface CommandMap
    • getCommand

      public Command getCommand(String name)
      Description copied from interface: CommandMap
      从给定命令名称或者别名获取命令对象
      Specified by:
      getCommand in interface CommandMap
      Parameters:
      name - the name
      Returns:
      the command
    • getCommands

      public Map<String,Command> getCommands()
      获取knownCommands的未克隆实例
      Returns:
      the commands
    • registerServerAliases

      public void registerServerAliases()
      注册插件在plugin.yml中定义的命令别名