Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
4af62f6d1d
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 2d009e64 Update SnakeYAML javadoc link b4fd213c Switch Player#updateInventory deprecation for internal API annotation CraftBukkit Changes: f3b2b2210 SPIGOT-7376: Exception with getBlockData when hasBlockData is false 725545630 SPIGOT-7375: Fix crash breeding certain entities b9873b0d4 Update Brigadier version with fix 68b320562 SPIGOT-7266: Found typo in CraftBukkit package 98b4d2ff8 SPIGOT-7372, SPIGOT-7373: Signs can't be edited, issues with SignChangeEvent 5f7bd4d78 SPIGOT-7371: Sign does not open edit text on placement b4cf99d24 SPIGOT-7371: Fix editing signs with API a2b6c2744 PR-1200: Implement open sign by side a345bb940 SPIGOT-7368: Downgrade SpecialSource version Spigot Changes: 723951c3 Rebuild patches b655c57d Drop old collision API deprecated since 1.9.4 55b0fed4 Rebuild patches
64 Zeilen
3.2 KiB
Diff
64 Zeilen
3.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
|
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);
|
|
}
|
|
|