= fixed UTF_8 formatting issue for config output

This commit is contained in:
Matthew Cech
2019-06-23 01:58:35 -07:00
parent da699281e9
commit 227bf29b10
3 changed files with 392 additions and 92 deletions
+356 -63
View File
@@ -1,66 +1,3 @@
[[Command Management]]
[CommandEnabler]
beans=1
benchmark, bench=1
bet=1
bethistory=1
blur=1
boop=1
buildhelp=1
c++, g++, cplus, cpp=1
catch=1
charactercreate=1
charactereditbio=1
charactereditname=1
characterediturl=1
choose=1
color, colour=1
crouton=1
dbflush=1
dbstats=1
eightball, 8ball=1
fetch=1
givebeans=1
guildroleadd=1
guildroleallowed=1
guildrolelist=1
guildrolenotallowed=1
guildroleremove=1
help=1
indicator=1
info, about=1
invite=1
java, jdoodle=1
leaderboard=1
map=1
perish, thenperish=1
ping=1
poll=1
raffleend=1
rafflejoin=1
rafflespin=1
rafflestart=1
rating=1
results=1
role=1
roll=1
rpend=1
rpg=1
rpstart=1
searchcharacter=1
showpoll=1
shutdown=1
stats=1
teey=1
tony, stark, dontfeelgood, dontfeelsogood=1
tweet=1
vote=1
wolfram=1
work=1
yeet=1
[[Localized Commands]] [[Localized Commands]]
[ObjectBuilderFactory] [ObjectBuilderFactory]
indicator= indicator=
@@ -124,6 +61,8 @@ invite=
[[Localized Strings]] [[Localized Strings]]
[CommandBenchmark] [CommandBenchmark]
BenchmarkInfo=Allows you to lookup PC component benchmarks from UserBenchmark! You can use `bench find <name-snippet>` to see what's in the database, `bench info <name-snippet>` to look at a specific component, or the experimental `bench compare` commands! BenchmarkInfo=Allows you to lookup PC component benchmarks from UserBenchmark! You can use `bench find <name-snippet>` to see what's in the database, `bench info <name-snippet>` to look at a specific component, or the experimental `bench compare` commands!
@@ -434,3 +373,357 @@ RaffleJoinSuccess=You joined the raffle!
DBFlushInfo=Takes all objects queued for the database and writes them to the database, then says how many were written. DBFlushInfo=Takes all objects queued for the database and writes them to the database, then says how many were written.
[[Command Management]]
[CommandEnabler]
beans=1
beans=1
beans=1
beans=1
beans=1
beans=1
benchmark, bench=1
benchmark, bench=1
benchmark, bench=1
benchmark, bench=1
benchmark, bench=1
benchmark, bench=1
bet=1
bet=1
bet=1
bet=1
bet=1
bet=1
bethistory=1
bethistory=1
bethistory=1
bethistory=1
bethistory=1
bethistory=1
blur=1
blur=1
blur=1
blur=1
blur=1
blur=1
boop=1
boop=1
boop=1
boop=1
boop=1
boop=1
buildhelp=1
buildhelp=1
buildhelp=1
buildhelp=1
buildhelp=1
buildhelp=1
c++, g++, cplus, cpp=1
c++, g++, cplus, cpp=1
c++, g++, cplus, cpp=1
c++, g++, cplus, cpp=1
c++, g++, cplus, cpp=1
c++, g++, cplus, cpp=1
catch=1
catch=1
catch=1
catch=1
catch=1
catch=1
charactercreate=1
charactercreate=1
charactercreate=1
charactercreate=1
charactercreate=1
charactercreate=1
charactereditbio=1
charactereditbio=1
charactereditbio=1
charactereditbio=1
charactereditbio=1
charactereditbio=1
charactereditname=1
charactereditname=1
charactereditname=1
charactereditname=1
charactereditname=1
charactereditname=1
characterediturl=1
characterediturl=1
characterediturl=1
characterediturl=1
characterediturl=1
characterediturl=1
choose=1
choose=1
choose=1
choose=1
choose=1
choose=1
color, colour=1
color, colour=1
color, colour=1
color, colour=1
color, colour=1
color, colour=1
crouton=1
crouton=1
crouton=1
crouton=1
crouton=1
crouton=1
dbflush=1
dbflush=1
dbflush=1
dbflush=1
dbflush=1
dbflush=1
dbstats=1
dbstats=1
dbstats=1
dbstats=1
dbstats=1
dbstats=1
eightball, 8ball=1
eightball, 8ball=1
eightball, 8ball=1
eightball, 8ball=1
eightball, 8ball=1
eightball, 8ball=1
fetch=1
fetch=1
fetch=1
fetch=1
fetch=1
fetch=1
givebeans=1
givebeans=1
givebeans=1
givebeans=1
givebeans=1
givebeans=1
guildroleadd=1
guildroleadd=1
guildroleadd=1
guildroleadd=1
guildroleadd=1
guildroleadd=1
guildroleallowed=1
guildroleallowed=1
guildroleallowed=1
guildroleallowed=1
guildroleallowed=1
guildroleallowed=1
guildrolelist=1
guildrolelist=1
guildrolelist=1
guildrolelist=1
guildrolelist=1
guildrolelist=1
guildrolenotallowed=1
guildrolenotallowed=1
guildrolenotallowed=1
guildrolenotallowed=1
guildrolenotallowed=1
guildrolenotallowed=1
guildroleremove=1
guildroleremove=1
guildroleremove=1
guildroleremove=1
guildroleremove=1
guildroleremove=1
help=1
help=1
help=1
help=1
help=1
help=1
indicator=1
indicator=1
indicator=1
indicator=1
indicator=1
indicator=1
info, about=1
info, about=1
info, about=1
info, about=1
info, about=1
info, about=1
invite=1
invite=1
invite=1
invite=1
invite=1
invite=1
java, jdoodle=1
java, jdoodle=1
java, jdoodle=1
java, jdoodle=1
java, jdoodle=1
java, jdoodle=1
leaderboard=1
leaderboard=1
leaderboard=1
leaderboard=1
leaderboard=1
leaderboard=1
map=1
map=1
map=1
map=1
map=1
map=1
perish, thenperish=1
perish, thenperish=1
perish, thenperish=1
perish, thenperish=1
perish, thenperish=1
perish, thenperish=1
ping=1
ping=1
ping=1
ping=1
ping=1
ping=1
poll=1
poll=1
poll=1
poll=1
poll=1
poll=1
raffleend=1
raffleend=1
raffleend=1
raffleend=1
raffleend=1
raffleend=1
rafflejoin=1
rafflejoin=1
rafflejoin=1
rafflejoin=1
rafflejoin=1
rafflejoin=1
rafflespin=1
rafflespin=1
rafflespin=1
rafflespin=1
rafflespin=1
rafflespin=1
rafflestart=1
rafflestart=1
rafflestart=1
rafflestart=1
rafflestart=1
rafflestart=1
rating=1
rating=1
rating=1
rating=1
rating=1
rating=1
results=1
results=1
results=1
results=1
results=1
results=1
role=1
role=1
role=1
role=1
role=1
role=1
roll=1
roll=1
roll=1
roll=1
roll=1
roll=1
rpend=1
rpend=1
rpend=1
rpend=1
rpend=1
rpend=1
rpg=1
rpg=1
rpg=1
rpg=1
rpg=1
rpg=1
rpstart=1
rpstart=1
rpstart=1
rpstart=1
rpstart=1
rpstart=1
searchcharacter=1
searchcharacter=1
searchcharacter=1
searchcharacter=1
searchcharacter=1
searchcharacter=1
showpoll=1
showpoll=1
showpoll=1
showpoll=1
showpoll=1
showpoll=1
shutdown=1
shutdown=1
shutdown=1
shutdown=1
shutdown=1
shutdown=1
stats=1
stats=1
stats=1
stats=1
stats=1
stats=1
teey=1
teey=1
teey=1
teey=1
teey=1
teey=1
tony, stark, dontfeelgood, dontfeelsogood=1
tony, stark, dontfeelgood, dontfeelsogood=1
tony, stark, dontfeelgood, dontfeelsogood=1
tony, stark, dontfeelgood, dontfeelsogood=1
tony, stark, dontfeelgood, dontfeelsogood=1
tony, stark, dontfeelgood, dontfeelsogood=1
tweet=1
tweet=1
tweet=1
tweet=1
tweet=1
tweet=1
vote=1
vote=1
vote=1
vote=1
vote=1
vote=1
wolfram=1
wolfram=1
wolfram=1
wolfram=1
wolfram=1
wolfram=1
work=1
work=1
work=1
work=1
work=1
work=1
yeet=1
yeet=1
yeet=1
yeet=1
yeet=1
yeet=1
+8
View File
@@ -57,9 +57,13 @@ public class CommandEnabler extends BaseKeyValueFile implements IConfigSection
keyList.add(key); keyList.add(key);
if(value.equalsIgnoreCase(enabled)) if(value.equalsIgnoreCase(enabled))
{
enabledMap.putIfAbsent(key, true); enabledMap.putIfAbsent(key, true);
}
else else
{
enabledMap.putIfAbsent(key, false); enabledMap.putIfAbsent(key, false);
}
}); });
} }
@@ -92,7 +96,9 @@ public class CommandEnabler extends BaseKeyValueFile implements IConfigSection
String value = enabled.toLowerCase(); String value = enabled.toLowerCase();
if(enabledMap.get(key) == false) if(enabledMap.get(key) == false)
{
value = disabled.toLowerCase(); value = disabled.toLowerCase();
}
list.add(new Pair<String, String>(key, value)); list.add(new Pair<String, String>(key, value));
} }
@@ -108,7 +114,9 @@ public class CommandEnabler extends BaseKeyValueFile implements IConfigSection
String toCheck = key.toLowerCase(); String toCheck = key.toLowerCase();
if(enabledMap.containsKey(toCheck)) if(enabledMap.containsKey(toCheck))
{
return enabledMap.get(toCheck); return enabledMap.get(toCheck);
}
return true; return true;
} }
+5 -6
View File
@@ -1,8 +1,10 @@
package core; package core;
import java.io.File; import java.io.File;
import java.io.FileWriter; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
import java.util.HashMap; import java.util.HashMap;
import java.util.Vector; import java.util.Vector;
import utils.GlobalLog; import utils.GlobalLog;
@@ -84,14 +86,11 @@ public class Config
// Form updated data as necessary for autogeneration // Form updated data as necessary for autogeneration
String output = combineConfigs(); String output = combineConfigs();
String path = configFile.getPath();
// Write to file. // Write to file.
FileWriter fileWriter;
try try
{ {
fileWriter = new FileWriter(path); OutputStreamWriter fileWriter = new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8);
fileWriter.write(output); fileWriter.write(output);
fileWriter.close(); fileWriter.close();
} }
@@ -118,7 +117,7 @@ public class Config
else else
{ {
String sectionContents = parsedSections.getOrDefault(currentHeader, ""); String sectionContents = parsedSections.getOrDefault(currentHeader, "");
parsedSections.put(currentHeader, sectionContents); parsedSections.put(currentHeader, sectionContents + line + pairSeparator);
} }
} }