Пример #1
0
 @Override
 public void onSubcommand(
     @NotNull final ChannelMessageEvent event,
     @NotNull final CallInfo ci,
     @NotNull final List<String> args) {
   final User u = event.getActor();
   final Optional<String> account = u.getAccount();
   if (!account.isPresent()) {
     u.sendNotice("You must be registered with services to use this command.");
     return;
   }
   final PingRegistry pr = this.humanity.getPingRegistry();
   if (!pr.hasRegistration(account.get())) {
     u.sendNotice("You don't have a registration.");
     return;
   }
   final boolean success = pr.removeRegistration(account.get());
   u.sendNotice(
       "Registration "
           + (success ? "" : "could not be ")
           + "removed for services account "
           + account.get()
           + ".");
 }
Пример #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()));
 }