Skip to content

Commit

Permalink
Save Playerconfigs on shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Flo56958 committed Dec 14, 2024
1 parent ba96937 commit b6dd5c5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/main/java/de/flo56958/minetinker/MineTinker.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ public void AddSoftdependMods() {
public void onDisable() {
ChatWriter.logInfo("Shutting down!");
LanguageManager.cleanup(); //TODO: Replace with PluginDisableEvent
PlayerConfigurationManager.getInstance().saveAllPlayerConfigs();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@

public class PlayerConfigurationManager implements Listener {

private ArrayList<PlayerConfigurationInterface> playerConfigInterfaces = new ArrayList<>();
private final ArrayList<PlayerConfigurationInterface> playerConfigInterfaces = new ArrayList<>();

private HashMap<Player, PlayerConfigurationHandle> playerConfigs = new HashMap<>();
private final HashMap<Player, PlayerConfigurationHandle> playerConfigs = new HashMap<>();

private static PlayerConfigurationManager instance;

Expand Down Expand Up @@ -341,7 +341,11 @@ private void onPlayerQuit(final PlayerQuitEvent e) {

@EventHandler
private void onWorldSave(final WorldSaveEvent e) {
for (PlayerConfigurationHandle handle : playerConfigs.values()) {
saveAllPlayerConfigs();
}

public void saveAllPlayerConfigs() {
for (final PlayerConfigurationHandle handle : playerConfigs.values()) {
try {
handle.config.save(handle.configFile);
} catch (IOException exception) {
Expand Down

0 comments on commit b6dd5c5

Please sign in to comment.