aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0377-Improve-Legacy-Component-serialization-size.patch
diff options
context:
space:
mode:
authorSpottedleaf <[email protected]>2024-07-17 10:24:53 -0700
committerSpottedleaf <[email protected]>2024-07-17 10:28:32 -0700
commit00b949f1bbbf444e2b5e7b8de7c9b14fbd2133c6 (patch)
tree82639515bc5e9ae00c1e639e72137ed51e1ac688 /patches/server/0377-Improve-Legacy-Component-serialization-size.patch
parent967f98aa81da851740aeb429778e46159fd188df (diff)
downloadPaper-00b949f1bbbf444e2b5e7b8de7c9b14fbd2133c6.tar.gz
Paper-00b949f1bbbf444e2b5e7b8de7c9b14fbd2133c6.zip
Remove Moonrise utils to MCUtils, remove duplicated/unused utils
Diffstat (limited to 'patches/server/0377-Improve-Legacy-Component-serialization-size.patch')
-rw-r--r--patches/server/0377-Improve-Legacy-Component-serialization-size.patch56
1 files changed, 56 insertions, 0 deletions
diff --git a/patches/server/0377-Improve-Legacy-Component-serialization-size.patch b/patches/server/0377-Improve-Legacy-Component-serialization-size.patch
new file mode 100644
index 0000000000..5a1da5d1f0
--- /dev/null
+++ b/patches/server/0377-Improve-Legacy-Component-serialization-size.patch
@@ -0,0 +1,56 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Aikar <[email protected]>
+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 1b552b3f05ac7fc44450de4b1ec78907a0f62424..3a550f2bd1366ae89c69a0527404b0449e6d9cf7 100644
+--- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
++++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
+@@ -48,6 +48,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 Style EMPTY = Style.EMPTY.withItalic(false); // Paper - Improve Legacy Component serialization size
+ private static final Style RESET = Style.EMPTY.withBold(false).withItalic(false).withUnderlined(false).withStrikethrough(false).withObfuscated(false);
+
+ private final List<Component> list = new ArrayList<Component>();
+@@ -69,6 +70,7 @@ public final class CraftChatMessage {
+ Matcher matcher = (keepNewlines ? StringMessage.INCREMENTAL_PATTERN_KEEP_NEWLINES : StringMessage.INCREMENTAL_PATTERN).matcher(message);
+ String match = null;
+ boolean needsAdd = false;
++ boolean hasReset = false; // Paper - Improve Legacy Component serialization size
+ while (matcher.find()) {
+ int groupId = 0;
+ while ((match = matcher.group(++groupId)) == null) {
+@@ -114,7 +116,26 @@ public final class CraftChatMessage {
+ throw new AssertionError("Unexpected message format");
+ }
+ } else { // Color resets formatting
+- this.modifier = StringMessage.RESET.withColor(format);
++ // Paper start - Improve Legacy Component serialization size
++ Style previous = modifier;
++ modifier = (!hasReset ? RESET : EMPTY).withColor(format);
++ hasReset = true;
++ if (previous.isBold()) {
++ modifier = modifier.withBold(false);
++ }
++ if (previous.isItalic()) {
++ modifier = modifier.withItalic(false);
++ }
++ if (previous.isObfuscated()) {
++ modifier = modifier.withObfuscated(false);
++ }
++ if (previous.isStrikethrough()) {
++ modifier = modifier.withStrikethrough(false);
++ }
++ if (previous.isUnderlined()) {
++ modifier = modifier.withUnderlined(false);
++ }
++ // Paper end - Improve Legacy Component serialization size
+ }
+ needsAdd = true;
+ break;