Пример #1
0
 @NotNull
 protected String getHelpString() {
   final StringBuilder sb = new StringBuilder("Subcommands: ");
   for (final BaseCommand subcommand : this.subcommands) {
     sb.append("(").append(subcommand.getName());
     for (final String alias : subcommand.getAliases()) {
       sb.append(", ").append(alias);
     }
     sb.append("), ");
   }
   return sb.substring(0, sb.length() - 2);
 }
Пример #2
0
 @Override
 public void run(
     @NotNull ActorEvent<User> event,
     @NotNull CallInfo callInfo,
     @NotNull List<? extends String> arguments) {
   if (!this.beforeCommand(event, callInfo, arguments)) {
     return;
   }
   final User u = event.getActor();
   if (arguments.size() < 1) {
     u.sendNotice("Provide a subcommand.");
     u.sendNotice(this.getHelpString());
     return;
   }
   final BaseCommand subcommand = this.getSubcommand(arguments.get(0));
   if (subcommand == null) {
     u.sendNotice("No such subcommand.");
     return;
   }
   if (!this.beforeSubcommand(subcommand, event, callInfo, arguments)) {
     return;
   }
   subcommand.run(event, callInfo, arguments.subList(1, arguments.size()));
 }