diff --git a/Essentials/src/com/earth2me/essentials/utils/FormatUtil.java b/Essentials/src/com/earth2me/essentials/utils/FormatUtil.java index bc9f916c753..d6f1f281154 100644 --- a/Essentials/src/com/earth2me/essentials/utils/FormatUtil.java +++ b/Essentials/src/com/earth2me/essentials/utils/FormatUtil.java @@ -111,6 +111,11 @@ public static String formatString(final IUser user, final String permBase, Strin if (user.isAuthorized(permBase + ".format")) { supported.addAll(FORMATS); } + for (ChatColor chatColor : ChatColor.values()) { + if (user.isAuthorized(permBase + "." + chatColor.getChar())) { + supported.add(chatColor); + } + } EnumSet strip = EnumSet.complementOf(supported); if (!supported.isEmpty()) { diff --git a/Essentials/test/com/earth2me/essentials/utils/FormatUtilTest.java b/Essentials/test/com/earth2me/essentials/utils/FormatUtilTest.java index a6377b67b3a..fc053c29855 100644 --- a/Essentials/test/com/earth2me/essentials/utils/FormatUtilTest.java +++ b/Essentials/test/com/earth2me/essentials/utils/FormatUtilTest.java @@ -44,6 +44,20 @@ public void testFormatCategoryPerms() { checkFormatPerms("§f§ltest", "§f§ltest", "color", "format"); } + public void testFormatCodePerms() { + checkFormatPerms("&1Te&2st", "&1Te&2st"); + checkFormatPerms("§1Te§2st", "Test"); + + checkFormatPerms("&1Te&2st", "§1Te&2st", "code.1"); + checkFormatPerms("§1Te§2st", "§1Test", "code.1"); + + checkFormatPerms("&1Te&2st", "&1Te§2st", "code.2"); + checkFormatPerms("§1Te§2st", "Te§2st", "code.2"); + + checkFormatPerms("&1Te&2st", "§1Te§2st", "code.1", "code.2"); + checkFormatPerms("§1Te§2st", "§1Te§2st", "code.1", "code.2"); + } + private void checkFormatPerms(String input, String expectedOutput, String... perms) { IUser user = mock(IUser.class); for (String perm : perms) {