change shitty code

This commit is contained in:
sirjonasxx 2018-06-13 01:40:04 +02:00
parent 5d8cbcbf9d
commit 0efbddfe3d
5 changed files with 16 additions and 18 deletions

View File

@ -11,7 +11,7 @@ import java.util.List;
public class Cacher {
private static String getCacheDir() {
return System.getProperty("user.home") + File.separator + ".G-Earth/";
return System.getProperty("user.home") + File.separator + ".G-Earth" + File.separator;
}
public static boolean exists(String key) {

View File

@ -178,7 +178,7 @@ public class HConnection {
// wachten op data van client
new Thread(() -> {
try {
OutgoingHandler handler = new OutgoingHandler(habbo_server_out);
OutgoingHandler handler = new OutgoingHandler(habbo_server_out, trafficListeners);
rc4Obtainer.setOutgoingHandler(handler);
while (!client.isClosed() && (state == State.WAITING_FOR_CLIENT || state == State.CONNECTED)) {
@ -186,7 +186,7 @@ public class HConnection {
while (client_in.available() > 0) {
client_in.read(buffer = new byte[client_in.available()]);
handler.act(buffer, trafficListeners);
handler.act(buffer);
if (!datastream[0] && handler.isDataStream()) {
datastream[0] = true;
setState(State.CONNECTED);
@ -228,7 +228,7 @@ public class HConnection {
// wachten op data van server
new Thread(() -> {
try {
IncomingHandler handler = new IncomingHandler(client_out);
IncomingHandler handler = new IncomingHandler(client_out, trafficListeners);
rc4Obtainer.setIncomingHandler(handler);
while (!habbo_server.isClosed() && (state == State.CONNECTED || state == State.WAITING_FOR_CLIENT)) {
@ -239,7 +239,7 @@ public class HConnection {
handler.setAsDataStream();
inHandler = handler;
}
handler.act(buffer, trafficListeners);
handler.act(buffer);
}
Thread.sleep(1);
}

View File

@ -18,7 +18,8 @@ public abstract class Handler {
volatile int currentIndex = 0;
public Handler(OutputStream outputStream) {
public Handler(OutputStream outputStream, Object[] listeners) {
this.listeners = listeners;
out = outputStream;
}
@ -27,9 +28,7 @@ public abstract class Handler {
isDataStream = true;
}
public void act(byte[] buffer, Object[] listeners) throws IOException {
this.listeners = listeners;
public void act(byte[] buffer) throws IOException {
if (isDataStream) {
payloadBuffer.push(buffer);
notifyBufferListeners(buffer.length);

View File

@ -9,8 +9,8 @@ import java.io.OutputStream;
public class IncomingHandler extends Handler {
public IncomingHandler(OutputStream outputStream) {
super(outputStream);
public IncomingHandler(OutputStream outputStream, Object[] listeners) {
super(outputStream, listeners);
}
private final Object lock = new Object();
@ -34,7 +34,7 @@ public class IncomingHandler extends Handler {
for (HPacket hpacket : hpackets){
HMessage hMessage = new HMessage(hpacket, HMessage.Side.TOCLIENT, currentIndex);
notifyListeners(hMessage);
if (isDataStream) notifyListeners(hMessage);
if (!hMessage.isBlocked()) {
out.write(hMessage.getPacket().toBytes());

View File

@ -20,8 +20,8 @@ public class OutgoingHandler extends Handler {
private RC4 servercipher = null;
private List<Byte> tempEncryptedBuffer = new ArrayList<>();
public OutgoingHandler(OutputStream outputStream) {
super(outputStream);
public OutgoingHandler(OutputStream outputStream, Object[] listeners) {
super(outputStream, listeners);
}
private void dataStreamCheck(byte[] buffer) {
@ -32,9 +32,8 @@ public class OutgoingHandler extends Handler {
}
@Override
public void act(byte[] buffer, Object[] listeners) throws IOException {
public void act(byte[] buffer) throws IOException {
dataStreamCheck(buffer);
this.listeners = listeners;
if (isDataStream) {
@ -84,7 +83,7 @@ public class OutgoingHandler extends Handler {
}
try {
act(encrbuffer, this.listeners);
act(encrbuffer);
} catch (IOException e) {
e.printStackTrace();
}
@ -100,7 +99,7 @@ public class OutgoingHandler extends Handler {
HPacket[] hpackets = payloadBuffer.receive();
for (HPacket hpacket : hpackets){
HMessage hMessage = new HMessage(hpacket, HMessage.Side.TOSERVER, currentIndex);
notifyListeners(hMessage);
if (isDataStream) notifyListeners(hMessage);
if (!hMessage.isBlocked()) {
out.write(
currentIndex < encryptOffset ? hMessage.getPacket().toBytes() :