mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 19:52:55 +01:00
90fe0d58a5
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: 897a0a23 SPIGOT-5753: Back PotionType by a minecraft registry 255b2aa1 SPIGOT-7080: Add World#locateNearestBiome ff984826 Remove javadoc.io doc links CraftBukkit Changes: 71b0135cc SPIGOT-5753: Back PotionType by a minecraft registry a6bcb8489 SPIGOT-7080: Add World#locateNearestBiome ad0e57434 SPIGOT-7502: CraftMetaItem - cannot deserialize BlockStateTag b3efca57a SPIGOT-6400: Use Mockito instead of InvocationHandler 38c599f9d PR-1272: Only allow one entity in CraftItem instead of two f065271ac SPIGOT-7498: ChunkSnapshot.getBlockEmittedLight() gets 64 blocks upper in Overworld Spigot Changes: e0e223fe Remove javadoc.io doc links
86 lines
4.7 KiB
Diff
86 lines
4.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
|
Date: Mon, 12 Jun 2023 14:42:49 -0400
|
|
Subject: [PATCH] Suppress Item Meta Validation Checks
|
|
|
|
In some cases ItemMeta could validate tags in an ItemStack. This suppresses those warnings and ignores reading the value.
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java
|
|
index c92981aedebe934cefa1c96a0328fb91fe17acbc..80138632e5216c71fe7060a59dbb2915e740a3c8 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java
|
|
@@ -68,13 +68,33 @@ public class CraftMetaArmor extends CraftMetaItem implements ArmorMeta {
|
|
CompoundTag trimCompound = tag.getCompound(TRIM.NBT);
|
|
|
|
if (trimCompound.contains(TRIM_MATERIAL.NBT, net.minecraft.nbt.Tag.TAG_STRING) && trimCompound.contains(TRIM_PATTERN.NBT, net.minecraft.nbt.Tag.TAG_STRING)) { // Paper - for now, ignore inline definitions of trim material & pattern
|
|
- TrimMaterial trimMaterial = Registry.TRIM_MATERIAL.get(NamespacedKey.fromString(trimCompound.getString(TRIM_MATERIAL.NBT)));
|
|
- TrimPattern trimPattern = Registry.TRIM_PATTERN.get(NamespacedKey.fromString(trimCompound.getString(TRIM_PATTERN.NBT)));
|
|
+ // Paper start
|
|
+ TrimMaterial trimMaterial = getRegistry(Registry.TRIM_MATERIAL, trimCompound.getString(TRIM_MATERIAL.NBT));
|
|
+ TrimPattern trimPattern = getRegistry(Registry.TRIM_PATTERN, trimCompound.getString(TRIM_PATTERN.NBT));
|
|
+ // Paper end
|
|
|
|
- this.trim = new ArmorTrim(trimMaterial, trimPattern);
|
|
+ this.trim = trimMaterial == null || trimPattern == null ? null : new ArmorTrim(trimMaterial, trimPattern); // Paper
|
|
}
|
|
}
|
|
}
|
|
+ // Paper start
|
|
+ public <T extends org.bukkit.Keyed> T getRegistry(Registry<T> registry, String value) {
|
|
+ if (value == null || value.isEmpty()) {
|
|
+ return null;
|
|
+ }
|
|
+ NamespacedKey namespacedKey = NamespacedKey.fromString(value);
|
|
+ if (namespacedKey == null) {
|
|
+ return null;
|
|
+ }
|
|
+
|
|
+ T registryValue = registry.get(namespacedKey);
|
|
+ if (registryValue == null) {
|
|
+ return null;
|
|
+ }
|
|
+
|
|
+ return registryValue;
|
|
+ }
|
|
+ // Paper end
|
|
|
|
CraftMetaArmor(Map<String, Object> map) {
|
|
super(map);
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
|
index f79ea76c0127b7b57ab0511afbed626a3b42fd05..3cea851c3f5389a5dd92601dfbef2975b2a5948b 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
|
@@ -489,7 +489,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
|
continue;
|
|
}
|
|
|
|
- Attribute attribute = CraftAttribute.stringToBukkit(attributeName);
|
|
+ // Paper start
|
|
+ Attribute attribute;
|
|
+ try {
|
|
+ attribute = CraftAttribute.stringToBukkit(attributeName);
|
|
+ } catch (IllegalArgumentException e) {
|
|
+ attribute = null;
|
|
+ }
|
|
+ // Paper end
|
|
if (attribute == null) {
|
|
continue;
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
|
index 9b9e20014042da4324c9f4babb05d8ba9513f81d..ee37b43060e0b102ab23cf318fd22041f5abaeb0 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
|
@@ -72,11 +72,13 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
|
CraftMetaSkull(CompoundTag tag) {
|
|
super(tag);
|
|
|
|
+ try { // Paper - Ignore invalid game profiles
|
|
if (tag.contains(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) {
|
|
this.setProfile(NbtUtils.readGameProfile(tag.getCompound(SKULL_OWNER.NBT)));
|
|
} else if (tag.contains(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_STRING) && !tag.getString(SKULL_OWNER.NBT).isEmpty()) {
|
|
this.setProfile(new GameProfile(Util.NIL_UUID, tag.getString(SKULL_OWNER.NBT)));
|
|
}
|
|
+ } catch (Exception ignored) {} // Paper
|
|
|
|
if (tag.contains(BLOCK_ENTITY_TAG.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) {
|
|
CompoundTag nbtTagCompound = tag.getCompound(BLOCK_ENTITY_TAG.NBT).copy();
|