legacy formatting is worse than walking around in wet socks

This commit is contained in:
Riley Park 2021-03-09 09:27:12 -08:00
parent 7f72c4675b
commit f597fea0de
No known key found for this signature in database
GPG Key ID: D831AF236C834E45
2 changed files with 13 additions and 7 deletions

View File

@ -424,10 +424,10 @@ index 0000000000000000000000000000000000000000..64fcc77eb2ce8979ae756696d98f1d3a
+}
diff --git a/src/main/java/io/papermc/paper/adventure/PaperAdventure.java b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java
new file mode 100644
index 0000000000000000000000000000000000000000..3c6de21ffa90c644760a412eb6624d18510e0a53
index 0000000000000000000000000000000000000000..c45d48cef53476fa1602cebaa57c72894bba10d3
--- /dev/null
+++ b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java
@@ -0,0 +1,334 @@
@@ -0,0 +1,340 @@
+package io.papermc.paper.adventure;
+
+import com.mojang.brigadier.exceptions.CommandSyntaxException;
@ -463,6 +463,7 @@ index 0000000000000000000000000000000000000000..3c6de21ffa90c644760a412eb6624d18
+import net.minecraft.server.NBTTagList;
+import net.minecraft.server.NBTTagString;
+import net.minecraft.server.SoundCategory;
+import org.bukkit.ChatColor;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
+
@ -609,6 +610,11 @@ index 0000000000000000000000000000000000000000..3c6de21ffa90c644760a412eb6624d18
+ return IChatBaseComponent.ChatSerializer.componentToJson(component);
+ }
+
+ // thank you for being worse than wet socks, Bukkit
+ public static String superHackyLegacyRepresentationOfComponent(final Component component, final String string) {
+ return LEGACY_SECTION_UXRC.serialize(component) + ChatColor.getLastColors(string);
+ }
+
+ // BossBar
+
+ public static BossBattle.BarColor asVanilla(final BossBar.Color color) {
@ -2032,20 +2038,20 @@ index 3ea267a786f8f047767cace4dc59951b28a615a6..19cdff6eebb7c07d75b515dfa0d47bb7
player.activeContainer.addSlotListener(player);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 4bfdd900bae4c886360b24fcc8563e1d2e73ebf0..8e5fd03036282a9f329529a1f355ae73486651af 100644
index 4bfdd900bae4c886360b24fcc8563e1d2e73ebf0..9963de00a8143050d423bd45a7e2b92a441e6083 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -240,14 +240,39 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override
public String getDisplayName() {
+ if(true) return io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.serialize(this.getHandle().adventure$displayName); // Paper
+ if(true) return io.papermc.paper.adventure.PaperAdventure.superHackyLegacyRepresentationOfComponent(this.getHandle().adventure$displayName, this.getHandle().displayName); // Paper
return getHandle().displayName;
}
@Override
public void setDisplayName(final String name) {
+ this.getHandle().adventure$displayName = name != null ? io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.deserialize(name) : net.kyori.adventure.text.Component.text(this.getName()); if (true) return; // Paper
+ this.getHandle().adventure$displayName = name != null ? io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.deserialize(name) : net.kyori.adventure.text.Component.text(this.getName()); // Paper
getHandle().displayName = name == null ? getName() : name;
}

View File

@ -64,7 +64,7 @@ index 772ca6256964692a2b9c12e2edc532d2a8f51f7b..71168d9d0252e93253fa3b3f0bface3a
// Paper end
packetdataserializer.a(this.b);
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index e0805f4e295ff3866e7689214cfd922267a98008..4f3511447473f50336a1deea62958834cb3d4af1 100644
index 41bb934dda000cf3abd062dfcd12eea73afb86e5..02805bada2ca3e587dc45592ce4f4eafd57e0e8b 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1,5 +1,6 @@
@ -170,4 +170,4 @@ index e0805f4e295ff3866e7689214cfd922267a98008..4f3511447473f50336a1deea62958834
+
@Override
public String getDisplayName() {
if(true) return io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.serialize(this.getHandle().adventure$displayName); // Paper
if(true) return io.papermc.paper.adventure.PaperAdventure.superHackyLegacyRepresentationOfComponent(this.getHandle().adventure$displayName, this.getHandle().displayName); // Paper