aboutsummaryrefslogtreecommitdiffhomepage
path: root/removed-patches-1-20-5
diff options
context:
space:
mode:
authorJake Potrebic <[email protected]>2024-04-23 23:44:48 -0700
committerJake Potrebic <[email protected]>2024-04-23 23:44:48 -0700
commitcc4614854ae884f8c0585af1b6cfb9a0e99a22e0 (patch)
tree48d81b5c78e13b4daca35b56701c614aaa58b6e5 /removed-patches-1-20-5
parent9079c90d22dc5ef2a760072ea18dd8ea216910be (diff)
downloadPaper-cc4614854ae884f8c0585af1b6cfb9a0e99a22e0.tar.gz
Paper-cc4614854ae884f8c0585af1b6cfb9a0e99a22e0.zip
405
Diffstat (limited to 'removed-patches-1-20-5')
-rw-r--r--removed-patches-1-20-5/0405-Support-old-UUID-format-for-NBT.patch66
-rw-r--r--removed-patches-1-20-5/0410-Update-itemstack-legacy-name-and-lore.patch63
2 files changed, 129 insertions, 0 deletions
diff --git a/removed-patches-1-20-5/0405-Support-old-UUID-format-for-NBT.patch b/removed-patches-1-20-5/0405-Support-old-UUID-format-for-NBT.patch
new file mode 100644
index 0000000000..c754088358
--- /dev/null
+++ b/removed-patches-1-20-5/0405-Support-old-UUID-format-for-NBT.patch
@@ -0,0 +1,66 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Aikar <[email protected]>
+Date: Mon, 29 Jun 2020 03:26:17 -0400
+Subject: [PATCH] Support old UUID format for NBT
+
+We have stored UUID in plenty of places that did not get DFU'd
+
+So just look for old format and load it if it exists.
+
+diff --git a/src/main/java/net/minecraft/nbt/CompoundTag.java b/src/main/java/net/minecraft/nbt/CompoundTag.java
+index c7945686a4ee50d7a9d5f1173aa90e456f68b410..23916b011ed0645ab284fb080c9555921290d875 100644
+--- a/src/main/java/net/minecraft/nbt/CompoundTag.java
++++ b/src/main/java/net/minecraft/nbt/CompoundTag.java
+@@ -232,6 +232,12 @@ public class CompoundTag implements Tag {
+ }
+
+ public void putUUID(String key, UUID value) {
++ // Paper start - Support old UUID format
++ if (this.contains(key + "Most", net.minecraft.nbt.Tag.TAG_ANY_NUMERIC) && this.contains(key + "Least", net.minecraft.nbt.Tag.TAG_ANY_NUMERIC)) {
++ this.tags.remove(key + "Most");
++ this.tags.remove(key + "Least");
++ }
++ // Paper end - Support old UUID format
+ this.tags.put(key, NbtUtils.createUUID(value));
+ }
+
+@@ -240,10 +246,20 @@ public class CompoundTag implements Tag {
+ * You must use {@link #hasUUID(String)} before or else it <b>will</b> throw an NPE.
+ */
+ public UUID getUUID(String key) {
++ // Paper start - Support old UUID format
++ if (!contains(key, 11) && this.contains(key + "Most", net.minecraft.nbt.Tag.TAG_ANY_NUMERIC) && this.contains(key + "Least", net.minecraft.nbt.Tag.TAG_ANY_NUMERIC)) {
++ return new UUID(this.getLong(key + "Most"), this.getLong(key + "Least"));
++ }
++ // Paper end - Support old UUID format
+ return NbtUtils.loadUUID(this.get(key));
+ }
+
+ public boolean hasUUID(String key) {
++ // Paper start - Support old UUID format
++ if (this.contains(key + "Most", net.minecraft.nbt.Tag.TAG_ANY_NUMERIC) && this.contains(key + "Least", net.minecraft.nbt.Tag.TAG_ANY_NUMERIC)) {
++ return true;
++ }
++ // Paper end - Support old UUID format
+ Tag tag = this.get(key);
+ return tag != null && tag.getType() == IntArrayTag.TYPE && ((IntArrayTag)tag).getAsIntArray().length == 4;
+ }
+diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java
+index 3e395d575fab2348cd30a88511a194aba2d8e4ba..f3b11b08358fdd93464cd19b05047e10727a5799 100644
+--- a/src/main/java/net/minecraft/nbt/NbtUtils.java
++++ b/src/main/java/net/minecraft/nbt/NbtUtils.java
+@@ -65,6 +65,14 @@ public final class NbtUtils {
+ @Nullable
+ public static GameProfile readGameProfile(CompoundTag nbt) {
+ UUID uUID = nbt.hasUUID("Id") ? nbt.getUUID("Id") : Util.NIL_UUID;
++ // Paper start - Support old UUID format
++ if (nbt.contains("Id", Tag.TAG_STRING)) {
++ try {
++ uUID = UUID.fromString(nbt.getString("Id"));
++ } catch (IllegalArgumentException ignored){
++ }
++ }
++ // Paper end - Support old UUID format
+ String string = nbt.getString("Name");
+
+ try {
diff --git a/removed-patches-1-20-5/0410-Update-itemstack-legacy-name-and-lore.patch b/removed-patches-1-20-5/0410-Update-itemstack-legacy-name-and-lore.patch
new file mode 100644
index 0000000000..49a60bd241
--- /dev/null
+++ b/removed-patches-1-20-5/0410-Update-itemstack-legacy-name-and-lore.patch
@@ -0,0 +1,63 @@
+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 0a3fec9b82a4d744f9046aebe30f80bb6e56c500..4a6e128c62c890c34b62f826d586ae6a424e7f01 100644
+--- a/src/main/java/net/minecraft/world/item/ItemStack.java
++++ b/src/main/java/net/minecraft/world/item/ItemStack.java
+@@ -196,6 +196,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", net.minecraft.nbt.Tag.TAG_STRING)) {
++ 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", net.minecraft.nbt.Tag.TAG_LIST)) {
++ ListTag list = display.getList("Lore", net.minecraft.nbt.Tag.TAG_STRING);
++ 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 final net.minecraft.network.chat.contents.PlainTextContents plainTextContents && plainTextContents.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(plainTextContents.text())[0];
++ }
++ return net.minecraft.nbt.StringTag.valueOf(org.bukkit.craftbukkit.util.CraftChatMessage.toJSON(component));
++ }
+ // Paper end
+
+ public ItemStack(ItemLike item) {
+@@ -245,6 +283,7 @@ public final class ItemStack {
+ if (nbttagcompound.contains("tag", 10)) {
+ this.tag = nbttagcompound.getCompound("tag").copy();
+ this.processEnchantOrder(this.tag); // Paper
++ this.processText(); // Paper - Update itemstack legacy name and lore
+ this.getItem().verifyTagAfterLoad(this.tag);
+ }
+