aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJake Potrebic <[email protected]>2024-12-08 11:58:09 -0800
committerJake Potrebic <[email protected]>2024-12-08 11:58:09 -0800
commitd6f007c1e08093d2f66c601d84ad24ce6fb0361b (patch)
tree0ed4324e6d0446d2292e129a2953abdb5eafcb07
parentc715869d02d3266af24d3eef116d7b3a0e270051 (diff)
downloadPaper-feature/Holderable.tar.gz
Paper-feature/Holderable.zip
remove unneeded unwrapAndConvertHolder callfeature/Holderable
-rw-r--r--patches/server/0463-Add-RegistryAccess-for-managing-Registries.patch22
-rw-r--r--patches/server/0906-Fixup-NamespacedKey-handling.patch15
-rw-r--r--patches/server/0944-improve-checking-handled-tags-in-itemmeta.patch8
3 files changed, 16 insertions, 29 deletions
diff --git a/patches/server/0463-Add-RegistryAccess-for-managing-Registries.patch b/patches/server/0463-Add-RegistryAccess-for-managing-Registries.patch
index 7ff6fc3672..8eb6488c4a 100644
--- a/patches/server/0463-Add-RegistryAccess-for-managing-Registries.patch
+++ b/patches/server/0463-Add-RegistryAccess-for-managing-Registries.patch
@@ -918,7 +918,7 @@ index 73d8814ee2424a8336a09536f9ea8f5cf23ef85a..f9e33ec8ba7adaf729fecabc093aece2
return null;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java
-index 0d091c7b328fb70a82f5b5ded7dec61b7cd3d59a..7df1ce34c60ce14beb6acf8135a587e7b4e959b1 100644
+index 0d091c7b328fb70a82f5b5ded7dec61b7cd3d59a..f3b971d50542f925da54aedd0a2abc0754158a3e 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java
@@ -93,13 +93,40 @@ public class CraftRegistry<B extends Keyed, M> implements Registry<B> {
@@ -946,16 +946,16 @@ index 0d091c7b328fb70a82f5b5ded7dec61b7cd3d59a..7df1ce34c60ce14beb6acf8135a587e7
+ public static <B extends Keyed, M> B minecraftHolderToBukkit(final Holder<M> minecraft, final Registry<B> bukkitRegistry) {
+ Preconditions.checkArgument(minecraft != null);
+
-+ final B bukkit;
-+ if (bukkitRegistry instanceof final CraftRegistry<?, ?> craftRegistry && craftRegistry.supportsDirectHolders()) {
-+ bukkit = minecraft.unwrap().map(
-+ key -> bukkitRegistry.get(io.papermc.paper.util.MCUtil.fromResourceKey(key)),
-+ value -> ((CraftRegistry<B, M>) bukkitRegistry).convertDirectHolder(minecraft)
-+ );
-+ } else {
-+ Preconditions.checkArgument(minecraft.kind() == Holder.Kind.REFERENCE, "Cannot convert direct holder to bukkit representation");
-+ bukkit = bukkitRegistry.get(io.papermc.paper.util.MCUtil.fromResourceKey(minecraft.unwrapKey().orElseThrow()));
-+ }
++ final B bukkit = switch (minecraft) {
++ case final Holder.Direct<M> direct -> {
++ if (!(bukkitRegistry instanceof final CraftRegistry<?, ?> craftRegistry) || !craftRegistry.supportsDirectHolders()) {
++ throw new IllegalArgumentException("Cannot convert direct holder to bukkit representation");
++ }
++ yield ((CraftRegistry<B, M>) bukkitRegistry).convertDirectHolder(direct);
++ }
++ case final Holder.Reference<M> reference -> bukkitRegistry.get(io.papermc.paper.util.MCUtil.fromResourceKey(reference.key()));
++ default -> throw new IllegalArgumentException("Unknown holder: " + minecraft);
++ };
Preconditions.checkArgument(bukkit != null);
return bukkit;
diff --git a/patches/server/0906-Fixup-NamespacedKey-handling.patch b/patches/server/0906-Fixup-NamespacedKey-handling.patch
index beae8a9f42..8da9a19029 100644
--- a/patches/server/0906-Fixup-NamespacedKey-handling.patch
+++ b/patches/server/0906-Fixup-NamespacedKey-handling.patch
@@ -18,7 +18,7 @@ index 90b82ad996b2b85628c9a5ddeef9410150b7f70c..5fd22a80e9d05afbea273471cee99173
public static NamespacedKey minecraftToBukkitKey(ResourceKey<LootTable> minecraft) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java
-index 6033035e87d004997fee62801942c57628b91e6d..47951e62aa384542c3ba92e1ef6162031d05a300 100644
+index e23e92331ae305e1cc83a1d478b71a9478f8e8c6..624f627ead8d6a811a5f81ea8a4f2497d3115bbb 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java
@@ -159,6 +159,19 @@ public class CraftRegistry<B extends Keyed, M> implements Registry<B> {
@@ -96,19 +96,6 @@ index 1c1a2d66d1ebcbe2ded732e759d0f9d471d43b56..eb44c19f6af624df458981e46c73a643
if (color != null && pattern != null) {
this.patterns.add(new Pattern(color, pattern));
-diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMusicInstrument.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMusicInstrument.java
-index 478059eb3ad76b41e6a20e9b489a2a4fb19e7c7c..76a3e4893cbdba903a712d6db1d30b9c644795be 100644
---- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMusicInstrument.java
-+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMusicInstrument.java
-@@ -30,7 +30,7 @@ public class CraftMetaMusicInstrument extends CraftMetaItem implements MusicInst
- super(tag);
-
- getOrEmpty(tag, CraftMetaMusicInstrument.GOAT_HORN_INSTRUMENT).ifPresent((instrument) -> {
-- this.instrument = CraftMusicInstrument.minecraftHolderToBukkit(instrument);
-+ this.instrument = org.bukkit.craftbukkit.CraftRegistry.unwrapAndConvertHolder(org.bukkit.Registry.INSTRUMENT, instrument).orElse(null); // Paper - fix upstream not handling inlined instrument
- });
- }
-
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaShield.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaShield.java
index c8eec04685456d89cb41466cddcc3975d0ceeb29..bcd6cc29e4e621805cbd923d747f652ced240c6d 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaShield.java
diff --git a/patches/server/0944-improve-checking-handled-tags-in-itemmeta.patch b/patches/server/0944-improve-checking-handled-tags-in-itemmeta.patch
index 32bf88b7e5..10f39aa866 100644
--- a/patches/server/0944-improve-checking-handled-tags-in-itemmeta.patch
+++ b/patches/server/0944-improve-checking-handled-tags-in-itemmeta.patch
@@ -456,7 +456,7 @@ index 4941e0afff8df5f10f06c715b54bf58eb86051c5..566d893a413fd04b99e83dc2da8fe958
getOrEmpty(tag, CraftMetaFirework.FIREWORKS).ifPresent((fireworks) -> {
this.power = fireworks.flightDuration();
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
-index b9ddf1c75d371258c6ccd39095160469e5b644f2..2c0a61fd4fbfb07ed3d5d27509b3bc8b51cb0a76 100644
+index cf85cd7426ccf179957c12f49721f44401b8ee38..22f2376365329e3323a3bc817665570fc1e662b7 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -393,7 +393,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -683,7 +683,7 @@ index 08e18dcabbf52aae5c3843d49a72d1d52baa729b..149356981e586e4f67d4543d3df94a2e
getOrEmpty(tag, CraftMetaMap.MAP_ID).ifPresent((mapId) -> {
this.mapId = mapId.id();
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMusicInstrument.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMusicInstrument.java
-index 76a3e4893cbdba903a712d6db1d30b9c644795be..a80b9b142ca99c7c0257b1bdeb059dce5f92ae93 100644
+index 478059eb3ad76b41e6a20e9b489a2a4fb19e7c7c..8423c6b67a83d99ef4356674f64d6e52fda3d36f 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMusicInstrument.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMusicInstrument.java
@@ -26,8 +26,8 @@ public class CraftMetaMusicInstrument extends CraftMetaItem implements MusicInst
@@ -696,7 +696,7 @@ index 76a3e4893cbdba903a712d6db1d30b9c644795be..a80b9b142ca99c7c0257b1bdeb059dce
+ super(tag, extraHandledDcts); // Paper
getOrEmpty(tag, CraftMetaMusicInstrument.GOAT_HORN_INSTRUMENT).ifPresent((instrument) -> {
- this.instrument = org.bukkit.craftbukkit.CraftRegistry.unwrapAndConvertHolder(org.bukkit.Registry.INSTRUMENT, instrument).orElse(null); // Paper - fix upstream not handling inlined instrument
+ this.instrument = CraftMusicInstrument.minecraftHolderToBukkit(instrument);
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaOminousBottle.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaOminousBottle.java
index ed272c7eb435677de5f6b106a6012c472decbb62..b118d8ecb505d187c02bb158f14df333f487a87f 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaOminousBottle.java
@@ -713,7 +713,7 @@ index ed272c7eb435677de5f6b106a6012c472decbb62..b118d8ecb505d187c02bb158f14df333
this.ominousBottleAmplifier = amplifier.value();
});
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java
-index 533c600d632eb733c121f5d8189142726b091713..6f0eebcaffa20337cf5a7f8485f891c690d948ae 100644
+index 96ad0f53d39338f310f994e3352c8d2168fc39e8..fd7b7f53c5504549426f7514ab4385e66f15d8e8 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java
@@ -54,8 +54,8 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta {