Improving shutdown and error handling (#63)

Co-authored-by: Dawson <dawson@funkemunky.cc>
This commit is contained in:
Dawson
2025-04-22 12:07:30 -04:00
committed by GitHub
parent 2dbe465b9e
commit 2b7f043eb9
6 changed files with 194 additions and 150 deletions
@@ -37,12 +37,11 @@ public class BungeeListener extends VPNExecutor implements Listener {
}
@Override
public void shutdown() {
public void onShutdown() {
if(cacheResetTask != null) {
cacheResetTask.cancel();
cacheResetTask = null;
}
threadExecutor.shutdown();
BungeePlugin.pluginInstance.getProxy().getPluginManager().unregisterListener(this);
}
@@ -61,6 +60,17 @@ public class BungeeListener extends VPNExecutor implements Listener {
BungeeCord.getInstance().getLogger().log(Level.SEVERE, message, ex);
}
@Override
public void disablePlugin() {
BungeeCord.getInstance().getPluginManager().unregisterListeners(BungeePlugin.pluginInstance);
if(cacheResetTask != null) {
cacheResetTask.cancel();
cacheResetTask = null;
}
BungeeCord.getInstance().getPluginManager().unregisterCommands(BungeePlugin.pluginInstance);
BungeePlugin.pluginInstance.onDisable();
}
@EventHandler(priority = EventPriority.LOWEST)
public void onListener(final PreLoginEvent event) {
if(!responseCache.asMap().containsKey(event.getConnection().getUniqueId())) return;