From 91a02bbc367afb3e75cf9e8d2f63d172f6664e40 Mon Sep 17 00:00:00 2001 From: "Noah Clarkson (Unprotesting)" Date: Thu, 24 Dec 2020 10:09:15 +0000 Subject: [PATCH] Fixed reloading the plugin + Fixed reloading the plugin and some stability bugs when restarting --- Auto-Tune/src/unprotesting/com/github/Main.java | 15 ++++++++------- .../com/github/util/StaticFileHandler.java | 1 - 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Auto-Tune/src/unprotesting/com/github/Main.java b/Auto-Tune/src/unprotesting/com/github/Main.java index 266a634..62304f1 100644 --- a/Auto-Tune/src/unprotesting/com/github/Main.java +++ b/Auto-Tune/src/unprotesting/com/github/Main.java @@ -183,9 +183,11 @@ public void onDisable() { if (getINSTANCE() == null){ INSTANCE = this; } - scheduler.cancelTasks(getINSTANCE()); - server.stop(3); + if (server != null){ + server.stop(0); + } closeDataFiles(); + scheduler.cancelTasks(getINSTANCE()); log.info(String.format("[%s] Disabled Version %s", getDescription().getName(), getDescription().getVersion())); } @@ -215,7 +217,6 @@ public void onEnable() { server.setExecutor(null); server.start(); log.info("[Auto Tune] Web server has started on port " + Config.getPort()); - } catch (IOException e) { log( "Error Creating Server on port: " + Config.getPort() + ". Please try restarting or changing your port."); @@ -473,14 +474,14 @@ public static void setupDataFiles() { public static void closeDataFiles(){ db.commit(); - enchDB.commit(); - tempDB.commit(); - loanDB.commit(); db.close(); - memDB.close(); + enchDB.commit(); enchDB.close(); + tempDB.commit(); tempDB.close(); + loanDB.commit(); loanDB.close(); + memDB.close(); } public static void loadTopMovers(){ diff --git a/Auto-Tune/src/unprotesting/com/github/util/StaticFileHandler.java b/Auto-Tune/src/unprotesting/com/github/util/StaticFileHandler.java index ccc9a81..8137413 100644 --- a/Auto-Tune/src/unprotesting/com/github/util/StaticFileHandler.java +++ b/Auto-Tune/src/unprotesting/com/github/util/StaticFileHandler.java @@ -34,7 +34,6 @@ public void handle(HttpExchange ex) throws IOException { ex.sendResponseHeaders(404, 0); out.write("404 File not found.".getBytes()); } - out.close(); }