From da8e278c1568bbe11679e770a3218ff233c0adad Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Mon, 31 Oct 2016 17:23:52 +0100 Subject: [PATCH] Added save on disable --- src/main/java/buttondevteam/core/MainPlugin.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/buttondevteam/core/MainPlugin.java b/src/main/java/buttondevteam/core/MainPlugin.java index 587432c..f4b7202 100644 --- a/src/main/java/buttondevteam/core/MainPlugin.java +++ b/src/main/java/buttondevteam/core/MainPlugin.java @@ -1,5 +1,7 @@ package buttondevteam.core; +import java.util.Map.Entry; +import java.util.UUID; import java.util.logging.Logger; import org.bukkit.plugin.PluginDescriptionFile; @@ -7,6 +9,7 @@ import org.bukkit.plugin.java.JavaPlugin; import buttondevteam.discordplugin.EventExceptionDiscordSender; import buttondevteam.lib.EventExceptionHandler; +import buttondevteam.lib.TBMCPlayer; public class MainPlugin extends JavaPlugin { public static MainPlugin Instance; @@ -14,6 +17,7 @@ public class MainPlugin extends JavaPlugin { private PluginDescriptionFile pdfFile; private Logger logger; + @Override public void onEnable() { // Logs "Plugin Enabled", registers commands Instance = this; @@ -24,4 +28,13 @@ public class MainPlugin extends JavaPlugin { EventExceptionHandler.registerEvents(new PlayerListener(), this, new EventExceptionDiscordSender()); } + @Override + public void onDisable() { + logger.info("Saving player data..."); + for (Entry entry : TBMCPlayer.getLoadedPlayers().entrySet()) { + TBMCPlayer.savePlayer(entry.getValue()); + } + logger.info("Player data saved."); + } + }