Added save on disable

This commit is contained in:
Norbi Peti 2016-10-31 17:23:52 +01:00
parent d3963ab5f4
commit da8e278c15

View file

@ -1,5 +1,7 @@
package buttondevteam.core; package buttondevteam.core;
import java.util.Map.Entry;
import java.util.UUID;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginDescriptionFile;
@ -7,6 +9,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import buttondevteam.discordplugin.EventExceptionDiscordSender; import buttondevteam.discordplugin.EventExceptionDiscordSender;
import buttondevteam.lib.EventExceptionHandler; import buttondevteam.lib.EventExceptionHandler;
import buttondevteam.lib.TBMCPlayer;
public class MainPlugin extends JavaPlugin { public class MainPlugin extends JavaPlugin {
public static MainPlugin Instance; public static MainPlugin Instance;
@ -14,6 +17,7 @@ public class MainPlugin extends JavaPlugin {
private PluginDescriptionFile pdfFile; private PluginDescriptionFile pdfFile;
private Logger logger; private Logger logger;
@Override
public void onEnable() { public void onEnable() {
// Logs "Plugin Enabled", registers commands // Logs "Plugin Enabled", registers commands
Instance = this; Instance = this;
@ -24,4 +28,13 @@ public class MainPlugin extends JavaPlugin {
EventExceptionHandler.registerEvents(new PlayerListener(), this, new EventExceptionDiscordSender()); EventExceptionHandler.registerEvents(new PlayerListener(), this, new EventExceptionDiscordSender());
} }
@Override
public void onDisable() {
logger.info("Saving player data...");
for (Entry<UUID, TBMCPlayer> entry : TBMCPlayer.getLoadedPlayers().entrySet()) {
TBMCPlayer.savePlayer(entry.getValue());
}
logger.info("Player data saved.");
}
} }