mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Backup old mod configs & replace with new.
This commit is contained in:
parent
81140824e4
commit
e1bf55b077
@ -18,6 +18,8 @@ import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
|
||||
public class CustomArmorConfig extends ConfigLoader {
|
||||
private static CustomArmorConfig instance;
|
||||
|
||||
private boolean needsUpdate = false;
|
||||
|
||||
private List<Repairable> repairables;
|
||||
|
||||
private List<Material> customBoots = new ArrayList<Material>();
|
||||
@ -50,12 +52,19 @@ public class CustomArmorConfig extends ConfigLoader {
|
||||
protected void loadKeys() {
|
||||
repairables = new ArrayList<Repairable>();
|
||||
|
||||
while (!needsUpdate) {
|
||||
loadArmor("Boots", customBoots);
|
||||
loadArmor("Chestplates", customChestplates);
|
||||
loadArmor("Helmets", customHelmets);
|
||||
loadArmor("Leggings", customLeggings);
|
||||
}
|
||||
|
||||
if (needsUpdate) {
|
||||
needsUpdate = false;
|
||||
backup();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadArmor(String armorType, List<Material> materialList) {
|
||||
ConfigurationSection armorSection = config.getConfigurationSection(armorType);
|
||||
|
||||
@ -66,6 +75,11 @@ public class CustomArmorConfig extends ConfigLoader {
|
||||
Set<String> armorConfigSet = armorSection.getKeys(false);
|
||||
|
||||
for (String armorName : armorConfigSet) {
|
||||
if (config.contains(armorType + "." + armorName + "." + ".ID")) {
|
||||
needsUpdate = true;
|
||||
return;
|
||||
}
|
||||
|
||||
Material armorMaterial = Material.matchMaterial(armorName);
|
||||
|
||||
if (armorMaterial == null) {
|
||||
|
@ -16,6 +16,8 @@ import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
public class CustomBlockConfig extends ConfigLoader {
|
||||
private static CustomBlockConfig instance;
|
||||
|
||||
private boolean needsUpdate = false;
|
||||
|
||||
private List<MaterialData> customExcavationBlocks = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customHerbalismBlocks = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customMiningBlocks = new ArrayList<MaterialData>();
|
||||
@ -42,6 +44,7 @@ public class CustomBlockConfig extends ConfigLoader {
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
while (!needsUpdate) {
|
||||
loadBlocks("Excavation", customExcavationBlocks);
|
||||
loadBlocks("Herbalism", customHerbalismBlocks);
|
||||
loadBlocks("Mining", customMiningBlocks);
|
||||
@ -49,6 +52,12 @@ public class CustomBlockConfig extends ConfigLoader {
|
||||
loadBlocks("Ability_Blocks", customAbilityBlocks);
|
||||
}
|
||||
|
||||
if (needsUpdate) {
|
||||
needsUpdate = false;
|
||||
backup();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadBlocks(String skillType, List<MaterialData> blockList) {
|
||||
ConfigurationSection skillSection = config.getConfigurationSection(skillType);
|
||||
|
||||
@ -59,6 +68,11 @@ public class CustomBlockConfig extends ConfigLoader {
|
||||
Set<String> skillConfigSet = skillSection.getKeys(false);
|
||||
|
||||
for (String blockName : skillConfigSet) {
|
||||
if (config.contains(skillType + "." + blockName + "." + ".ID")) {
|
||||
needsUpdate = true;
|
||||
return;
|
||||
}
|
||||
|
||||
String[] blockInfo = blockName.split("[|]");
|
||||
|
||||
Material blockMaterial = Material.matchMaterial(blockInfo[0]);
|
||||
|
@ -32,6 +32,11 @@ public class CustomEntityConfig extends ConfigLoader {
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
if (config.getConfigurationSection("Hostile") != null) {
|
||||
backup();
|
||||
return;
|
||||
}
|
||||
|
||||
for (String entityName : config.getKeys(false)) {
|
||||
Class<?> clazz = null;
|
||||
String className = config.getString(entityName + ".Class", "");
|
||||
|
@ -19,6 +19,9 @@ import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
|
||||
|
||||
public class CustomToolConfig extends ConfigLoader {
|
||||
private static CustomToolConfig instance;
|
||||
|
||||
private boolean needsUpdate = false;
|
||||
|
||||
private List<Repairable> repairables;
|
||||
|
||||
private List<Material> customAxes = new ArrayList<Material>();
|
||||
@ -55,6 +58,7 @@ public class CustomToolConfig extends ConfigLoader {
|
||||
protected void loadKeys() {
|
||||
repairables = new ArrayList<Repairable>();
|
||||
|
||||
while (!needsUpdate) {
|
||||
loadTool("Axes", customAxes);
|
||||
loadTool("Bows", customBows);
|
||||
loadTool("Hoes", customHoes);
|
||||
@ -63,6 +67,12 @@ public class CustomToolConfig extends ConfigLoader {
|
||||
loadTool("Swords", customSwords);
|
||||
}
|
||||
|
||||
if (needsUpdate) {
|
||||
needsUpdate = false;
|
||||
backup();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadTool(String toolType, List<Material> materialList) {
|
||||
ConfigurationSection toolSection = config.getConfigurationSection(toolType);
|
||||
|
||||
@ -73,6 +83,11 @@ public class CustomToolConfig extends ConfigLoader {
|
||||
Set<String> toolConfigSet = toolSection.getKeys(false);
|
||||
|
||||
for (String toolName : toolConfigSet) {
|
||||
if (config.contains(toolType + "." + toolName + "." + ".ID")) {
|
||||
needsUpdate = true;
|
||||
return;
|
||||
}
|
||||
|
||||
Material toolMaterial = Material.matchMaterial(toolName);
|
||||
|
||||
if (toolMaterial == null) {
|
||||
|
Loading…
Reference in New Issue
Block a user