idk if this works but it works for me idk !!

This commit is contained in:
Chayapak 2023-04-01 12:33:57 +07:00
parent f32d7675ce
commit 35e945403a
2 changed files with 10 additions and 9 deletions

View file

@ -67,7 +67,7 @@ public class Bot {
try {
DiscordPlugin.readyLatch().await();
Thread.sleep(2000); // prob the worst way to fix this thing
// Thread.sleep(2000); // prob the worst way to fix this thing
} catch (InterruptedException ignored) { System.exit(1); }
this.chat = new ChatPlugin(this);
@ -98,7 +98,8 @@ public class Bot {
else username = _username;
Session session = new TcpClientSession(host, port, new MinecraftProtocol(username), null);
this.session = session;
System.out.println("adding listener");
session.addListener(new SessionAdapter() {
// same stuff over and over yup
@ -147,18 +148,18 @@ public class Bot {
@Override
public void disconnected(DisconnectedEvent disconnectedEvent) {
final int reconnectDelay = config.reconnectDelay();
executor.schedule(() -> reconnect(), reconnectDelay, TimeUnit.MILLISECONDS);
for (SessionListener listener : listeners) {
listener.disconnected(disconnectedEvent);
}
final int reconnectDelay = config.reconnectDelay();
if (reconnectDelay < 0) return; // to disable reconnecting
executor.schedule(() -> reconnect(), reconnectDelay, TimeUnit.MILLISECONDS);
}
});
this.session = session;
session.connect();
}

View file

@ -22,8 +22,8 @@ public class LoggerPlugin extends ChatPlugin.ChatListener {
@Override
public void disconnected (DisconnectedEvent event) {
event.getCause().printStackTrace();
log("Disconnected from " + bot.host() + ":" + bot.port() + ", reason: " + event.getReason());
event.getCause().printStackTrace();
}
});