= Escape characters now honored
This commit is contained in:
+1
-1
@@ -184,7 +184,7 @@
|
|||||||
"Localized Strings","LeaderboardInfo","Shows you the 10 users with the most beans on the server"
|
"Localized Strings","LeaderboardInfo","Shows you the 10 users with the most beans on the server"
|
||||||
"Localized Strings","LeaderboardTitle","Server Leaderboard"
|
"Localized Strings","LeaderboardTitle","Server Leaderboard"
|
||||||
"Localized Strings","MapHeight",""
|
"Localized Strings","MapHeight",""
|
||||||
"Localized Strings","MapInfo","Generates a map! You can pass additional information if you want with the flags `-s<seed>`. If one of the fields isn't provided, its default will be used. Note that adjusting the width and height impacts the map outcomes.nn**Defaults**nDefault Seed: Random,nDefault Width: 35(max %s),nDefault Height: 25(max %s)nn**Key**nLand: ~nMountain: ▲nBeach: "
|
"Localized Strings","MapInfo","Generates a map! You can pass additional information if you want with the flags `-s<seed>`. If one of the fields isn't provided, its default will be used. Note that adjusting the width and height impacts the map outcomes.nn**Defaults**nDefault Seed: Random,nDefault Width: 35(max %s),nDefault Height: 25(max %s)nn**Key**nLand: ~nMountain: \u25B2nBeach: "
|
||||||
"Localized Strings","MapInvalid","Invalid arguments provided!"
|
"Localized Strings","MapInvalid","Invalid arguments provided!"
|
||||||
"Localized Strings","MapSeed","Seed"
|
"Localized Strings","MapSeed","Seed"
|
||||||
"Localized Strings","MapVersion","Using mapgen v0.1"
|
"Localized Strings","MapVersion","Using mapgen v0.1"
|
||||||
|
|||||||
|
@@ -14,8 +14,10 @@ import java.util.Vector;
|
|||||||
import com.opencsv.CSVReader;
|
import com.opencsv.CSVReader;
|
||||||
import com.opencsv.CSVReaderBuilder;
|
import com.opencsv.CSVReaderBuilder;
|
||||||
import com.opencsv.CSVWriter;
|
import com.opencsv.CSVWriter;
|
||||||
|
import com.opencsv.RFC4180ParserBuilder;
|
||||||
|
|
||||||
import utils.GlobalLog;
|
import utils.GlobalLog;
|
||||||
|
import utils.StringUtils;
|
||||||
|
|
||||||
public class ConfigCSV
|
public class ConfigCSV
|
||||||
{
|
{
|
||||||
@@ -41,7 +43,7 @@ public class ConfigCSV
|
|||||||
return new CSVWriter(writer,
|
return new CSVWriter(writer,
|
||||||
CSVWriter.DEFAULT_SEPARATOR,
|
CSVWriter.DEFAULT_SEPARATOR,
|
||||||
CSVWriter.DEFAULT_QUOTE_CHARACTER,
|
CSVWriter.DEFAULT_QUOTE_CHARACTER,
|
||||||
'\\',
|
CSVWriter.DEFAULT_ESCAPE_CHARACTER,
|
||||||
CSVWriter.DEFAULT_LINE_END);
|
CSVWriter.DEFAULT_LINE_END);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +62,7 @@ public class ConfigCSV
|
|||||||
}
|
}
|
||||||
|
|
||||||
Reader reader = Files.newBufferedReader(Paths.get(filepath));
|
Reader reader = Files.newBufferedReader(Paths.get(filepath));
|
||||||
CSVReader csvReader = new CSVReaderBuilder(reader).withSkipLines(1).build();
|
CSVReader csvReader = new CSVReaderBuilder(reader).withSkipLines(1).withCSVParser(new RFC4180ParserBuilder().build()).build();
|
||||||
fileContents.clear();
|
fileContents.clear();
|
||||||
|
|
||||||
// Read contents. As for the line number, we not only start counting at 1, we also skip the header.
|
// Read contents. As for the line number, we not only start counting at 1, we also skip the header.
|
||||||
@@ -74,7 +76,7 @@ public class ConfigCSV
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigItem parsedLine = new ConfigItem(record[0], record[1], record[2]);
|
ConfigItem parsedLine = new ConfigItem(StringUtils.unEscape(record[0]), StringUtils.unEscape(record[1]), StringUtils.unEscape(record[2]));
|
||||||
fileContents.add(parsedLine);
|
fileContents.add(parsedLine);
|
||||||
++line;
|
++line;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package core;
|
package core;
|
||||||
|
|
||||||
|
import utils.StringUtils;
|
||||||
|
|
||||||
// Everything in here must be a string type. This class does not
|
// Everything in here must be a string type. This class does not
|
||||||
// perform any parsing past naming columns, and just holds the raw data.
|
// perform any parsing past naming columns, and just holds the raw data.
|
||||||
public class ConfigItem
|
public class ConfigItem
|
||||||
@@ -30,7 +32,7 @@ public class ConfigItem
|
|||||||
|
|
||||||
public String[] getAll()
|
public String[] getAll()
|
||||||
{
|
{
|
||||||
return new String[] {type, key, value};
|
return new String[] {StringUtils.reEscape(type), StringUtils.reEscape(key), StringUtils.reEscape(value) };
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString()
|
||||||
|
|||||||
@@ -1,29 +1,18 @@
|
|||||||
package utils;
|
package utils;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringEscapeUtils;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public class StringUtils
|
public class StringUtils
|
||||||
{
|
{
|
||||||
public static String unEscape(String str)
|
public static String unEscape(String str)
|
||||||
{
|
{
|
||||||
str = str.replaceAll("\\\\b", "\b");
|
return StringEscapeUtils.unescapeJava(str);
|
||||||
str = str.replaceAll("\\\\n", "\n");
|
|
||||||
str = str.replaceAll("\\\\t", "\t");
|
|
||||||
str = str.replaceAll("\\\\r", "\r");
|
|
||||||
str = str.replaceAll("\\\\f", "\f");
|
|
||||||
str = str.replaceAll("\\\\\"", "\"");
|
|
||||||
str = str.replaceAll("\\\\\\\\\\\\", "\\\\");
|
|
||||||
|
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String reEscape(String str)
|
public static String reEscape(String str)
|
||||||
{
|
{
|
||||||
str = str.replaceAll("\\\b", "\\\\\\b");
|
return StringEscapeUtils.escapeJava(str);
|
||||||
str = str.replaceAll("\\\n", "\\\\\\n");
|
|
||||||
str = str.replaceAll("\\\t", "\\\\\\t");
|
|
||||||
str = str.replaceAll("\\\r", "\\\\\\r");
|
|
||||||
str = str.replaceAll("\\\f", "\\\\\\f");
|
|
||||||
|
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finds first whitespace in the string
|
// Finds first whitespace in the string
|
||||||
|
|||||||
Reference in New Issue
Block a user