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
@@ -54,13 +54,17 @@ public class AntiVPN {
try {
File configFile = new File(pluginFolder, "config.yml");
if(!configFile.exists()){
configFile.getParentFile().mkdirs();
if(configFile.getParentFile().mkdirs()) {
AntiVPN.getInstance().getExecutor().log("Created plugin folder!");
}
MiscUtils.copy(INSTANCE.getResource( "config.yml"), configFile);
}
INSTANCE.config = ConfigurationProvider.getProvider(YamlConfiguration.class)
.load(configFile);
} catch (IOException e) {
e.printStackTrace();
AntiVPN.getInstance().getExecutor().logException("Could not load config.yml, plugin disabling...", e);
executor.disablePlugin();
return;
}
INSTANCE.vpnConfig = new VPNConfig();
@@ -139,7 +143,8 @@ public class AntiVPN {
}
public void stop() {
executor.shutdown();
executor.onShutdown();
VPNExecutor.threadExecutor.shutdown();
if(database != null) database.shutdown();
}
@@ -188,7 +193,7 @@ public class AntiVPN {
ConfigurationProvider.getProvider(YamlConfiguration.class)
.save(getConfig(), new File(pluginFolder.getPath() + File.separator + "config.yml"));
} catch (IOException e) {
e.printStackTrace();
AntiVPN.getInstance().getExecutor().logException(e);
}
}