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 0eaa2dd444
commit a597c7d687
2 changed files with 9 additions and 3 deletions

View file

@ -463,6 +463,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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..00000000000000000000000000000000
+ 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) {
@ -2039,13 +2045,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@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

@ -170,4 +170,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
@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