aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0431-Update-itemstack-legacy-name-and-lore.patch
diff options
context:
space:
mode:
authorSpottedleaf <[email protected]>2023-06-08 16:12:34 -0700
committerSpottedleaf <[email protected]>2023-06-08 16:12:34 -0700
commit619d7c93d80c4fecf7b3db9f2750e44a0ce611d2 (patch)
tree0599c640166a0b74a12e074236ba5c1162b094db /patches/server/0431-Update-itemstack-legacy-name-and-lore.patch
parentcc491a396e411f58b2c7bb753e93b2144e886682 (diff)
downloadPaper-619d7c93d80c4fecf7b3db9f2750e44a0ce611d2.tar.gz
Paper-619d7c93d80c4fecf7b3db9f2750e44a0ce611d2.zip
Add in some patches
Diffstat (limited to 'patches/server/0431-Update-itemstack-legacy-name-and-lore.patch')
-rw-r--r--patches/server/0431-Update-itemstack-legacy-name-and-lore.patch63
1 files changed, 0 insertions, 63 deletions
diff --git a/patches/server/0431-Update-itemstack-legacy-name-and-lore.patch b/patches/server/0431-Update-itemstack-legacy-name-and-lore.patch
deleted file mode 100644
index c8f81c40b4..0000000000
--- a/patches/server/0431-Update-itemstack-legacy-name-and-lore.patch
+++ /dev/null
@@ -1,63 +0,0 @@
-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/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
-index cbda9f0fd0b14062c5b0290b2da571cff2df13e5..22bc138601247d4f14d84b54771020143920fc38 100644
---- a/src/main/java/net/minecraft/world/item/ItemStack.java
-+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
-@@ -171,6 +171,44 @@ public final class ItemStack {
- list.sort((java.util.Comparator<? super net.minecraft.nbt.Tag>) enchantSorter); // Paper
- } catch (Exception ignored) {}
- }
-+
-+ private void processText() {
-+ CompoundTag display = getTagElement("display");
-+ if (display != null) {
-+ if (display.contains("Name", 8)) {
-+ String json = display.getString("Name");
-+ if (json != null && json.contains("\u00A7")) {
-+ try {
-+ display.put("Name", convert(json));
-+ } catch (com.google.gson.JsonParseException jsonparseexception) {
-+ display.remove("Name");
-+ }
-+ }
-+ }
-+ if (display.contains("Lore", 9)) {
-+ ListTag list = display.getList("Lore", 8);
-+ for (int index = 0; index < list.size(); index++) {
-+ String json = list.getString(index);
-+ if (json != null && json.contains("\u00A7")) { // Only try if it has legacy in the unparsed json
-+ try {
-+ list.set(index, convert(json));
-+ } catch (com.google.gson.JsonParseException e) {
-+ list.set(index, net.minecraft.nbt.StringTag.valueOf(org.bukkit.craftbukkit.util.CraftChatMessage.toJSON(net.minecraft.network.chat.Component.literal(""))));
-+ }
-+ }
-+ }
-+ }
-+ }
-+ }
-+
-+ private net.minecraft.nbt.StringTag convert(String json) {
-+ Component component = Component.Serializer.fromJson(json);
-+ 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(literalContents.text())[0];
-+ }
-+ return net.minecraft.nbt.StringTag.valueOf(org.bukkit.craftbukkit.util.CraftChatMessage.toJSON(component));
-+ }
- // Paper end
-
- public ItemStack(ItemLike item) {
-@@ -222,6 +260,7 @@ public final class ItemStack {
- this.tag = nbttagcompound.getCompound("tag").copy();
- // CraftBukkit end
- this.processEnchantOrder(this.tag); // Paper
-+ this.processText(); // Paper
- this.getItem().verifyTagAfterLoad(this.tag);
- }
-