Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
@@ -6,6 +6,8 @@ import java.util.Map;
|
|||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import utils.StringUtils;
|
||||||
|
|
||||||
// This is a class designed to parse ini inspired key-value pairs that are sectioned off.
|
// This is a class designed to parse ini inspired key-value pairs that are sectioned off.
|
||||||
// The difference here is that this is more permissive than an ini file, and only accepts
|
// The difference here is that this is more permissive than an ini file, and only accepts
|
||||||
// a single split character, not the traditional set an ini does. All of the following are valid:
|
// a single split character, not the traditional set an ini does. All of the following are valid:
|
||||||
@@ -91,6 +93,20 @@ public class TaggedPairStore
|
|||||||
Map.Entry internalPair = (Map.Entry)internal.next();
|
Map.Entry internalPair = (Map.Entry)internal.next();
|
||||||
String key = (String)internalPair.getKey();
|
String key = (String)internalPair.getKey();
|
||||||
String value = (String)internalPair.getValue();
|
String value = (String)internalPair.getValue();
|
||||||
|
key = StringUtils.ReEscape(key);
|
||||||
|
value = StringUtils.ReEscape(value);
|
||||||
|
|
||||||
|
if(key.endsWith("\\r"))
|
||||||
|
{
|
||||||
|
if(!key.endsWith("\\r\\r"))
|
||||||
|
key = key.substring(0, key.length() - 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(value.endsWith("\\r"))
|
||||||
|
{
|
||||||
|
if(!value.endsWith("\\r\\r"))
|
||||||
|
value = value.substring(0, value.length() - 2);
|
||||||
|
}
|
||||||
|
|
||||||
if(key == value)
|
if(key == value)
|
||||||
out += (key + PairSplit) + PairLineSeparator;
|
out += (key + PairSplit) + PairLineSeparator;
|
||||||
@@ -144,6 +160,9 @@ public class TaggedPairStore
|
|||||||
|
|
||||||
String key = line.substring(0, splitPos);
|
String key = line.substring(0, splitPos);
|
||||||
String value = line.substring(splitPos + PairSplit.length());
|
String value = line.substring(splitPos + PairSplit.length());
|
||||||
|
key = StringUtils.UnEscape(key);
|
||||||
|
value = StringUtils.UnEscape(value);
|
||||||
|
|
||||||
taggedPairs.get(sectionName).putIfAbsent(key, value);
|
taggedPairs.get(sectionName).putIfAbsent(key, value);
|
||||||
allPairs.putIfAbsent(key, value);
|
allPairs.putIfAbsent(key, value);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -42,7 +42,7 @@ public class Main extends ListenerAdapter
|
|||||||
|
|
||||||
// Bot startup
|
// Bot startup
|
||||||
kitty = new JDABuilder(AccountType.BOT).setToken(Ref.TestToken).buildBlocking();
|
kitty = new JDABuilder(AccountType.BOT).setToken(Ref.TestToken).buildBlocking();
|
||||||
kitty.getPresence().setGame(Game.playing("with a new build"));
|
kitty.getPresence().setGame(Game.playing("with digital yarn"));
|
||||||
kitty.addEventListener(new Main());
|
kitty.addEventListener(new Main());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package utils;
|
||||||
|
|
||||||
|
public class StringUtils
|
||||||
|
{
|
||||||
|
public static String UnEscape(String str)
|
||||||
|
{
|
||||||
|
str = str.replaceAll("\\\\b", "\b");
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
str = str.replaceAll("\\\b", "\\\\\\b");
|
||||||
|
str = str.replaceAll("\\\n", "\\\\\\n");
|
||||||
|
str = str.replaceAll("\\\t", "\\\\\\t");
|
||||||
|
str = str.replaceAll("\\\r", "\\\\\\r");
|
||||||
|
str = str.replaceAll("\\\f", "\\\\\\f");
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user