Пример #1
0
 @Override
 public void addTabCompletionOptions(List<String> list, ICommandSender sender, String[] args) {
   if (args.length == 0) {
     for (ServerConfig serverConfig : ConfigurationHandler.getServerConfigs()) {
       for (ChannelConfig channelConfig : serverConfig.getChannelConfigs()) {
         list.add(channelConfig.getName());
       }
     }
   }
 }
Пример #2
0
 @Override
 public boolean processCommand(
     ICommandSender sender, IRCContext context, String[] args, boolean serverSide)
     throws CommandException {
   if (args.length < 1) {
     throw new WrongUsageException(getCommandUsage(sender));
   }
   IRCContext target =
       EiraIRCAPI.parseContext(null, args[0], IRCContext.ContextType.IRCConnection);
   IRCConnection connection;
   if (target.getContextType() == IRCContext.ContextType.Error) {
     if (args[0].indexOf('/') != -1) {
       Utils.sendLocalizedMessage(sender, target.getName(), args[0]);
       return true;
     } else {
       if (context == null) {
         Utils.sendLocalizedMessage(sender, "error.specifyServer");
         return true;
       }
       target = context.getConnection();
     }
   }
   connection = (IRCConnection) target;
   ServerConfig serverConfig = ConfigHelper.getServerConfig(connection);
   String channelName = IRCResolver.stripPath(args[0]);
   if (connection.getChannel(channelName) != null) {
     Utils.sendLocalizedMessage(sender, "error.alreadyJoined", channelName, connection.getHost());
     return true;
   }
   ChannelConfig channelConfig = serverConfig.getOrCreateChannelConfig(channelName);
   if (args.length >= 2) {
     AuthManager.putChannelPassword(channelConfig.getIdentifier(), args[1]);
   }
   Utils.sendLocalizedMessage(
       sender, "commands.join", channelConfig.getName(), connection.getHost());
   connection.join(
       channelConfig.getName(), AuthManager.getChannelPassword(channelConfig.getIdentifier()));
   return true;
 }