diff --git a/src/main/java/com/sk89q/worldedit/bukkit/BukkitConfiguration.java b/src/main/java/com/sk89q/worldedit/bukkit/BukkitConfiguration.java index 73d89c77b..43761962e 100644 --- a/src/main/java/com/sk89q/worldedit/bukkit/BukkitConfiguration.java +++ b/src/main/java/com/sk89q/worldedit/bukkit/BukkitConfiguration.java @@ -34,6 +34,7 @@ public class BukkitConfiguration extends LocalConfiguration { private Configuration config; private Logger logger; + private FileHandler logFileHandler; public boolean noOpPermissions = false; @@ -97,9 +98,9 @@ public void load() { String logFile = config.getString("logging.file", ""); if (!logFile.equals("")) { try { - FileHandler handler = new FileHandler(logFile, true); - handler.setFormatter(new LogFormat()); - logger.addHandler(handler); + logFileHandler = new FileHandler(logFile, true); + logFileHandler.setFormatter(new LogFormat()); + logger.addHandler(logFileHandler); } catch (IOException e) { logger.log(Level.WARNING, "Could not use log file " + logFile + ": " + e.getMessage()); @@ -110,4 +111,11 @@ public void load() { } } } + + public void unload() { + if (logFileHandler != null) { + logFileHandler.close(); + } + } + } diff --git a/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index 5e6dffdc3..2de3daf5c 100644 --- a/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -111,6 +111,7 @@ public void onEnable() { */ public void onDisable() { controller.clearSessions(); + config.unload(); } /**