diff --git a/src/main/java/com/onarandombox/MultiverseCore/localization/SimpleMessageProvider.java b/src/main/java/com/onarandombox/MultiverseCore/localization/SimpleMessageProvider.java index 1ab2ce79..cbcbcae7 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/localization/SimpleMessageProvider.java +++ b/src/main/java/com/onarandombox/MultiverseCore/localization/SimpleMessageProvider.java @@ -8,6 +8,7 @@ import java.util.HashMap; import java.util.Locale; import java.util.Set; +import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; @@ -20,8 +21,16 @@ public class SimpleMessageProvider implements LazyLocaleMessageProvider { private static final String LOCALIZATION_FOLDER_NAME = "localization"; // Regex 1: replace all single & with the section char - private static final String FORMAT_PATTERN_1 = "([^&])(&)([^&])"; - private static final String FORMAT_REPL_1 = "$1\u00A7$3"; + private static final String FORMAT_PATTERN_1; + private static final String FORMAT_REPL_1; + static { + StringBuilder formatBuilder = new StringBuilder("([^&])&(["); + for (ChatColor c : ChatColor.values()) + formatBuilder.append(c.getChar()); + FORMAT_PATTERN_1 = formatBuilder.append("])").toString(); + + FORMAT_REPL_1 = new StringBuilder().append("$1").append(ChatColor.COLOR_CHAR).append("$2").toString(); + } // Regex 2: replace all double & with single & private static final String FORMAT_PATTERN_2 = "&&"; diff --git a/src/test/java/com/onarandombox/MultiverseCore/test/TestLocalization.java b/src/test/java/com/onarandombox/MultiverseCore/test/TestLocalization.java index 0a58557b..219a4edd 100644 --- a/src/test/java/com/onarandombox/MultiverseCore/test/TestLocalization.java +++ b/src/test/java/com/onarandombox/MultiverseCore/test/TestLocalization.java @@ -109,6 +109,7 @@ public class TestLocalization { assertFalse(new File(TestInstanceCreator.pluginDirectory, "en.yml").exists()); assertTrue(new File("src/main/resources/localization/en.yml").exists()); doAnswer(new Answer() { + @Override public InputStream answer(InvocationOnMock invocation) throws Throwable { try { return new FileInputStream("src/main/resources/" + (String) invocation.getArguments()[0]); @@ -165,6 +166,7 @@ public class TestLocalization { assertTrue(file.exists()); assertTrue(new File("src/main/resources/localization/en.yml").exists()); doAnswer(new Answer() { + @Override public InputStream answer(InvocationOnMock invocation) throws Throwable { try { return new FileInputStream("src/main/resources/" + (String) invocation.getArguments()[0]); diff --git a/src/test/java/com/onarandombox/MultiverseCore/test/utils/MVTestLogFormatter.java b/src/test/java/com/onarandombox/MultiverseCore/test/utils/MVTestLogFormatter.java index a26c235e..d2913261 100644 --- a/src/test/java/com/onarandombox/MultiverseCore/test/utils/MVTestLogFormatter.java +++ b/src/test/java/com/onarandombox/MultiverseCore/test/utils/MVTestLogFormatter.java @@ -21,6 +21,7 @@ import java.util.logging.LogRecord; public class MVTestLogFormatter extends Formatter { private static final DateFormat df = new SimpleDateFormat("HH:mm:ss"); + @Override public String format(LogRecord record) { StringBuilder ret = new StringBuilder(); diff --git a/src/test/java/com/onarandombox/MultiverseCore/test/utils/WorldCreatorMatcher.java b/src/test/java/com/onarandombox/MultiverseCore/test/utils/WorldCreatorMatcher.java index 529906fd..3d4ee8f2 100644 --- a/src/test/java/com/onarandombox/MultiverseCore/test/utils/WorldCreatorMatcher.java +++ b/src/test/java/com/onarandombox/MultiverseCore/test/utils/WorldCreatorMatcher.java @@ -28,6 +28,7 @@ public class WorldCreatorMatcher extends ArgumentMatcher { this.careAboutGenerators = doICare; } + @Override public boolean matches(Object creator) { Util.log("Checking world creators."); if (creator == null) {