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