From 227bf29b10f597029e65ff1959057a5f1f44c81d Mon Sep 17 00:00:00 2001 From: Matthew Cech Date: Sun, 23 Jun 2019 01:58:35 -0700 Subject: [PATCH] = fixed UTF_8 formatting issue for config output --- assets/config.config | 463 ++++++++++++++++++++++++++++------- src/core/CommandEnabler.java | 8 + src/core/Config.java | 13 +- 3 files changed, 392 insertions(+), 92 deletions(-) diff --git a/assets/config.config b/assets/config.config index 892e290..d26feb0 100644 --- a/assets/config.config +++ b/assets/config.config @@ -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]] [ObjectBuilderFactory] indicator= @@ -124,6 +61,8 @@ invite= + + [[Localized Strings]] [CommandBenchmark] BenchmarkInfo=Allows you to lookup PC component benchmarks from UserBenchmark! You can use `bench find ` to see what's in the database, `bench info ` to look at a specific component, or the experimental `bench compare` commands! @@ -138,8 +77,8 @@ GuildRoleNotAllowedSuccess= GuildRoleNotAllowedInfo= [CommandBetHistory] -BetHistoryOutput=Kitty has %s beans! -BetHistoryInfo=Sees the amount of beans Kitty has earned through your bets! +BetHistoryOutput=Kitty has %s beans! +BetHistoryInfo=Sees the amount of beans Kitty has earned through your bets! [CommandCatch] CatchInfo=Play catch with yourself or with a friend with @! @@ -149,9 +88,9 @@ LeaderboardInfo=Shows you the 10 users with the most beans on the server LeaderboardTitle=Server Leaderboard [CommandGuildRoleList] -GuildRoleListOutput=The allowed roles are %s! -GuildRoleListEmpty=There are no roles allowed! -GuildRoleListInfo=Outputs a list of the roles you are allowed to add to yourself! +GuildRoleListOutput=The allowed roles are %s! +GuildRoleListEmpty=There are no roles allowed! +GuildRoleListInfo=Outputs a list of the roles you are allowed to add to yourself! [CommandRoll] RollError=Didn't work ;3; @@ -159,8 +98,8 @@ RollInfo=Based on input of xdy where x is number of dice and y is faces kitty wi [CommandGuildRoleAllowed] GuildRoleAllowedInfo= -GuildRoleAllowedSuccess=Added %s to the allowed roles! -GuildRoleAllowedDuplicate=Can't add the same role twice! +GuildRoleAllowedSuccess=Added %s to the allowed roles! +GuildRoleAllowedDuplicate=Can't add the same role twice! [CommandStats] StatsInfo=Displays the actively running KittyBot application information @@ -187,11 +126,11 @@ PerishInfo=Adds a red, 'a n g e r y' overlay to your icon or the icon of a frien [CommandTradeBeans] TradeBeanseStealingBeans=Stealing is wrong! *Steals 10 beans from %s* TradeBeansNoTargetError=You have to give *someone* your beans! -TradeBeansSuccess=%s gave %s %s of their beans! +TradeBeansSuccess=%s gave %s %s of their beans! TradeBeansStealingBeans= TradeBeansInfo=Gives another person some of your beans! Use is `tradebeans amount @person`! -TradeBeansIntParseError=That's not a real number! -TradeBeansNotEnoughError=You don't have enough beans! +TradeBeansIntParseError=That's not a real number! +TradeBeansNotEnoughError=You don't have enough beans! [CommandPollVote] PollVoteNotValidNumber=That's not a vaild number! @@ -209,7 +148,7 @@ ShutdownInfo=Stops kitty. `-s` or `safe` as an argument attempts to sync off the [CommandRaffleSpin] RaffleSpinInfo= RaffleSpinSuccess=The winner issssssss %s! -RaffleSpinFailure=I can't choose a winner D: +RaffleSpinFailure=I can't choose a winner D: [CommandRaffleEnd] RaffleEndSuccess= @@ -218,7 +157,7 @@ RaffleEndFailure=I don't think there's one going! [CommandCharacterSearch] CharacterSearchNoCharacterFound=Couldn't find a character with that name or ID! -CharacterSearchMultipleCharacterHeader=I found a couple characters with that name, use `charactersearch UniqueID` with their Unique ID to find them! +CharacterSearchMultipleCharacterHeader=I found a couple characters with that name, use `charactersearch UniqueID` with their Unique ID to find them! CharacterSearchMultipleCharacter=%s is owned by %s. Unique ID is `%s` CharacterSearchOneCharacter=I found one character with that name! \n Owner: %s | Name: %s | Bio: %s | Ref: <%s> | Unique ID: `%s` CharacterSearchInfo=Find a character with their name or Unique ID! `charactersearch name` or `charactersearch UniqueID` @@ -273,11 +212,11 @@ RPGInfo=Admin+ command only right now - experimental text RPG! Format is !rpg (key, value)); } @@ -108,7 +114,9 @@ public class CommandEnabler extends BaseKeyValueFile implements IConfigSection String toCheck = key.toLowerCase(); if(enabledMap.containsKey(toCheck)) + { return enabledMap.get(toCheck); + } return true; } diff --git a/src/core/Config.java b/src/core/Config.java index dbe41d9..4f32ffd 100644 --- a/src/core/Config.java +++ b/src/core/Config.java @@ -1,8 +1,10 @@ package core; import java.io.File; -import java.io.FileWriter; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStreamWriter; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Vector; import utils.GlobalLog; @@ -84,14 +86,11 @@ public class Config // Form updated data as necessary for autogeneration String output = combineConfigs(); - String path = configFile.getPath(); - + // Write to file. - FileWriter fileWriter; - try { - fileWriter = new FileWriter(path); + OutputStreamWriter fileWriter = new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8); fileWriter.write(output); fileWriter.close(); } @@ -118,7 +117,7 @@ public class Config else { String sectionContents = parsedSections.getOrDefault(currentHeader, ""); - parsedSections.put(currentHeader, sectionContents); + parsedSections.put(currentHeader, sectionContents + line + pairSeparator); } }