Пример #1
0
 @Override
 public String encode() {
   StringBuilder string = new StringBuilder();
   string.append(PREFIX);
   string.append("251 ").append(conn.getNickname()).append(" :");
   string
       .append("There are ")
       .append(Server.getServer().getUserHandler().size())
       .append(" users and 0 invisible on 1 servers");
   return string.toString();
 }
Пример #2
0
 public void run(Source source, String[] args) {
   if (args.length == 1) {
     // TODO: Support user modes
     if (args[0].contains("#")) {
       if (Server.getServer().getChannelHandler().getChannel(args[0]) != null) {
         source.send(
             new ModeChannelCodec(
                 args[0], Server.getServer().getChannelHandler().getChannel(args[0]).getModes()));
       }
     }
   } else if (args.length == 2) {
     if (args[0].contains("#")
         && Server.getServer().getChannelHandler().getChannel(args[0]) != null) {
       Channel chan = Server.getServer().getChannelHandler().getChannel(args[0]);
       if (args[1].contains("+")) {
         modifyChannelMode(args, chan, source, true);
       } else if (args[1].contains("-")) {
         modifyChannelMode(args, chan, source, false);
       }
     }
   } else if (args.length >= 3) {
     if (args[0].contains("#")
         && Server.getServer().getChannelHandler().getChannel(args[0]) != null) {
       Channel chan = Server.getServer().getChannelHandler().getChannel(args[0]);
       if (chan.getUserList().containsKey(source)
           && chan.getUserList().get(source).getUserModes().contains(ChannelUserMode.OP)) {
         if (args[1].contains("+")) {
           addRemoveModeChannel(args, chan, source, true);
         } else if (args[1].contains("-")) {
           addRemoveModeChannel(args, chan, source, false);
         }
       }
     }
   }
 }
Пример #3
0
 private void addRemoveModeChannel(String[] args, Channel chan, Source source, boolean add) {
   String[] temp;
   if (add) {
     temp = args[1].split("\\+");
   } else {
     temp = args[1].split("\\-");
   }
   char[] modes = temp[1].toCharArray();
   for (int i = 0; i < modes.length; i++) {
     ChannelUserMode mode = ChannelUserMode.get(String.valueOf(modes[i]));
     User user = Server.getServer().getUserHandler().getUser(args[i + 2]);
     if (mode != null && user != null && chan.getUserList().containsKey(user)) {
       chan.changeUserMode(source, user, mode, add);
     }
   }
 }