Save player systems on shutdown

This commit is contained in:
Chew 2021-09-26 17:24:37 -05:00
parent 9935ac68da
commit bbc180ba4f
No known key found for this signature in database
GPG Key ID: AF1472E56590998C
1 changed files with 12 additions and 2 deletions

View File

@ -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<UUID, List<ESSystem>> 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() {