Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
9df2066642
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: dfe1fb48 PR-906: Add missing MinecraftExperimental annotation to Bundles 825ab30d PR-905: Add missing MapCursor.Type and update documentation e03d10e6 PR-903: Make BARRIER Waterlogged 1961ead6 PR-898: Use Java Consumer instead of Bukkit Consumer CraftBukkit Changes: f71a799f0 Make BARRIER Waterlogged 172f76a45 Upgrade specialsource-maven-plugin f0702775c SPIGOT-7486: Alternate approach to null profile names 069495671 SPIGOT-7485: Allow air entity items since required for Vanilla logic 5dfd33dc2 SPIGOT-7484: Cancelling PlayerEditBookEvent does not update client's book contents 02d490788 PR-1250: Standardize and centralize Bukkit / Minecraft registry conversion 9024a09b9 PR-1251: Use Java Consumer instead of Bukkit Consumer 6d4b25bf1 Increase diff stability
87 Zeilen
4.7 KiB
Diff
87 Zeilen
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 9b266dd16dbf863dcf08783ec665dd237b048793..4bfa08fe53604145a7b1c4e7630bf46519223b59 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();
|