Ignore comment lines on custom menu entry swapper (#721)

Any line that starts with // will be ignored, giving you the ability to categorize your swaps.

![alt text](https://i.gyazo.com/09fe3443ac466ddbc7f7e691aae18bdf.png)
This commit is contained in:
vanni
2019-06-24 04:12:56 -04:00
committed by James
parent 3468ad9b5b
commit 818a92bcc9
2 changed files with 22 additions and 2 deletions

View File

@@ -1309,7 +1309,17 @@ public class MenuEntrySwapperPlugin extends Plugin
if (!Strings.isNullOrEmpty(config))
{
Map<String, String> split = NEWLINE_SPLITTER.withKeyValueSeparator(':').split(config);
StringBuilder sb = new StringBuilder();
for (String str : config.split("\n"))
{
if (!str.startsWith("//"))
{
sb.append(str + "\n");
}
}
Map<String, String> split = NEWLINE_SPLITTER.withKeyValueSeparator(':').split(sb);
for (Map.Entry<String, String> entry : split.entrySet())
{

View File

@@ -32,12 +32,22 @@ public class Parse
{
try
{
StringBuilder sb = new StringBuilder();
for (String str : value.split("\n"))
{
if (!str.startsWith("//"))
{
sb.append(str + "\n");
}
}
Splitter NEWLINE_SPLITTER = Splitter
.on("\n")
.omitEmptyStrings()
.trimResults();
NEWLINE_SPLITTER.withKeyValueSeparator(':').split(value);
NEWLINE_SPLITTER.withKeyValueSeparator(':').split(sb);
return true;
}
catch (IllegalArgumentException ex)