Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Shell(String username, String password) {
- EntityHandler.load();
- irc = new IRC(this, "irc.clubhouse.ws", "awesome", "#herpesbot");
- engineHandle = new EngineHandle();
- //map = new Map();
- //map.loadTile(50 * 48 + 23, 50 * 48 + 23, 0);
- this.username = username;
- this.password = password;
- connectionThread = new Thread(new Runnable() {
- public void run() {
- int i = 0;
- int j = 256;
- int sleepTime = 1;
- int i1 = 0;
- for(int k = 0; k < 10; k++)
- connectionTimers[k] = System.currentTimeMillis();
- while(true) {
- int k1 = j;
- int i2 = sleepTime;
- j = 300;
- sleepTime = 1;
- long l1 = System.currentTimeMillis();
- if (connectionTimers[i] == 0L) {
- j = k1;
- sleepTime = i2;
- } else if (l1 > connectionTimers[i])
- j = (int) ((long) (2560 * threadSleepModifier) / (l1 - connectionTimers[i]));
- if (j < 25)
- j = 25;
- if (j > 256) {
- j = 256;
- sleepTime = (int) ((long) threadSleepModifier - (l1 - connectionTimers[i]) / 10L);
- if (sleepTime < 1)
- sleepTime = 1;
- }
- try {
- Thread.sleep(sleepTime);
- }
- catch (InterruptedException _ex) {
- }
- connectionTimers[i] = l1;
- i = (i + 1) % 10;
- if (sleepTime > 1) {
- for (int j2 = 0; j2 < 10; j2++)
- if (connectionTimers[j2] != 0L)
- connectionTimers[j2] += sleepTime;
- }
- int k2 = 0;
- while (i1 < 256) {
- if(!loggedIn) {
- loggedIn = login();
- if(loggedIn)
- onLogin();
- }
- //method2();
- //ping data
- if(!pingSent && System.currentTimeMillis() - pingTime2 > 5000L) {
- pingTime2 = System.currentTimeMillis();
- streamClass.createPacket(5);
- streamClass.formatPacket();
- pingSent = true;
- }
- long l = System.currentTimeMillis();
- if(streamClass.containsData())
- lastPing = l;
- if(l - lastPing > 5000L) {
- lastPing = l;
- streamClass.createPacket(5);
- streamClass.formatPacket();
- }
- try {
- streamClass.writePacket(20);
- }
- catch(Exception e) {
- print("Lost connection");
- if(!loggedIn) {
- loggedIn = login();
- if(loggedIn)
- onLogin();
- }
- }
- int length = streamClass.readPacket(packetData);
- if(length > 0)
- handlePacket(packetData[0] & 0xff, length/*, packetData*/);
- i1 += j;
- if (++k2 > 1000) {
- i1 = 0;
- break;
- }
- }
- i1 &= 0xff;
- anInt2++;
- long l = System.currentTimeMillis();
- if(aBoolean1) {
- aLong1 = l;
- aBoolean1 = false;
- }
- if(System.currentTimeMillis() - aLong1 > 1000L) {
- anInt1 = anInt2;
- anInt2 = 0;
- aBoolean1 = true;
- }
- }
- }
- });
- connectionThread.start();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement