From bbc180ba4fe5a7ad3a66815283acf2e0027843b0 Mon Sep 17 00:00:00 2001 From: Chew Date: Sun, 26 Sep 2021 17:24:37 -0500 Subject: [PATCH] Save player systems on shutdown --- .../energeticstorage/EnergeticStorage.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/seanomik/energeticstorage/EnergeticStorage.java b/src/main/java/net/seanomik/energeticstorage/EnergeticStorage.java index 9f3c127..cdb9d02 100644 --- a/src/main/java/net/seanomik/energeticstorage/EnergeticStorage.java +++ b/src/main/java/net/seanomik/energeticstorage/EnergeticStorage.java @@ -62,16 +62,26 @@ public final class EnergeticStorage extends JavaPlugin implements Listener { } }*/ - @EventHandler - public void onWorldSaveEvent(WorldSaveEvent event) { + /** + * Saves all player systems. + */ + private void savePlayerSystems() { for (Map.Entry> systemEntry : Reference.ES_SYSTEMS.entrySet()) { PlayersFile.savePlayerSystems(systemEntry.getValue()); } } + @EventHandler + public void onWorldSaveEvent(WorldSaveEvent event) { + // Save the player systems when the world is saved + savePlayerSystems(); + } + @Override public void onDisable() { // Plugin shutdown logic + // Save the player systems on shutdown to prevent item loss + savePlayerSystems(); } public static EnergeticStorage getPlugin() {