diff options
author | Aikar <[email protected]> | 2020-07-05 03:07:02 -0400 |
---|---|---|
committer | Aikar <[email protected]> | 2020-07-05 03:07:02 -0400 |
commit | 166e52b57470327b48cb3911e935c6c1214c0f56 (patch) | |
tree | c28a1434a207f5264f3097e644c131606fec8c75 /Spigot-Server-Patches/0534-Update-itemstack-legacy-name-and-lore.patch | |
parent | 5a17ba07bbe153fbb7b73b3d8b8665ef2d21286c (diff) | |
download | Paper-166e52b57470327b48cb3911e935c6c1214c0f56.tar.gz Paper-166e52b57470327b48cb3911e935c6c1214c0f56.zip |
[CI-SKIP] [Auto] Rebuild Patches
A recent commit has been made that caused patches to be out of order, rebuilding
Diffstat (limited to 'Spigot-Server-Patches/0534-Update-itemstack-legacy-name-and-lore.patch')
-rw-r--r-- | Spigot-Server-Patches/0534-Update-itemstack-legacy-name-and-lore.patch | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/Spigot-Server-Patches/0534-Update-itemstack-legacy-name-and-lore.patch b/Spigot-Server-Patches/0534-Update-itemstack-legacy-name-and-lore.patch new file mode 100644 index 0000000000..6c779eae9e --- /dev/null +++ b/Spigot-Server-Patches/0534-Update-itemstack-legacy-name-and-lore.patch @@ -0,0 +1,91 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: William Blake Galbreath <[email protected]> +Date: Wed, 1 Jul 2020 11:57:40 -0500 +Subject: [PATCH] Update itemstack legacy name and lore + + +diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java +index 00725529793d6c2fe26ecacf900355b40e31dad8..53dc47ffb48cce2ef160d1d61766e6700f67c6e3 100644 +--- a/src/main/java/net/minecraft/server/ItemStack.java ++++ b/src/main/java/net/minecraft/server/ItemStack.java +@@ -83,6 +83,52 @@ public final class ItemStack { + list.sort((Comparator<? super NBTBase>) enchantSorter); // Paper + } catch (Exception ignored) {} + } ++ ++ private void processText() { ++ NBTTagCompound display = getSubTag("display"); ++ if (display != null) { ++ if (display.hasKeyOfType("Name", 8)) { ++ String json = display.getString("Name"); ++ if (json != null && json.contains("\u00A7")) { ++ try { ++ display.set("Name", convert(json)); ++ } catch (JsonParseException jsonparseexception) { ++ display.remove("Name"); ++ } ++ } ++ } ++ if (display.hasKeyOfType("Lore", 9)) { ++ NBTTagList list = display.getList("Lore", 8); ++ boolean legacy = false; ++ for (int index = 0; index < list.size(); index++) { ++ String json = list.getString(index); ++ if (json != null && json.contains("\u00A7")) { ++ legacy = true; ++ break; ++ } ++ } ++ if (legacy) { ++ NBTTagList lore = new NBTTagList(); ++ for (int index = 0; index < list.size(); index++) { ++ String json = list.getString(index); ++ try { ++ lore.add(convert(json)); ++ } catch (JsonParseException ignore) { ++ } ++ } ++ display.set("Lore", lore); ++ } ++ } ++ } ++ } ++ ++ private NBTTagString convert(String json) { ++ IChatBaseComponent component = IChatBaseComponent.ChatSerializer.jsonToComponent(json); ++ if (component != null) { ++ component = org.bukkit.craftbukkit.util.CraftChatMessage.fromString(component.getText())[0]; ++ } ++ return NBTTagString.create(org.bukkit.craftbukkit.util.CraftChatMessage.toJSON(component)); ++ } + // Paper end + + public ItemStack(IMaterial imaterial) { +@@ -128,6 +174,7 @@ public final class ItemStack { + // CraftBukkit start - make defensive copy as this data may be coming from the save thread + this.tag = (NBTTagCompound) nbttagcompound.getCompound("tag").clone(); + processEnchantOrder(this.tag); // Paper ++ processText(); // Paper + this.getItem().b(this.tag); + // CraftBukkit end + } +@@ -611,6 +658,7 @@ public final class ItemStack { + } + } + ++ @Nullable public NBTTagCompound getSubTag(String s) { return b(s); } // Paper - OBFHELPER + @Nullable + public NBTTagCompound b(String s) { + return this.tag != null && this.tag.hasKeyOfType(s, 10) ? this.tag.getCompound(s) : null; +diff --git a/src/main/java/net/minecraft/server/NBTTagString.java b/src/main/java/net/minecraft/server/NBTTagString.java +index 7ef2378311edd0645472d895cf3756426f25605d..a4747d5dc04ff1e1ec5fd35f927db7d452ea5ae4 100644 +--- a/src/main/java/net/minecraft/server/NBTTagString.java ++++ b/src/main/java/net/minecraft/server/NBTTagString.java +@@ -40,6 +40,7 @@ public class NBTTagString implements NBTBase { + this.data = s; + } + ++ public static NBTTagString create(String s) { return a(s); } // Paper - OBFHELPER + public static NBTTagString a(String s) { + return s.isEmpty() ? NBTTagString.b : new NBTTagString(s); + } |