forked from ChomeNS/chomens-bot-java
idk if this works but it works for me idk !!
This commit is contained in:
parent
f32d7675ce
commit
35e945403a
2 changed files with 10 additions and 9 deletions
|
@ -67,7 +67,7 @@ public class Bot {
|
||||||
try {
|
try {
|
||||||
DiscordPlugin.readyLatch().await();
|
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); }
|
} catch (InterruptedException ignored) { System.exit(1); }
|
||||||
|
|
||||||
this.chat = new ChatPlugin(this);
|
this.chat = new ChatPlugin(this);
|
||||||
|
@ -98,7 +98,8 @@ public class Bot {
|
||||||
else username = _username;
|
else username = _username;
|
||||||
|
|
||||||
Session session = new TcpClientSession(host, port, new MinecraftProtocol(username), null);
|
Session session = new TcpClientSession(host, port, new MinecraftProtocol(username), null);
|
||||||
this.session = session;
|
|
||||||
|
System.out.println("adding listener");
|
||||||
|
|
||||||
session.addListener(new SessionAdapter() {
|
session.addListener(new SessionAdapter() {
|
||||||
// same stuff over and over yup
|
// same stuff over and over yup
|
||||||
|
@ -147,18 +148,18 @@ public class Bot {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnected(DisconnectedEvent disconnectedEvent) {
|
public void disconnected(DisconnectedEvent disconnectedEvent) {
|
||||||
|
final int reconnectDelay = config.reconnectDelay();
|
||||||
|
|
||||||
|
executor.schedule(() -> reconnect(), reconnectDelay, TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
for (SessionListener listener : listeners) {
|
for (SessionListener listener : listeners) {
|
||||||
listener.disconnected(disconnectedEvent);
|
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();
|
session.connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,8 @@ public class LoggerPlugin extends ChatPlugin.ChatListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnected (DisconnectedEvent event) {
|
public void disconnected (DisconnectedEvent event) {
|
||||||
event.getCause().printStackTrace();
|
|
||||||
log("Disconnected from " + bot.host() + ":" + bot.port() + ", reason: " + event.getReason());
|
log("Disconnected from " + bot.host() + ":" + bot.port() + ", reason: " + event.getReason());
|
||||||
|
event.getCause().printStackTrace();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue