Exemple #1
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);
         }
       }
     }
   }
 }
 @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();
 }
 @Override
 public String encode() {
   StringBuffer string = new StringBuffer();
   string.append(":").append(source.getReprensentation()).append(" ");
   string.append("MODE").append(" ").append(chan.getName()).append(" ");
   if (add) {
     string.append("+");
   } else {
     string.append("-");
   }
   for (ChannelMode mode : modes) {
     string.append(mode);
   }
   return string.toString();
 }