mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 22:56:45 +01:00
Automatic spelling mistake correction on repair/salvage configs for
previously misspelled netherite materials
This commit is contained in:
parent
83617b73b7
commit
dab255254c
@ -1,7 +1,10 @@
|
|||||||
Version 2.1.130
|
Version 2.1.130
|
||||||
Fixed a bug that prevented Repair from working on the new Netherite weapons/armors
|
Fixed a bug that prevented Repair from working on the new Netherite weapons/armors
|
||||||
|
mcMMO will now run a script to fix a misspelling of netherite in repair/salvage configs (script only runs once and then never again)
|
||||||
|
|
||||||
|
|
||||||
NOTES:
|
NOTES:
|
||||||
|
Early versions of 1.16 support had Netherite misspelled, the script I added executes before loading those config files to fix the spelling mistakes if it finds any
|
||||||
If you are still having issues with Repair/Salvage, delete the repair and salvage .yml files in /plugins/mcMMO and restart the server
|
If you are still having issues with Repair/Salvage, delete the repair and salvage .yml files in /plugins/mcMMO and restart the server
|
||||||
|
|
||||||
Version 2.1.129
|
Version 2.1.129
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package com.gmail.nossr50.config.skills.repair;
|
package com.gmail.nossr50.config.skills.repair;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.database.UpgradeType;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||||
|
import com.gmail.nossr50.util.FixSpellingNetheriteUtil;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -31,6 +33,13 @@ public class RepairConfigManager {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(mcMMO.getUpgradeManager().shouldUpgrade(UpgradeType.FIX_SPELLING_NETHERITE_REPAIR)) {
|
||||||
|
//Check spelling mistakes (early versions of 1.16 support had Netherite misspelled)
|
||||||
|
plugin.getLogger().info("Checking for certain invalid material names in Repair config...");
|
||||||
|
FixSpellingNetheriteUtil.processFileCheck(mcMMO.p, fileName, UpgradeType.FIX_SPELLING_NETHERITE_REPAIR);
|
||||||
|
}
|
||||||
|
|
||||||
RepairConfig rConfig = new RepairConfig(fileName);
|
RepairConfig rConfig = new RepairConfig(fileName);
|
||||||
repairables.addAll(rConfig.getLoadedRepairables());
|
repairables.addAll(rConfig.getLoadedRepairables());
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package com.gmail.nossr50.config.skills.salvage;
|
package com.gmail.nossr50.config.skills.salvage;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.database.UpgradeType;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
|
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
|
||||||
|
import com.gmail.nossr50.util.FixSpellingNetheriteUtil;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -31,6 +33,14 @@ public class SalvageConfigManager {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(mcMMO.getUpgradeManager().shouldUpgrade(UpgradeType.FIX_SPELLING_NETHERITE_SALVAGE)) {
|
||||||
|
//Check spelling mistakes (early versions of 1.16 support had Netherite misspelled)
|
||||||
|
plugin.getLogger().info("Checking for certain invalid material names in Salvage config...");
|
||||||
|
FixSpellingNetheriteUtil.processFileCheck(mcMMO.p, fileName, UpgradeType.FIX_SPELLING_NETHERITE_SALVAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
SalvageConfig salvageConfig = new SalvageConfig(fileName);
|
SalvageConfig salvageConfig = new SalvageConfig(fileName);
|
||||||
salvageables.addAll(salvageConfig.getLoadedSalvageables());
|
salvageables.addAll(salvageConfig.getLoadedSalvageables());
|
||||||
}
|
}
|
||||||
|
@ -14,4 +14,6 @@ public enum UpgradeType {
|
|||||||
DROP_NAME_UNIQUENESS,
|
DROP_NAME_UNIQUENESS,
|
||||||
ADD_SKILL_TOTAL,
|
ADD_SKILL_TOTAL,
|
||||||
ADD_UNIQUE_PLAYER_DATA,
|
ADD_UNIQUE_PLAYER_DATA,
|
||||||
|
FIX_SPELLING_NETHERITE_SALVAGE,
|
||||||
|
FIX_SPELLING_NETHERITE_REPAIR
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.runnables.player.PlayerProfileSaveTask;
|
import com.gmail.nossr50.runnables.player.PlayerProfileSaveTask;
|
||||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -3,10 +3,7 @@ package com.gmail.nossr50.skills.mining;
|
|||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
public class Mining {
|
public class Mining {
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ import com.gmail.nossr50.util.random.RandomChanceUtil;
|
|||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
import org.apache.commons.lang.math.RandomUtils;
|
import org.apache.commons.lang.math.RandomUtils;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
package com.gmail.nossr50.util;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.database.UpgradeType;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
public class FixSpellingNetheriteUtil {
|
||||||
|
|
||||||
|
public static void processFileCheck(mcMMO pluginRef, String fileName, UpgradeType upgradeType) {
|
||||||
|
pluginRef.getLogger().info("Checking " + fileName + " config material names...");
|
||||||
|
|
||||||
|
File configFile = new File(pluginRef.getDataFolder(), fileName);
|
||||||
|
if(configFile.exists()) {
|
||||||
|
BufferedReader bufferedReader = null;
|
||||||
|
FileWriter fileWriter = null;
|
||||||
|
try {
|
||||||
|
bufferedReader = new BufferedReader(new FileReader(configFile));
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
String curLine;
|
||||||
|
|
||||||
|
while ((curLine = bufferedReader.readLine()) != null) {
|
||||||
|
String fixedLine = curLine.replace("NETHERRITE", "NETHERITE");
|
||||||
|
stringBuilder.append(fixedLine);
|
||||||
|
stringBuilder.append("\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Close
|
||||||
|
bufferedReader.close();
|
||||||
|
|
||||||
|
fileWriter = new FileWriter(configFile);
|
||||||
|
fileWriter.write(stringBuilder.toString());
|
||||||
|
fileWriter.close();
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
if(bufferedReader != null) {
|
||||||
|
try {
|
||||||
|
bufferedReader.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(fileWriter != null) {
|
||||||
|
try {
|
||||||
|
fileWriter.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pluginRef.getLogger().info("Finished checking "+fileName+" for certain misspelled material names.");
|
||||||
|
|
||||||
|
mcMMO.getUpgradeManager().setUpgradeCompleted(upgradeType);
|
||||||
|
}
|
||||||
|
}
|
@ -7,3 +7,5 @@ Upgrades_Finished:
|
|||||||
DROP_SQL_PARTY_NAMES: false
|
DROP_SQL_PARTY_NAMES: false
|
||||||
DROP_SPOUT: false
|
DROP_SPOUT: false
|
||||||
ADD_ALCHEMY: false
|
ADD_ALCHEMY: false
|
||||||
|
FIX_SPELLING_NETHERITE_SALVAGE: false
|
||||||
|
FIX_SPELLING_NETHERITE_REPAIR: false
|
||||||
|
Loading…
Reference in New Issue
Block a user