Advertisement
Guest User

Untitled

a guest
Jun 9th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.83 KB | None | 0 0
  1.     public Shell(String username, String password) {
  2.         EntityHandler.load();
  3.         irc = new IRC(this, "irc.clubhouse.ws", "awesome", "#herpesbot");
  4.         engineHandle = new EngineHandle();
  5.         //map = new Map();
  6.         //map.loadTile(50 * 48 + 23, 50 * 48 + 23, 0);
  7.         this.username = username;
  8.         this.password = password;
  9.         connectionThread = new Thread(new Runnable() {
  10.             public void run() {
  11.                 int i = 0;
  12.                 int j = 256;
  13.                 int sleepTime = 1;
  14.                 int i1 = 0;
  15.                 for(int k = 0; k < 10; k++)
  16.                     connectionTimers[k] = System.currentTimeMillis();
  17.                 while(true) {
  18.                     int k1 = j;
  19.                     int i2 = sleepTime;
  20.                     j = 300;
  21.                     sleepTime = 1;
  22.                     long l1 = System.currentTimeMillis();
  23.                     if (connectionTimers[i] == 0L) {
  24.                         j = k1;
  25.                         sleepTime = i2;
  26.                     } else if (l1 > connectionTimers[i])
  27.                         j = (int) ((long) (2560 * threadSleepModifier) / (l1 - connectionTimers[i]));
  28.                     if (j < 25)
  29.                         j = 25;
  30.                     if (j > 256) {
  31.                         j = 256;
  32.                         sleepTime = (int) ((long) threadSleepModifier - (l1 - connectionTimers[i]) / 10L);
  33.                         if (sleepTime < 1)
  34.                             sleepTime = 1;
  35.                     }
  36.                     try {
  37.                         Thread.sleep(sleepTime);
  38.                     }
  39.                     catch (InterruptedException _ex) {
  40.                     }
  41.                     connectionTimers[i] = l1;
  42.                     i = (i + 1) % 10;
  43.                     if (sleepTime > 1) {
  44.                         for (int j2 = 0; j2 < 10; j2++)
  45.                             if (connectionTimers[j2] != 0L)
  46.                                 connectionTimers[j2] += sleepTime;
  47.  
  48.                     }
  49.                     int k2 = 0;
  50.                     while (i1 < 256) {
  51.                         if(!loggedIn) {
  52.                             loggedIn = login();
  53.                             if(loggedIn)
  54.                                 onLogin();
  55.                         }
  56.                         //method2();
  57.                         //ping data
  58.                         if(!pingSent && System.currentTimeMillis() - pingTime2 > 5000L) {
  59.                             pingTime2 = System.currentTimeMillis();
  60.                             streamClass.createPacket(5);
  61.                             streamClass.formatPacket();
  62.                             pingSent = true;
  63.                         }
  64.                         long l = System.currentTimeMillis();
  65.                         if(streamClass.containsData())
  66.                             lastPing = l;
  67.                         if(l - lastPing > 5000L) {
  68.                             lastPing = l;
  69.                             streamClass.createPacket(5);
  70.                             streamClass.formatPacket();
  71.                         }
  72.                         try {
  73.                             streamClass.writePacket(20);
  74.                         }
  75.                         catch(Exception e) {
  76.                             print("Lost connection");
  77.                             if(!loggedIn) {
  78.                                 loggedIn = login();
  79.                                 if(loggedIn)
  80.                                     onLogin();
  81.                             }
  82.                         }
  83.                         int length = streamClass.readPacket(packetData);
  84.                         if(length > 0)
  85.                             handlePacket(packetData[0] & 0xff, length/*, packetData*/);
  86.                        
  87.                         i1 += j;
  88.                         if (++k2 > 1000) {
  89.                             i1 = 0;
  90.                             break;
  91.                         }
  92.                     }
  93.                     i1 &= 0xff;
  94.                     anInt2++;
  95.                     long l = System.currentTimeMillis();
  96.                     if(aBoolean1) {
  97.                         aLong1 = l;
  98.                         aBoolean1 = false;
  99.                     }
  100.                     if(System.currentTimeMillis() - aLong1 > 1000L) {
  101.                         anInt1 = anInt2;
  102.                         anInt2 = 0;
  103.                         aBoolean1 = true;
  104.                     }
  105.                 }
  106.             }
  107.         });
  108.         connectionThread.start();
  109.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement