Fix rgb color codes getting stripped in some cases (#5076)

This commit is contained in:
Josh Roy 2022-08-18 13:29:12 -04:00 committed by GitHub
parent 4ab3e20a0c
commit ca4077b204
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 4 deletions

View File

@ -29,6 +29,10 @@ dependencies {
} }
} }
test {
testLogging.showStandardStreams = true
}
shadowJar { shadowJar {
dependencies { dependencies {
include (dependency('io.papermc:paperlib')) include (dependency('io.papermc:paperlib'))

View File

@ -226,12 +226,12 @@ public final class FormatUtil {
final EnumSet<ChatColor> strip = EnumSet.complementOf(supported); final EnumSet<ChatColor> strip = EnumSet.complementOf(supported);
final boolean rgb = user.isAuthorized(permBase + ".rgb"); final boolean rgb = user.isAuthorized(permBase + ".rgb");
if (!supported.isEmpty() || rgb) {
message = replaceColor(message, supported, rgb);
}
if (!strip.isEmpty()) { if (!strip.isEmpty()) {
message = stripColor(message, strip); message = stripColor(message, strip);
} }
if (!supported.isEmpty() || rgb) {
message = replaceColor(message, supported, rgb);
}
return message; return message;
} }

View File

@ -192,7 +192,7 @@ public final class VersionUtil {
if (!Bukkit.getName().equals("Essentials Fake Server")) { if (!Bukkit.getName().equals("Essentials Fake Server")) {
throw new IllegalArgumentException(string + " is not in valid version format. e.g. 1.8.8-R0.1"); throw new IllegalArgumentException(string + " is not in valid version format. e.g. 1.8.8-R0.1");
} }
matcher = VERSION_PATTERN.matcher(v1_14_R01.toString()); matcher = VERSION_PATTERN.matcher(v1_16_1_R01.toString());
Preconditions.checkArgument(matcher.matches(), string + " is not in valid version format. e.g. 1.8.8-R0.1"); Preconditions.checkArgument(matcher.matches(), string + " is not in valid version format. e.g. 1.8.8-R0.1");
} }

View File

@ -18,6 +18,17 @@ public class FormatUtilTest {
checkFormatPerms("§aT§Aest", "§aT§Aest", "color"); checkFormatPerms("§aT§Aest", "§aT§Aest", "color");
} }
@Test
public void testFormatHexColors() {
checkFormatPerms("&#ffffff", "&#ffffff");
checkFormatPerms("&#ffffff", "§x§f§f§f§f§f§f", "color", "rgb");
checkFormatPerms("&#ff0000test", "§x§f§f§0§0§0§0test", "rgb");
checkFormatPerms("&#ff0000test", "§x§f§f§0§0§0§0test", "rgb", "color");
checkFormatPerms("&#ff0000test", "§x§f§f§0§0§0§0test", "rgb", "white");
checkFormatPerms("&#ff0000test", "§x§f§f§0§0§0§0test", "rgb", "black");
checkFormatPerms("&#ff0000test", "§x§f§f§0§0§0§0test", "rgb", "black", "white");
}
@Test @Test
public void testFormatCategoryPerms() { public void testFormatCategoryPerms() {
checkFormatPerms("Test", "Test"); checkFormatPerms("Test", "Test");