mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 14:46:46 +01:00
Kill the upgrade manager
This commit is contained in:
parent
c91255c474
commit
5ce08a2294
@ -121,7 +121,7 @@ public class mcMMO extends JavaPlugin {
|
||||
PluginManager pluginManager = getServer().getPluginManager();
|
||||
healthBarPluginEnabled = pluginManager.getPlugin("HealthBar") != null;
|
||||
|
||||
upgradeManager = new UpgradeManager();
|
||||
//upgradeManager = new UpgradeManager();
|
||||
|
||||
setupFilePaths();
|
||||
|
||||
|
@ -1,65 +1,65 @@
|
||||
package com.gmail.nossr50.util.upgrade;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.database.UpgradeType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class UpgradeManager extends ConfigLoader {
|
||||
private final Set<UpgradeType> setNeededUpgrades;
|
||||
|
||||
public UpgradeManager() {
|
||||
super("upgrades.yml");
|
||||
|
||||
setNeededUpgrades = EnumSet.allOf(UpgradeType.class);
|
||||
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given {@link UpgradeType} is necessary.
|
||||
*
|
||||
* @param type Upgrade type to check
|
||||
*
|
||||
* @return true if plugin data needs to have the given upgrade
|
||||
*/
|
||||
public boolean shouldUpgrade(final UpgradeType type) {
|
||||
return setNeededUpgrades.contains(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the given {@link UpgradeType} as completed. Does nothing if
|
||||
* the upgrade was applied previously.
|
||||
*
|
||||
* @param type Upgrade type to set as complete
|
||||
*/
|
||||
public void setUpgradeCompleted(final UpgradeType type) {
|
||||
if (!setNeededUpgrades.remove(type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.debug("Saving upgrade status for type " + type.toString() + "...");
|
||||
|
||||
config.set("Upgrades_Finished." + type.toString(), true);
|
||||
|
||||
try {
|
||||
config.save(getFile());
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
for (UpgradeType type : UpgradeType.values()) {
|
||||
if (config.getBoolean("Upgrades_Finished." + type.toString())) {
|
||||
setNeededUpgrades.remove(type);
|
||||
}
|
||||
}
|
||||
|
||||
plugin.debug("Needed upgrades: " + Arrays.toString(setNeededUpgrades.toArray(new UpgradeType[setNeededUpgrades.size()])));
|
||||
}
|
||||
}
|
||||
//package com.gmail.nossr50.util.upgrade;
|
||||
//
|
||||
//import com.gmail.nossr50.config.ConfigLoader;
|
||||
//import com.gmail.nossr50.datatypes.database.UpgradeType;
|
||||
//
|
||||
//import java.util.Arrays;
|
||||
//import java.util.EnumSet;
|
||||
//import java.util.Set;
|
||||
//
|
||||
//public class UpgradeManager extends ConfigLoader {
|
||||
// private final Set<UpgradeType> setNeededUpgrades;
|
||||
//
|
||||
// public UpgradeManager() {
|
||||
// super("upgrades.yml");
|
||||
//
|
||||
// setNeededUpgrades = EnumSet.allOf(UpgradeType.class);
|
||||
//
|
||||
// loadKeys();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Check if the given {@link UpgradeType} is necessary.
|
||||
// *
|
||||
// * @param type Upgrade type to check
|
||||
// *
|
||||
// * @return true if plugin data needs to have the given upgrade
|
||||
// */
|
||||
// public boolean shouldUpgrade(final UpgradeType type) {
|
||||
// return setNeededUpgrades.contains(type);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Set the given {@link UpgradeType} as completed. Does nothing if
|
||||
// * the upgrade was applied previously.
|
||||
// *
|
||||
// * @param type Upgrade type to set as complete
|
||||
// */
|
||||
// public void setUpgradeCompleted(final UpgradeType type) {
|
||||
// if (!setNeededUpgrades.remove(type)) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// plugin.debug("Saving upgrade status for type " + type.toString() + "...");
|
||||
//
|
||||
// config.set("Upgrades_Finished." + type.toString(), true);
|
||||
//
|
||||
// try {
|
||||
// config.save(getFile());
|
||||
// }
|
||||
// catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void loadKeys() {
|
||||
// for (UpgradeType type : UpgradeType.values()) {
|
||||
// if (config.getBoolean("Upgrades_Finished." + type.toString())) {
|
||||
// setNeededUpgrades.remove(type);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// plugin.debug("Needed upgrades: " + Arrays.toString(setNeededUpgrades.toArray(new UpgradeType[setNeededUpgrades.size()])));
|
||||
// }
|
||||
//}
|
||||
|
Loading…
Reference in New Issue
Block a user