Shutdown logging to file in a clean way if the plugin gets disabled

This commit is contained in:
Evenprime 2011-04-11 16:45:30 +02:00
parent 7390acdd39
commit 467fb90ad1
3 changed files with 20 additions and 1 deletions

View File

@ -3,7 +3,7 @@ name: NoCheat
author: Evenprime
main: cc.co.evenprime.bukkit.nocheat.NoCheat
version: 0.8.3a
version: 0.8.3b
commands:
nocheat:

View File

@ -161,6 +161,10 @@ public class NoCheat extends JavaPlugin {
public void onDisable() {
PluginDescriptionFile pdfFile = this.getDescription();
if(config != null)
config.cleanup();
Logger.getLogger("Minecraft").info( "[NoCheat] version [" + pdfFile.getVersion() + "] is disabled.");
}

View File

@ -123,6 +123,21 @@ public class NoCheatConfiguration {
plugin.airbuildCheck.setActive(c.getBoolean("active.airbuild", plugin.airbuildCheck.isActive()));
plugin.bedteleportCheck.setActive(c.getBoolean("active.bedteleport", plugin.bedteleportCheck.isActive()));
}
public void cleanup() {
if(fh != null) {
try {
logger.removeHandler(fh);
fh.flush();
fh.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
private Action[] stringToActions(String string, Action[] def) {