コード例 #1
0
 public void registerCommand(SkyblockCommand skyblockCommand) {
   registeredCommands.put(skyblockCommand.getCommandLabel(), skyblockCommand);
   if (skyblockCommand.getAliases() == null || skyblockCommand.getAliases().length == 0) {
     return;
   }
   for (String alias : skyblockCommand.getAliases()) {
     registeredCommands.put(alias, skyblockCommand);
   }
 }
コード例 #2
0
 @Override
 public boolean onCommand(
     CommandSender commandSender, Command cmd, String commandLabel, String[] args) {
   if (!cmd.getName().equalsIgnoreCase("is")) return true;
   if (args.length == 0) {
     // Send information about all the registered commands.
     return true;
   }
   String subCommand = args[0];
   if (!registeredCommands.containsKey(subCommand)) {
     // Send command not found.
     return true;
   }
   SkyblockCommand skyblockCommand = registeredCommands.get(subCommand);
   String[] newArray = Arrays.copyOfRange(args, 1, args.length);
   if (skyblockCommand.isForcePlayer()) {
     if (!(commandSender instanceof Player)) {
       // Send error.
       return true;
     }
   }
   skyblockCommand.getExecutor().execute(commandSender, newArray);
   return true;
 }