Kill the upgrade manager

This commit is contained in:
nossr50 2019-02-19 07:40:29 -08:00
parent c91255c474
commit 5ce08a2294
2 changed files with 66 additions and 66 deletions

View File

@ -121,7 +121,7 @@ public class mcMMO extends JavaPlugin {
PluginManager pluginManager = getServer().getPluginManager(); PluginManager pluginManager = getServer().getPluginManager();
healthBarPluginEnabled = pluginManager.getPlugin("HealthBar") != null; healthBarPluginEnabled = pluginManager.getPlugin("HealthBar") != null;
upgradeManager = new UpgradeManager(); //upgradeManager = new UpgradeManager();
setupFilePaths(); setupFilePaths();

View File

@ -1,65 +1,65 @@
package com.gmail.nossr50.util.upgrade; //package com.gmail.nossr50.util.upgrade;
//
import com.gmail.nossr50.config.ConfigLoader; //import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.datatypes.database.UpgradeType; //import com.gmail.nossr50.datatypes.database.UpgradeType;
//
import java.util.Arrays; //import java.util.Arrays;
import java.util.EnumSet; //import java.util.EnumSet;
import java.util.Set; //import java.util.Set;
//
public class UpgradeManager extends ConfigLoader { //public class UpgradeManager extends ConfigLoader {
private final Set<UpgradeType> setNeededUpgrades; // private final Set<UpgradeType> setNeededUpgrades;
//
public UpgradeManager() { // public UpgradeManager() {
super("upgrades.yml"); // super("upgrades.yml");
//
setNeededUpgrades = EnumSet.allOf(UpgradeType.class); // setNeededUpgrades = EnumSet.allOf(UpgradeType.class);
//
loadKeys(); // loadKeys();
} // }
//
/** // /**
* Check if the given {@link UpgradeType} is necessary. // * Check if the given {@link UpgradeType} is necessary.
* // *
* @param type Upgrade type to check // * @param type Upgrade type to check
* // *
* @return true if plugin data needs to have the given upgrade // * @return true if plugin data needs to have the given upgrade
*/ // */
public boolean shouldUpgrade(final UpgradeType type) { // public boolean shouldUpgrade(final UpgradeType type) {
return setNeededUpgrades.contains(type); // return setNeededUpgrades.contains(type);
} // }
//
/** // /**
* Set the given {@link UpgradeType} as completed. Does nothing if // * Set the given {@link UpgradeType} as completed. Does nothing if
* the upgrade was applied previously. // * the upgrade was applied previously.
* // *
* @param type Upgrade type to set as complete // * @param type Upgrade type to set as complete
*/ // */
public void setUpgradeCompleted(final UpgradeType type) { // public void setUpgradeCompleted(final UpgradeType type) {
if (!setNeededUpgrades.remove(type)) { // if (!setNeededUpgrades.remove(type)) {
return; // return;
} // }
//
plugin.debug("Saving upgrade status for type " + type.toString() + "..."); // plugin.debug("Saving upgrade status for type " + type.toString() + "...");
//
config.set("Upgrades_Finished." + type.toString(), true); // config.set("Upgrades_Finished." + type.toString(), true);
//
try { // try {
config.save(getFile()); // config.save(getFile());
} // }
catch (Exception e) { // catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
} // }
} // }
//
@Override // @Override
protected void loadKeys() { // protected void loadKeys() {
for (UpgradeType type : UpgradeType.values()) { // for (UpgradeType type : UpgradeType.values()) {
if (config.getBoolean("Upgrades_Finished." + type.toString())) { // if (config.getBoolean("Upgrades_Finished." + type.toString())) {
setNeededUpgrades.remove(type); // setNeededUpgrades.remove(type);
} // }
} // }
//
plugin.debug("Needed upgrades: " + Arrays.toString(setNeededUpgrades.toArray(new UpgradeType[setNeededUpgrades.size()]))); // plugin.debug("Needed upgrades: " + Arrays.toString(setNeededUpgrades.toArray(new UpgradeType[setNeededUpgrades.size()])));
} // }
} //}