diff options
-rw-r--r-- | src/main/java/de/hype/bbsentials/communication/BBsentialConnection.java | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/main/java/de/hype/bbsentials/communication/BBsentialConnection.java b/src/main/java/de/hype/bbsentials/communication/BBsentialConnection.java index 1d11998..1d1e3c1 100644 --- a/src/main/java/de/hype/bbsentials/communication/BBsentialConnection.java +++ b/src/main/java/de/hype/bbsentials/communication/BBsentialConnection.java @@ -412,15 +412,17 @@ public class BBsentialConnection { public void onDisconnectPacket(DisconnectPacket packet) { Chat.sendPrivateMessageToSelfError(packet.displayMessage); - for (int i : packet.waitBeforeReconnect) { + BBsentials.connection = null; + for (int i = 0; i < packet.waitBeforeReconnect.length; i++) { + int finalI = i; executionService.schedule(() -> { - if (i == 1) { + if (finalI == 1) { BBsentials.connectToBBserver(); } else { BBsentials.conditionalReconnectToBBserver(); } - }, i, TimeUnit.SECONDS); + }, (long) (packet.waitBeforeReconnect[i] + (Math.random() * packet.random)), TimeUnit.SECONDS); } } |