Backup old mod configs & replace with new.

This commit is contained in:
GJ 2013-10-08 13:10:09 -04:00
parent 81140824e4
commit e1bf55b077
4 changed files with 63 additions and 15 deletions

View File

@ -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,10 +52,17 @@ public class CustomArmorConfig extends ConfigLoader {
protected void loadKeys() {
repairables = new ArrayList<Repairable>();
loadArmor("Boots", customBoots);
loadArmor("Chestplates", customChestplates);
loadArmor("Helmets", customHelmets);
loadArmor("Leggings", customLeggings);
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) {
@ -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) {

View File

@ -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,11 +44,18 @@ public class CustomBlockConfig extends ConfigLoader {
@Override
protected void loadKeys() {
loadBlocks("Excavation", customExcavationBlocks);
loadBlocks("Herbalism", customHerbalismBlocks);
loadBlocks("Mining", customMiningBlocks);
loadBlocks("Woodcutting", customWoodcuttingBlocks);
loadBlocks("Ability_Blocks", customAbilityBlocks);
while (!needsUpdate) {
loadBlocks("Excavation", customExcavationBlocks);
loadBlocks("Herbalism", customHerbalismBlocks);
loadBlocks("Mining", customMiningBlocks);
loadBlocks("Woodcutting", customWoodcuttingBlocks);
loadBlocks("Ability_Blocks", customAbilityBlocks);
}
if (needsUpdate) {
needsUpdate = false;
backup();
}
}
private void loadBlocks(String skillType, List<MaterialData> blockList) {
@ -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]);

View File

@ -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", "");

View File

@ -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,12 +58,19 @@ public class CustomToolConfig extends ConfigLoader {
protected void loadKeys() {
repairables = new ArrayList<Repairable>();
loadTool("Axes", customAxes);
loadTool("Bows", customBows);
loadTool("Hoes", customHoes);
loadTool("Pickaxes", customPickaxes);
loadTool("Shovels", customShovels);
loadTool("Swords", customSwords);
while (!needsUpdate) {
loadTool("Axes", customAxes);
loadTool("Bows", customBows);
loadTool("Hoes", customHoes);
loadTool("Pickaxes", customPickaxes);
loadTool("Shovels", customShovels);
loadTool("Swords", customSwords);
}
if (needsUpdate) {
needsUpdate = false;
backup();
}
}
private void loadTool(String toolType, List<Material> materialList) {
@ -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) {