Add maxDistance

master
BodgeMaster 2022-12-15 12:56:29 +01:00
parent 2770980d3a
commit 84beefbbce
1 changed files with 11 additions and 3 deletions

View File

@ -14,8 +14,9 @@ public class Config {
public static boolean debug = true; public static boolean debug = true;
public static boolean fixLog4J = true; public static boolean fixLog4J = true;
public static int maxDistance = 50;
private static final String configHeader = "# The format of this file is strictly `option=value` (no spaces).\n" + "# Lines starting with # and empty lines are ignored.\n"; private static final String configHeader = "# The format of this file is strictly `option=value` (no spaces).\n# Lines starting with # and empty lines are ignored.\n";
public static void writeConfig() { public static void writeConfig() {
String configOut = configHeader; String configOut = configHeader;
@ -25,8 +26,11 @@ public class Config {
configOut += "\n\n# Enable Log4Shell counter measures?\n"; configOut += "\n\n# Enable Log4Shell counter measures?\n";
configOut += "fixLog4J="; configOut += "fixLog4J=";
configOut += fixLog4J ? "true" : "false"; configOut += fixLog4J ? "true" : "false";
configOut += "\n\n# The maximum search radius for finding a suitable location for placing the death chest\n";
configOut += "maxDistance=";
configOut += Integer.toString(maxDistance);
File configFile = new File (configDir, configFileName); File configFile = new File(configDir, configFileName);
try { try {
Files.write(configFile.toPath(), configOut.getBytes()); Files.write(configFile.toPath(), configOut.getBytes());
} catch (IOException e) { } catch (IOException e) {
@ -54,6 +58,10 @@ public class Config {
fixLog4J = configData.get(i).substring(equalsSign + 1).equals("true") ? true : false; fixLog4J = configData.get(i).substring(equalsSign + 1).equals("true") ? true : false;
break; break;
} }
case ("maxDistance"): {
maxDistance = Integer.parseInt(configData.get(i).substring(equalsSign + 1));
break;
}
default: { default: {
System.err.println("Failed parsing config entry: " + configData.get(i)); System.err.println("Failed parsing config entry: " + configData.get(i));
FMLCommonHandler.instance().exitJava(1, false); FMLCommonHandler.instance().exitJava(1, false);