mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-01 12:41:50 +01:00
1f32290b68
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing CraftBukkit Changes: ff2b9440f SPIGOT-6304: Removed the detection of legacy text based on color codes
56 lines
3.3 KiB
Diff
56 lines
3.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
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 1582a799e456402453c43c2e0c6b8a194951a9dd..ede1cffb5de4f958ecf57b6c62a0d63896274746 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
|
@@ -46,6 +46,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.a.setItalic(false); // Paper - OBFHELPER
|
|
private static final ChatModifier RESET = ChatModifier.a.setBold(false).setItalic(false).setUnderline(false).setStrikethrough(false).setRandom(false);
|
|
|
|
private final List<IChatBaseComponent> list = new ArrayList<IChatBaseComponent>();
|
|
@@ -67,6 +68,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) {
|
|
@@ -112,7 +114,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;
|