Advertisement
rakiru

Nodus IRC Shit - cleaned up a bit

Jun 3rd, 2012
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 11.84 KB | None | 0 0
  1. import java.awt.Toolkit;
  2. import java.awt.datatransfer.StringSelection;
  3. import java.io.BufferedReader;
  4. import java.io.BufferedWriter;
  5. import java.io.File;
  6. import java.io.FileReader;
  7. import java.io.FileWriter;
  8. import java.io.IOException;
  9. import java.io.InputStreamReader;
  10. import java.io.OutputStreamWriter;
  11. import java.net.Socket;
  12. import java.net.UnknownHostException;
  13. import java.util.ArrayList;
  14. import java.util.Iterator;
  15.  
  16. public class NewClass
  17.         implements Runnable {
  18.  
  19.     public String ircNick;
  20.     public String ircLineStart = "[IRC]";
  21.     public Socket ircSocket;
  22.     private BufferedWriter ircWriter;
  23.     private BufferedReader ircReader;
  24.     private String B = "";
  25.     private String jdField_k_of_type_JavaLangString = "";
  26.     private ArrayList g = new ArrayList();
  27.     private ArrayList j = new ArrayList();
  28.     private ArrayList jdField_k_of_type_JavaUtilArrayList = new ArrayList();
  29.     private boolean D = true;
  30.     private boolean u;
  31.     public static ArrayList i = new ArrayList();
  32.  
  33.     public void run() {
  34.         try {
  35.             H();
  36.             this.ircSocket = new Socket(mR.ao, mR.bR);
  37.             this.ircWriter = new BufferedWriter(new OutputStreamWriter(this.ircSocket.getOutputStream()));
  38.             this.ircReader = new BufferedReader(new InputStreamReader(this.ircSocket.getInputStream()));
  39.             this.ircWriter.write("NICK " + ircNick + "\n");
  40.             this.ircWriter.write("USER " + ircNick + " - - :" + ircNick + "\n");
  41.             this.ircWriter.flush();
  42.             String str1;
  43.             while (((str1 = this.ircReader.readLine()) != null) && (mS.K.w())) {
  44.                 str1 = str1.replaceAll("§", "");
  45.                 if (str1.contains("PING")) {
  46.                     this.ircWriter.write("PONG " + str1.substring(str1.indexOf(":")) + "\n");
  47.                     this.ircWriter.flush();
  48.                     continue;
  49.                 }
  50.                 if (str1.contains(" MODE " + ircNick)) {
  51.                     if (!mR.as.equals("null")) {
  52.                         G();
  53.                     }
  54.                     d(mR.ap, mR.aq);
  55.                     continue;
  56.                 }
  57.                 String str2;
  58.                 if ((str1.contains(" NOTICE ")) && (str1.startsWith(":NickServ!"))) {
  59.                     str2 = str1.substring(str1.indexOf(":", str1.indexOf("NOTICE")) + 1);
  60.                     mR.jdField_a_of_type_Nd.h("§c" + str2, false);
  61.                     continue;
  62.                 }
  63.                 Object localObject1;
  64.                 if (str1.contains(" PRIVMSG ")) {
  65.                     str2 = str1.substring(str1.indexOf(":", str1.indexOf("PRIVMSG")) + 1);
  66.                     localObject1 = str1.substring(1, str1.indexOf("!"));
  67.                     str1 = str1.replace("§", "");
  68.                     if (str2.contains("\001VERSION\001")) {
  69.                         B((String)localObject1);
  70.                         continue;
  71.                     }
  72.                     if (!i.contains(((String)localObject1).toLowerCase())) {
  73.                         if (((str2.startsWith("GET_SERVER")) || (str2.startsWith("SET_SERVER"))) && (str1.toLowerCase().contains(mR.ap.toLowerCase()))) {
  74.                             continue;
  75.                         }
  76.                         if (((str2.startsWith("GET_SERVER")) || (str2.startsWith("SET_SERVER"))) && (!str1.toLowerCase().contains(mR.ap.toLowerCase()))) {
  77.                             if (str2.contains("GET_SERVER")) {
  78.                                 h((String)localObject1, str2);
  79.                             } else {
  80.                                 e((String)localObject1, str2);
  81.                             }
  82.                         } else if (str1.toLowerCase().contains(mR.ap.toLowerCase())) {
  83.                             mR.jdField_a_of_type_Nd.h(ircLineStart + "§" + a((String)localObject1, false) + (String)localObject1 + "§f: " + str2, false);
  84.                         } else {
  85.                             mR.jdField_a_of_type_Nd.h(ircLineStart + "§" + a((String)localObject1, false) + (String)localObject1 + " §f-> " + "§" + a(ircNick, false) + ircNick + "§f: " + str2, false);
  86.                         }
  87.                     }
  88.                     continue;
  89.                 }
  90.                 if (str1.contains(" 353 ")) {
  91.                     if (this.u) {
  92.                         this.jdField_k_of_type_JavaUtilArrayList.clear();
  93.                         this.g.clear();
  94.                         this.j.clear();
  95.                         this.u = false;
  96.                     }
  97.                     str2 = str1.substring(str1.lastIndexOf(":") + 1);
  98.                     if (!str2.substring(0, str2.length() - 1).contains(" ")) {
  99.                         this.jdField_k_of_type_JavaUtilArrayList.add(f(str2));
  100.                         continue;
  101.                     }
  102.                     localObject1 = str2.trim().split(" ");
  103.                     for (String str3 : localObject1) {
  104.                         this.jdField_k_of_type_JavaUtilArrayList.add(f(str3));
  105.                     }
  106.                     continue;
  107.                 }
  108.                 if (str1.contains(" 366 ")) {
  109.                     this.u = true;
  110.                     if (!this.D) {
  111.                         continue;
  112.                     }
  113.                     this.D = false;
  114.                     str2 = mT.a.h() + "Online Users (" + this.jdField_k_of_type_JavaUtilArrayList.size() + "): " + mT.b.h();
  115.                     localObject1 = this.jdField_k_of_type_JavaUtilArrayList.iterator();
  116.                     while (((Iterator)localObject1).hasNext()) {
  117.                         ? ?  ?  =   ((Iterator)localObject1).next();
  118.            
  119.                         str2 = str2 + "§" + a(? ?  ?.toString()
  120.                         , true) + ???.toString() + mT.b.h() + ", ";
  121.                     }
  122.                     str2 = str2.substring(0, str2.length() - 2);
  123.                     mR.jdField_a_of_type_Nd.h(str2, false);
  124.                     continue;
  125.                 }
  126.                 if (str1.contains(" JOIN ")) {
  127.                     if (mS.K.n(1)) {
  128.                         mR.jdField_a_of_type_Nd.h(ircLineStart + str1.substring(1, str1.indexOf("!")) + " has joined IRC.", false);
  129.                     }
  130.                     F();
  131.                     continue;
  132.                 }
  133.                 if ((str1.contains(" QUIT ")) || (str1.contains(" PART "))) {
  134.                     if (!mS.K.n(1)) {
  135.                         continue;
  136.                     }
  137.                     mR.jdField_a_of_type_Nd.h(ircLineStart + str1.substring(1, str1.indexOf("!")) + " has left IRC.", false);
  138.                     continue;
  139.                 }
  140.                 if (str1.contains(" KICK ")) {
  141.                     str2 = str1.substring(str1.indexOf("KICK"));
  142.                     localObject1 = str2.split(" ");
  143.                     if (localObject1[2].equalsIgnoreCase(ircNick)) {
  144.                         mR.jdField_a_of_type_Nd.h(ircLineStart + "You have been kicked from IRC.", false);
  145.                         mS.K.f(false);
  146.                         mS.L.f(false);
  147.                         mS.L.f(false);
  148.                         break;
  149.                     }
  150.                     mR.jdField_a_of_type_Nd.h(ircLineStart + localObject1[2] + " has been kicked from IRC.", false);
  151.                     continue;
  152.                 }
  153.                 if (!str1.contains(" 475 ")) {
  154.                     continue;
  155.                 }
  156.                 mR.jdField_a_of_type_Nd.h(ircLineStart + "This channel is password protected.", false);
  157.             }
  158.             this.ircSocket.close();
  159.             this.ircWriter.close();
  160.             this.ircReader.close();
  161.         } catch (UnknownHostException localUnknownHostException) {
  162.             localUnknownHostException.printStackTrace();
  163.         } catch (IOException localIOException) {
  164.             localIOException.printStackTrace();
  165.         }
  166.     }
  167.  
  168.     public void B(String paramString) {
  169.         try {
  170.             this.ircWriter.write("PRIVMSG " + paramString + " :" + "\001VERSION Client: Nodus\001\n");
  171.             this.ircWriter.flush();
  172.         } catch (Exception localException) {
  173.         }
  174.     }
  175.  
  176.     public String f(String paramString) {
  177.         if ((paramString.charAt(0) == '@') || ((paramString.charAt(0) == '~') && (!this.g.contains(paramString)))) {
  178.             paramString = paramString.substring(1);
  179.             this.g.add(paramString.toLowerCase());
  180.         } else if ((paramString.charAt(0) == '+') && (!this.j.contains(paramString))) {
  181.             paramString = paramString.substring(1);
  182.             this.j.add(paramString.toLowerCase());
  183.         } else if ((paramString.charAt(0) == '%') || (paramString.charAt(0) == '&')) {
  184.             paramString = paramString.substring(1);
  185.         }
  186.         return paramString;
  187.     }
  188.  
  189.     public void g(String paramString1, String paramString2) {
  190.         try {
  191.             this.jdField_k_of_type_JavaLangString = paramString2;
  192.             this.ircWriter.write("PRIVMSG NICKSERV :REGISTER " + paramString1 + " " + paramString2 + "\n");
  193.             this.ircWriter.flush();
  194.         } catch (Exception localException) {
  195.         }
  196.     }
  197.  
  198.     public void G() {
  199.         try {
  200.             this.ircWriter.write("PRIVMSG NICKSERV :IDENTIFY " + mR.as + "\n");
  201.             this.ircWriter.flush();
  202.         } catch (Exception localException) {
  203.         }
  204.     }
  205.  
  206.     public void A(String paramString) {
  207.         try {
  208.             this.ircWriter.write("KICK " + mR.ap + " " + paramString + "\n");
  209.             this.ircWriter.flush();
  210.         } catch (Exception localException) {
  211.         }
  212.     }
  213.  
  214.     public void e(String paramString1, String paramString2) {
  215.         String[] arrayOfString = paramString2.split(";");
  216.         if (arrayOfString.length < 4) {
  217.             return;
  218.         }
  219.         if ((arrayOfString[1].equalsIgnoreCase(ircNick)) && (paramString1.equalsIgnoreCase(this.B))) {
  220.             if (arrayOfString[2].equals("127.0.0.1")) {
  221.                 mR.jdField_a_of_type_Nd.h(ircLineStart + new StringBuilder().append(paramString1).append(" is not in a server.").toString(), false);
  222.             } else {
  223.                 mR.jdField_a_of_type_Nd.h(ircLineStart + paramString1 + " is on server " + arrayOfString[2] + ":" + arrayOfString[3] + " as " + arrayOfString[4], false);
  224.                 mR.jdField_a_of_type_Nd.h(ircLineStart + "Address added to clipboard.", false);
  225.                 String str = arrayOfString[2] + ":" + arrayOfString[3];
  226.                 StringSelection localStringSelection = new StringSelection(str);
  227.                 Toolkit.getDefaultToolkit().getSystemClipboard().setContents(localStringSelection, null);
  228.             }
  229.             this.B = "";
  230.         }
  231.     }
  232.  
  233.     public void h(String paramString1, String paramString2) {
  234.         try {
  235.             String[] arrayOfString = paramString2.split(";");
  236.             if (arrayOfString.length < 1) {
  237.                 return;
  238.             }
  239.             if (arrayOfString[1].equalsIgnoreCase(ircNick)) {
  240.                 if (mS.N.w()) {
  241.                     this.ircWriter.write("PRIVMSG " + paramString1 + " :SET_SERVER;" + paramString1 + ";" + mR.s + ";" + mR.y + ";" + mR.i.b.jdField_k_of_type_JavaLangString + "\n");
  242.                     this.ircWriter.flush();
  243.                 } else {
  244.                     this.ircWriter.write("PRIVMSG " + paramString1 + " :SET_SERVER;" + paramString1 + ";127.0.0.1;25565;" + mR.i.b.jdField_k_of_type_JavaLangString + "\n");
  245.                     this.ircWriter.flush();
  246.                 }
  247.             }
  248.         } catch (Exception localException) {
  249.         }
  250.     }
  251.  
  252.     public void E(String paramString) {
  253.         try {
  254.             this.B = paramString;
  255.             mR.jdField_a_of_type_Nd.h(ircLineStart + "Attempting to get " + paramString + "'s server.", false);
  256.             this.ircWriter.write("PRIVMSG " + paramString + " :GET_SERVER;" + paramString + "\n");
  257.             this.ircWriter.flush();
  258.         } catch (Exception localException) {
  259.         }
  260.     }
  261.  
  262.     public void C(String paramString) {
  263.         try {
  264.             mR.jdField_a_of_type_Nd.h(ircLineStart + "§" + a(ircNick, false) + ircNick + "§f: " + paramString, false);
  265.             this.ircWriter.write("PRIVMSG " + mR.ap + " :" + paramString + "\n");
  266.             this.ircWriter.flush();
  267.         } catch (Exception localException) {
  268.         }
  269.     }
  270.  
  271.     public void f(String paramString1, String paramString2) {
  272.         try {
  273.             mR.jdField_a_of_type_Nd.h(ircLineStart + "§" + a(ircNick, false) + ircNick + " §f-> " + "§" + a(paramString1, false) + "§f:" + paramString2, false);
  274.             this.ircWriter.write("PRIVMSG " + paramString1 + " :" + paramString2 + "\n");
  275.             this.ircWriter.flush();
  276.         } catch (Exception localException) {
  277.         }
  278.     }
  279.  
  280.     public void y() {
  281.         try {
  282.             this.D = true;
  283.             this.ircWriter.write("NAMES " + mR.ap + "\n");
  284.             this.ircWriter.flush();
  285.         } catch (Exception localException) {
  286.         }
  287.     }
  288.  
  289.     public void F() {
  290.         try {
  291.             this.ircWriter.write("NAMES " + mR.ap + "\n");
  292.             this.ircWriter.flush();
  293.         } catch (Exception localException) {
  294.         }
  295.     }
  296.  
  297.     public char a(String paramString, boolean paramBoolean) {
  298.         if (this.g.contains(paramString.toLowerCase())) {
  299.             return 'c';
  300.         }
  301.         if (this.j.contains(paramString.toLowerCase())) {
  302.             return '5';
  303.         }
  304.         if (!paramBoolean) {
  305.             return mT.c.a();
  306.         }
  307.         return 'f';
  308.     }
  309.  
  310.     public void d(String paramString1, String paramString2) {
  311.         try {
  312.             this.D = true;
  313.             this.ircWriter.write("PART " + mR.ap + "\n");
  314.             this.ircWriter.write("JOIN " + paramString1 + (!paramString2.equals("") ? " " + paramString2 : "") + "\n");
  315.             mR.ap = paramString1;
  316.             mR.aq = paramString2;
  317.             mR.jdField_a_of_type_LB.F();
  318.             this.ircWriter.flush();
  319.         } catch (Exception localException) {
  320.         }
  321.     }
  322.  
  323.     public static File c() {
  324.         return new File(lB.e, "ignore.txt");
  325.     }
  326.  
  327.     public static void H() {
  328.         try {
  329.             BufferedReader localBufferedReader = new BufferedReader(new FileReader(c()));
  330.             String str;
  331.             for (int m = 0; (str = localBufferedReader.readLine()) != null; m++) {
  332.                 i.add(str.toLowerCase());
  333.             }
  334.             localBufferedReader.close();
  335.         } catch (Exception localException) {
  336.         }
  337.     }
  338.  
  339.     public void E() {
  340.         try {
  341.             BufferedWriter localBufferedWriter = new BufferedWriter(new FileWriter(c()));
  342.             for (int m = 0; m < i.size(); m++) {
  343.                 localBufferedWriter.write((String)i.get(m) + "\r\n");
  344.             }
  345.             localBufferedWriter.close();
  346.         } catch (Exception localException) {
  347.         }
  348.     }
  349. }
  350.  
  351. /* Location:           L:\Minecraft\Nodus2\data\.minecraft\bin\minecraft.jar
  352.  * Qualified Name:     nn
  353.  * JD-Core Version:    0.6.0
  354.  */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement