Misc fixes (#7883)

This commit is contained in:
Owen 2022-06-08 09:03:33 -04:00 committed by GitHub
parent 301cf577c2
commit 2259098789
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 10 deletions

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Update itemstack legacy name and lore
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
index db8db2ab4c81cbf6eb4f21b8916e487c4e2d51fb..7c41d18004bd4ef980e0c142d59a5563e77f257f 100644
index db8db2ab4c81cbf6eb4f21b8916e487c4e2d51fb..8df392c0c607e4775debdac97ad564ddcbaf0607 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -168,6 +168,44 @@ public final class ItemStack {
@ -44,9 +44,9 @@ index db8db2ab4c81cbf6eb4f21b8916e487c4e2d51fb..7c41d18004bd4ef980e0c142d59a5563
+
+ private net.minecraft.nbt.StringTag convert(String json) {
+ Component component = Component.Serializer.fromJson(json);
+ if (component instanceof TextComponent && component.getContents().contains("\u00A7") && component.getSiblings().isEmpty()) {
+ if (component.getContents() instanceof net.minecraft.network.chat.contents.LiteralContents literalContents && literalContents.text().contains("\u00A7") && component.getSiblings().isEmpty()) {
+ // Only convert if the root component is a single comp with legacy in it, don't convert already normal components
+ component = org.bukkit.craftbukkit.util.CraftChatMessage.fromString(component.getContents())[0];
+ component = org.bukkit.craftbukkit.util.CraftChatMessage.fromString(literalContents.text())[0];
+ }
+ return net.minecraft.nbt.StringTag.valueOf(org.bukkit.craftbukkit.util.CraftChatMessage.toJSON(component));
+ }