Skip to content

Commit

Permalink
fix Bungee shutdown errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Aug 19, 2019
1 parent 0224e49 commit 0055968
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Expand Up @@ -47,6 +47,13 @@ public void onEnable() {
Debug.log("Depenizen loaded! " + loadedBridges.size() + " plugin bridge(s) loaded (of " + allBridges.size() + " available)");
}

@Override
public void onDisable() {
if (BungeeBridge.instance.connected) {
BungeeBridge.instance.onShutdown();
}
}

public void checkLoadBungeeBridge() {
String bungeeServer = getConfig().getString("Bungee server address", "none");
if (CoreUtilities.toLowerCase(bungeeServer).equals("none")) {
Expand Down
Expand Up @@ -123,7 +123,7 @@ public void init(String address, int port) {
public boolean reconnectPending = false;

public void reconnect() {
if (reconnectPending) {
if (reconnectPending || shuttingDown) {
return;
}
Bukkit.getScheduler().scheduleSyncDelayedTask(Depenizen.instance, new Runnable() {
Expand All @@ -135,6 +135,21 @@ public void run() {
}, 20 * 5);
}

public boolean shuttingDown = false;

public void onShutdown() {
shuttingDown = true;
if (connected) {
try {
handler.channel.close().await();
connected = false;
}
catch (Throwable ex) {
Debug.echoError(ex);
}
}
}

private boolean showedLastError = false;

private boolean hasConnectionLoading = false;
Expand Down

0 comments on commit 0055968

Please sign in to comment.