fix: i CANNOT handle that single extra connect message after getting suppressed
This commit is contained in:
@@ -1 +1 @@
|
||||
2673
|
||||
2675
|
||||
@@ -65,8 +65,7 @@ public class Bot extends SessionAdapter {
|
||||
|
||||
public boolean printDisconnectedCause = false;
|
||||
|
||||
public int connectingTimes = 0;
|
||||
public int disconnectedTimes = 0;
|
||||
public int connectAttempts = 0;
|
||||
|
||||
public boolean loggedIn = false;
|
||||
public long loginTime;
|
||||
@@ -181,7 +180,7 @@ public class Bot extends SessionAdapter {
|
||||
private void reconnect () {
|
||||
if (session != null) session = null; // does this do nothing?
|
||||
|
||||
connectingTimes++;
|
||||
connectAttempts++;
|
||||
|
||||
for (final Listener listener : listeners) {
|
||||
listener.connecting();
|
||||
@@ -244,8 +243,7 @@ public class Bot extends SessionAdapter {
|
||||
private void packetReceived (final ClientboundLoginPacket ignoredPacket) {
|
||||
loggedIn = true;
|
||||
loginTime = System.currentTimeMillis();
|
||||
connectingTimes = 0;
|
||||
disconnectedTimes = 0;
|
||||
connectAttempts = 0;
|
||||
|
||||
for (final SessionListener listener : listeners) {
|
||||
listener.connected(new ConnectedEvent(session));
|
||||
@@ -364,8 +362,6 @@ public class Bot extends SessionAdapter {
|
||||
public void disconnected (final DisconnectedEvent disconnectedEvent) {
|
||||
loggedIn = false;
|
||||
|
||||
disconnectedTimes++;
|
||||
|
||||
final Throwable cause = disconnectedEvent.getCause();
|
||||
|
||||
if (printDisconnectedCause && cause != null) logger.error(cause);
|
||||
|
||||
@@ -106,8 +106,8 @@ public class DiscordPlugin {
|
||||
|
||||
@Override
|
||||
public void connecting () {
|
||||
if (bot.connectingTimes > 6) return;
|
||||
else if (bot.connectingTimes == 6) {
|
||||
if (bot.connectAttempts > 6) return;
|
||||
else if (bot.connectAttempts == 6) {
|
||||
sendMessageInstantly("Suppressing connection status messages from now on", channelId);
|
||||
|
||||
return;
|
||||
@@ -135,7 +135,7 @@ public class DiscordPlugin {
|
||||
|
||||
@Override
|
||||
public void disconnected (final DisconnectedEvent event) {
|
||||
if (bot.disconnectedTimes >= 6) return;
|
||||
if (bot.connectAttempts >= 6) return;
|
||||
|
||||
final String reason = ComponentUtilities.stringifyDiscordAnsi(event.getReason());
|
||||
sendMessageInstantly(
|
||||
|
||||
@@ -19,8 +19,8 @@ public class LoggerPlugin implements ChatPlugin.Listener {
|
||||
bot.addListener(new Bot.Listener() {
|
||||
@Override
|
||||
public void connecting () {
|
||||
if (bot.connectingTimes > 10) return;
|
||||
else if (bot.connectingTimes == 10) {
|
||||
if (bot.connectAttempts > 10) return;
|
||||
else if (bot.connectAttempts == 10) {
|
||||
log("Suppressing connection status messages from now on");
|
||||
|
||||
return;
|
||||
@@ -46,7 +46,7 @@ public class LoggerPlugin implements ChatPlugin.Listener {
|
||||
|
||||
@Override
|
||||
public void disconnected (final DisconnectedEvent event) {
|
||||
if (bot.disconnectedTimes >= 10) return;
|
||||
if (bot.connectAttempts >= 10) return;
|
||||
|
||||
final Component message = Component.translatable(
|
||||
"Disconnected from %s, reason: %s",
|
||||
|
||||
Reference in New Issue
Block a user