Skip to content

Commit

Permalink
Strip removed config options, add DisableSaving and bump config version
Browse files Browse the repository at this point in the history
  • Loading branch information
Jikoo committed Nov 26, 2016
1 parent f11d60f commit 0bbcf6c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion plugin/src/main/java/com/lishid/openinv/ConfigUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

public class ConfigUpdater {

private static final int CONFIG_VERSION = 2;
private static final int CONFIG_VERSION = 3;

private final OpenInv plugin;

Expand Down Expand Up @@ -41,10 +41,22 @@ private void performUpdate() {
switch (getConfigVersion()) {
case 1:
updateConfig1To2();
case 2:
updateConfig2To3();
break;
}
}

private void updateConfig2To3() {
plugin.getConfig().set("config-version", 3);
plugin.getConfig().set("items.open-inv", null);
plugin.getConfig().set("toggles.items.open-inv", null);
plugin.getConfig().set("settings.disable-saving", plugin.getConfig().getBoolean("DisableSaving", false));
plugin.getConfig().set("DisableSaving", null);
// Save the new config
plugin.saveConfig();
}

private void updateConfig1To2() {
// Backup the old config file
try {
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/main/java/com/lishid/openinv/OpenInv.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public void unload(OfflinePlayer player) {
* @return false unless configured otherwise
*/
public boolean disableSaving() {
return getConfig().getBoolean("DisableSaving", false);
return getConfig().getBoolean("settings.disable-saving", false);
}

/**
Expand Down

0 comments on commit 0bbcf6c

Please sign in to comment.