From 3933a89608139e301adb7f76baa7764f83bcc463 Mon Sep 17 00:00:00 2001 From: TudbuT Date: Fri, 31 May 2024 20:14:13 +0200 Subject: [PATCH] make the RemoteEventManager actually tick --- .../java/com/baseband/client/event/FMLEventHandler.java | 1 + .../baseband/client/event/remote/RemoteEventManager.java | 9 ++++++--- .../com/baseband/client/feature/client/AltControl.java | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Client/src/main/java/com/baseband/client/event/FMLEventHandler.java b/Client/src/main/java/com/baseband/client/event/FMLEventHandler.java index 1e916ba..6eb907f 100644 --- a/Client/src/main/java/com/baseband/client/event/FMLEventHandler.java +++ b/Client/src/main/java/com/baseband/client/event/FMLEventHandler.java @@ -66,6 +66,7 @@ public class FMLEventHandler { return; playerLastTick = mc.player; BaseBand.updateKeyBinds(); + BaseBand.remoteEventManager.onTick(); for(Feature feature : features) { feature.onEveryTick(); if(feature.enabled) { diff --git a/Client/src/main/java/com/baseband/client/event/remote/RemoteEventManager.java b/Client/src/main/java/com/baseband/client/event/remote/RemoteEventManager.java index 4700c3b..451a612 100644 --- a/Client/src/main/java/com/baseband/client/event/remote/RemoteEventManager.java +++ b/Client/src/main/java/com/baseband/client/event/remote/RemoteEventManager.java @@ -10,7 +10,6 @@ import de.tudbut.parsing.JSON; import de.tudbut.parsing.TCN; import de.tudbut.tools.ConfigSaverTCN2; -import javax.annotation.Nullable; import java.io.IOException; import java.io.InputStream; import java.io.InterruptedIOException; @@ -33,7 +32,7 @@ public class RemoteEventManager { private final Queue toSend = new LinkedList<>(); private final Queue toProcess = new LinkedList<>(); - public void connect(@Nullable String ip) { + public void connect(String ip) { try { if(isConnected()) end(); @@ -92,6 +91,7 @@ public class RemoteEventManager { s.setSoTimeout(1); clients.add(s); publish(new RemoteInitEvent(++maxID)); + BaseBand.notify("[Remote] Client connected."); } else { s.close(); } @@ -144,6 +144,7 @@ public class RemoteEventManager { end(); return; } + BaseBand.notify("[Remote] Connected."); while(head != null) { while(!toSend.isEmpty()) { o.write(0); @@ -182,9 +183,11 @@ public class RemoteEventManager { if(event instanceof RemoteInitEvent) { if(id == -1) { id = ((RemoteInitEvent) event).id; + BaseBand.notify("[Remote] Received ID: " + id + "."); } else { maxID = ((RemoteInitEvent) event).id; + BaseBand.notify("[Remote] Someone connected with ID " + id + "."); } } else { @@ -200,7 +203,7 @@ public class RemoteEventManager { } public int getPeers() { - return maxID; + return maxID + 1; } } diff --git a/Client/src/main/java/com/baseband/client/feature/client/AltControl.java b/Client/src/main/java/com/baseband/client/feature/client/AltControl.java index bfdf294..b7865d3 100644 --- a/Client/src/main/java/com/baseband/client/feature/client/AltControl.java +++ b/Client/src/main/java/com/baseband/client/feature/client/AltControl.java @@ -35,6 +35,7 @@ public class AltControl extends Feature { } public void onRemoteSendChat(RemoteSendMessageEvent event) { + BaseBand.notify("[AltControl] Received a message to send."); ChatUtil.simulateSend(event.message, false); } @@ -46,7 +47,7 @@ public class AltControl extends Feature { ChatUtil.print("syntax: " + Client.prefix + this + " "); return; } - BaseBand.remoteEventManager.publish(new RemoteSendMessageEvent(String.join(" ", args))); + BaseBand.publish(new RemoteSendMessageEvent(String.join(" ", args))); } @Override