Fix writing of config values with backslashes (Fixes #444)

The VALID_PLAYERNAME_REGEXP setting needs to be changed to "^\\w+$" to work properly.
This commit is contained in:
Phoenix616 2021-05-15 14:22:55 +01:00
parent b09a1255a7
commit ca25dca6b0
No known key found for this signature in database
GPG Key ID: 40E2321E71738EB0
2 changed files with 3 additions and 3 deletions

View File

@ -31,9 +31,9 @@ public class ValueParser {
} else if (object instanceof String) {
String[] lines = ((String) object).split("\\R");
if (lines.length == 1) {
return '\"' + String.valueOf(object) + '\"';
return '\"' + String.valueOf(object).replace("\\", "\\\\") + '\"';
} else {
return "|-\n" + Arrays.stream(lines).map(s -> " " + s).collect(Collectors.joining("\n"));
return "|-\n" + Arrays.stream(lines).map(s -> " " + s.replace("\\", "\\\\")).collect(Collectors.joining("\n"));
}
} else {
return '\"' + String.valueOf(object) + '\"';

View File

@ -200,7 +200,7 @@ public class Properties {
@ConfigurationComment("This regexp validates the name of the player. If the name doesn't match, the player will neither be able to create a valid shop sign, nor buy/sell from a shop.\n" +
"Note for Bedrock support: If you have Floodgate on your server, you should set this regexp to ^\\\\*?\\\\w+$ and ENSURE_CORRECT_PLAYERID to false\n" +
"If your Floodgate prefix is not *, change the first * in the regexp (the one before the question mark) to whatever your prefix is.")
public static String VALID_PLAYERNAME_REGEXP = "^\\\\w+$";
public static String VALID_PLAYERNAME_REGEXP = "^\\w+$";
@PrecededBySpace
@ConfigurationComment("Should we block shops that sell things for more than they buy? (This prevents newbies from creating shops that would be exploited)")