From fb772923d5bbc6c53d18370f5bcd4083567f6035 Mon Sep 17 00:00:00 2001 From: Aikar Date: Sun, 28 Jun 2020 21:27:16 -0400 Subject: [PATCH] Improve Legacy Component serialization size Don't constantly send format: false for all formatting options when parent already has it false Fixes #3680 --- ...-Legacy-Component-serialization-size.patch | 56 +++++++++++++++++++ scripts/testServer.sh | 4 +- 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 Spigot-Server-Patches/0526-Improve-Legacy-Component-serialization-size.patch diff --git a/Spigot-Server-Patches/0526-Improve-Legacy-Component-serialization-size.patch b/Spigot-Server-Patches/0526-Improve-Legacy-Component-serialization-size.patch new file mode 100644 index 000000000..05f7e86c9 --- /dev/null +++ b/Spigot-Server-Patches/0526-Improve-Legacy-Component-serialization-size.patch @@ -0,0 +1,56 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Sun, 28 Jun 2020 19:08:41 -0400 +Subject: [PATCH] Improve Legacy Component serialization size + +Don't constantly send format: false for all formatting options when parent already +has it false + +diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java +index a423e3bf3906d3114af885c48d0b45d88d7e7d8b..3b79ae44c5ef790998915148db92c7161ae36ab6 100644 +--- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java ++++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java +@@ -45,6 +45,7 @@ public final class CraftChatMessage { + // Separate pattern with no group 3, new lines are part of previous string + private static final Pattern INCREMENTAL_PATTERN_KEEP_NEWLINES = Pattern.compile("(" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + "[0-9a-fk-orx])|((?:(?:https?):\\/\\/)?(?:[-\\w_\\.]{2,}\\.[a-z]{2,4}.*?(?=[\\.\\?!,;:]?(?:[" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + " ]|$))))", Pattern.CASE_INSENSITIVE); + // ChatColor.b does not explicitly reset, its more of empty ++ private static final ChatModifier EMPTY = ChatModifier.b; // Paper - OBFHELPER + private static final ChatModifier RESET = ChatModifier.b.setBold(false).setItalic(false).setUnderline(false).setStrikethrough(false).setRandom(false); + + private final List list = new ArrayList(); +@@ -66,6 +67,7 @@ public final class CraftChatMessage { + Matcher matcher = (keepNewlines ? INCREMENTAL_PATTERN_KEEP_NEWLINES : INCREMENTAL_PATTERN).matcher(message); + String match = null; + boolean needsAdd = false; ++ boolean hasReset = false; // Paper + while (matcher.find()) { + int groupId = 0; + while ((match = matcher.group(++groupId)) == null) { +@@ -111,7 +113,26 @@ public final class CraftChatMessage { + throw new AssertionError("Unexpected message format"); + } + } else { // Color resets formatting +- modifier = RESET.setColor(format); ++ // Paper start - improve legacy formatting ++ ChatModifier previous = modifier; ++ modifier = (!hasReset ? RESET : EMPTY).setColor(format); ++ hasReset = true; ++ if (previous.isBold()) { ++ modifier = modifier.setBold(false); ++ } ++ if (previous.isItalic()) { ++ modifier = modifier.setItalic(false); ++ } ++ if (previous.isRandom()) { ++ modifier = modifier.setRandom(false); ++ } ++ if (previous.isStrikethrough()) { ++ modifier = modifier.setStrikethrough(false); ++ } ++ if (previous.isUnderlined()) { ++ modifier = modifier.setUnderline(false); ++ } ++ // Paper end + } + needsAdd = true; + break; diff --git a/scripts/testServer.sh b/scripts/testServer.sh index 1ce78a332..834e4a917 100755 --- a/scripts/testServer.sh +++ b/scripts/testServer.sh @@ -87,7 +87,9 @@ fi # JVM FLAGS # -cp "$jar" paper.jar +if [ -f "$jar" ]; then + cp "$jar" paper.jar +fi baseargs="-server -Xms${PAPER_MIN_TEST_MEMORY:-512M} -Xmx${PAPER_TEST_MEMORY:-2G} -Dfile.encoding=UTF-8 -XX:MaxGCPauseMillis=150 -XX:+UseG1GC " baseargs="$baseargs -DIReallyKnowWhatIAmDoingISwear=1 " baseargs="$baseargs -XX:+UnlockExperimentalVMOptions -XX:G1NewSizePercent=40 -XX:G1MaxNewSizePercent=60 "