Ejemplo n.º 1
0
  @Override
  public boolean onCommand(CommandSender cs, Command command, String label, String[] args) {
    try {
      commandsManager.executeCommand(command, cs, args);
      commandLog(command, cs, args, true);
    } catch (CommandException ex) {
      String report = "&c" + ex.getMessage();

      for (String str : Formatter.selectFormatter(SimpleFormatter.class).format(report, null)) {
        cs.sendMessage(str);
      }

      if (ex instanceof CommandMethodInvocationException
          || ex instanceof MalformattedCommandException) {
        log(ex.getMessage(), 2);
        ex.printStackTrace();
        return true;
      } else if (ex instanceof ArgumentOutOfBoundsException) {
        try {
          commandsManager.sendHelp(cs, command);
        } catch (MalformattedCommandException ex1) {
          String _report = "&c" + ex1.getMessage();

          for (String str :
              Formatter.selectFormatter(SimpleFormatter.class).format(_report, null)) {
            cs.sendMessage(str);
          }

          log(ex.getMessage(), 2);
          ex.printStackTrace();
          return true;
        }
      }

      commandLog(command, cs, args, false);
    } catch (InsufficientPermissionsException ex) {
      String report = "&c" + ex.getMessage();

      for (String str : Formatter.selectFormatter(SimpleFormatter.class).format(report, null)) {
        cs.sendMessage(str);
      }

      commandLog(command, cs, args, false);
    }

    return true;
  }