From 1f8e7a7b09a6ba421076ca39093e33c8d672d2d8 Mon Sep 17 00:00:00 2001 From: Yannick Lamprecht <1420893+yannicklamprecht@users.noreply.github.com> Date: Sun, 16 Jun 2024 11:47:44 +0200 Subject: [PATCH] address compile and test issue (#10890) --- patches/server/0004-Test-changes.patch | 36 +++++++++++++++++-- patches/server/0019-Paper-Plugins.patch | 4 +-- ...gistryAccess-for-managing-Registries.patch | 2 +- ...ve-checking-handled-tags-in-itemmeta.patch | 4 +-- .../0976-Brigadier-based-command-API.patch | 4 +-- .../0977-Fix-issues-with-Recipe-API.patch | 6 ++-- 6 files changed, 43 insertions(+), 13 deletions(-) diff --git a/patches/server/0004-Test-changes.patch b/patches/server/0004-Test-changes.patch index 7f25b74963..a4b4a61e66 100644 --- a/patches/server/0004-Test-changes.patch +++ b/patches/server/0004-Test-changes.patch @@ -3,6 +3,7 @@ From: Jake Potrebic Date: Mon, 13 Feb 2023 14:14:56 -0800 Subject: [PATCH] Test changes +Co-authored-by: yannnicklamprecht diff --git a/build.gradle.kts b/build.gradle.kts index f276414e9e81abf8f1f80991ebd5ab43472e07b1..7a0f2391a464eeebc5e57856300bc000b8d35e52 100644 @@ -351,10 +352,40 @@ index ebcb65cb74acdb9d1bcf2b4b3551a2dc6d809bc9..7d9dbed7281099b78d7f898885b37cdc @Test diff --git a/src/test/java/org/bukkit/support/DummyServer.java b/src/test/java/org/bukkit/support/DummyServer.java -index 1acdf5bc439c073c1777c2c4f5743ae082f4a621..bd13fd46f79ab9000b708526acbadcc7210c8a92 100644 +index 1acdf5bc439c073c1777c2c4f5743ae082f4a621..183d30e3d3d413b05c762f374a964498d6ffdec4 100644 --- a/src/test/java/org/bukkit/support/DummyServer.java +++ b/src/test/java/org/bukkit/support/DummyServer.java -@@ -99,6 +99,15 @@ public final class DummyServer { +@@ -62,7 +62,7 @@ public final class DummyServer { + when(instance.getTag(any(), any(), any())).then(mock -> { + String registry = mock.getArgument(0); + Class clazz = mock.getArgument(2); +- MinecraftKey key = CraftNamespacedKey.toMinecraft(mock.getArgument(1)); ++ net.minecraft.resources.ResourceLocation key = CraftNamespacedKey.toMinecraft(mock.getArgument(1)); // Paper - address remapping issues + + switch (registry) { + case org.bukkit.Tag.REGISTRY_BLOCKS -> { +@@ -81,24 +81,32 @@ public final class DummyServer { + } + case org.bukkit.Tag.REGISTRY_FLUIDS -> { + Preconditions.checkArgument(clazz == org.bukkit.Fluid.class, "Fluid namespace must have fluid type"); +- TagKey fluidTagKey = TagKey.create(Registries.FLUID, key); ++ TagKey fluidTagKey = TagKey.create(Registries.FLUID, key); // Paper - address remapping issues + if (BuiltInRegistries.FLUID.getTag(fluidTagKey).isPresent()) { + return new CraftFluidTag(BuiltInRegistries.FLUID, fluidTagKey); + } + } + case org.bukkit.Tag.REGISTRY_ENTITY_TYPES -> { + Preconditions.checkArgument(clazz == org.bukkit.entity.EntityType.class, "Entity type namespace must have entity type"); +- TagKey> entityTagKey = TagKey.create(Registries.ENTITY_TYPE, key); ++ TagKey> entityTagKey = TagKey.create(Registries.ENTITY_TYPE, key); // Paper - address remapping issues + if (BuiltInRegistries.ENTITY_TYPE.getTag(entityTagKey).isPresent()) { + return new CraftEntityTag(BuiltInRegistries.ENTITY_TYPE, entityTagKey); + } + } +- default -> throw new IllegalArgumentException(); ++ default -> new io.papermc.paper.util.EmptyTag(); // Paper - testing additions + } + return null; }); @@ -364,7 +395,6 @@ index 1acdf5bc439c073c1777c2c4f5743ae082f4a621..bd13fd46f79ab9000b708526acbadcc7 + + final org.bukkit.plugin.PluginManager pluginManager = new org.bukkit.plugin.SimplePluginManager(instance, new org.bukkit.command.SimpleCommandMap(instance)); + when(instance.getPluginManager()).thenReturn(pluginManager); -+ when(instance.getTag(anyString(), any(org.bukkit.NamespacedKey.class), any())).thenAnswer(ignored -> new io.papermc.paper.util.EmptyTag()); + // paper end - testing additions + Bukkit.setServer(instance); diff --git a/patches/server/0019-Paper-Plugins.patch b/patches/server/0019-Paper-Plugins.patch index 5629b3f527..17df0a46b5 100644 --- a/patches/server/0019-Paper-Plugins.patch +++ b/patches/server/0019-Paper-Plugins.patch @@ -8151,7 +8151,7 @@ index 0000000000000000000000000000000000000000..ba271c35eb2804f94cfc893bf94affb9 + } +} diff --git a/src/test/java/org/bukkit/support/DummyServer.java b/src/test/java/org/bukkit/support/DummyServer.java -index bd13fd46f79ab9000b708526acbadcc7210c8a92..c2aa05f6e03b99b1e5c0a4539420be2ca93f1c3f 100644 +index 183d30e3d3d413b05c762f374a964498d6ffdec4..bfbd80b60ac5df500d03c80de57e38aa7548dd46 100644 --- a/src/test/java/org/bukkit/support/DummyServer.java +++ b/src/test/java/org/bukkit/support/DummyServer.java @@ -103,7 +103,7 @@ public final class DummyServer { @@ -8161,5 +8161,5 @@ index bd13fd46f79ab9000b708526acbadcc7210c8a92..c2aa05f6e03b99b1e5c0a4539420be2c - final org.bukkit.plugin.PluginManager pluginManager = new org.bukkit.plugin.SimplePluginManager(instance, new org.bukkit.command.SimpleCommandMap(instance)); + final org.bukkit.plugin.PluginManager pluginManager = new io.papermc.paper.plugin.manager.PaperPluginManagerImpl(instance, new org.bukkit.command.SimpleCommandMap(instance), null); when(instance.getPluginManager()).thenReturn(pluginManager); - when(instance.getTag(anyString(), any(org.bukkit.NamespacedKey.class), any())).thenAnswer(ignored -> new io.papermc.paper.util.EmptyTag()); // paper end - testing additions + diff --git a/patches/server/0475-Add-RegistryAccess-for-managing-Registries.patch b/patches/server/0475-Add-RegistryAccess-for-managing-Registries.patch index 6ddf9741cc..7c5dbe8250 100644 --- a/patches/server/0475-Add-RegistryAccess-for-managing-Registries.patch +++ b/patches/server/0475-Add-RegistryAccess-for-managing-Registries.patch @@ -1057,7 +1057,7 @@ index e48536683889cdea197746c55b0e67e7e4b9dc68..3216a3549011659a91cc4a0c656a56cd this.checkValidMinecraftToBukkit(clazz); diff --git a/src/test/java/org/bukkit/support/DummyServer.java b/src/test/java/org/bukkit/support/DummyServer.java -index c2aa05f6e03b99b1e5c0a4539420be2ca93f1c3f..41dcf87d945a0acb7806cb1704ee12f7f447daf7 100644 +index bfbd80b60ac5df500d03c80de57e38aa7548dd46..cce9e2226ef554c10e1df1dbaa1791656d5d0799 100644 --- a/src/test/java/org/bukkit/support/DummyServer.java +++ b/src/test/java/org/bukkit/support/DummyServer.java @@ -54,10 +54,7 @@ public final class DummyServer { diff --git a/patches/server/0970-improve-checking-handled-tags-in-itemmeta.patch b/patches/server/0970-improve-checking-handled-tags-in-itemmeta.patch index 53502b4dc8..ac37f066e2 100644 --- a/patches/server/0970-improve-checking-handled-tags-in-itemmeta.patch +++ b/patches/server/0970-improve-checking-handled-tags-in-itemmeta.patch @@ -785,7 +785,7 @@ index 51e2acf125bdff2ba6d8fd8af9f22e233d7c74a7..6bed0a5c8d9f1ca72678cdf4699128e4 @Test diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/MetaHandledTagsTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/MetaHandledTagsTest.java new file mode 100644 -index 0000000000000000000000000000000000000000..d9692972e3ad089885d43711b6a7fb3e96da59b1 +index 0000000000000000000000000000000000000000..43fca566e139d370a37b2d56156df4ed7d0d0b66 --- /dev/null +++ b/src/test/java/org/bukkit/craftbukkit/inventory/MetaHandledTagsTest.java @@ -0,0 +1,32 @@ @@ -808,7 +808,7 @@ index 0000000000000000000000000000000000000000..d9692972e3ad089885d43711b6a7fb3e + public void checkAllMetasHaveHandledTags() { + try (final ScanResult result = new ClassGraph() + .whitelistPackages("org.bukkit.craftbukkit.inventory") -+ .enableAllInfo().scan()) { ++ .enableClassInfo().scan()) { + final ClassInfoList subclasses = result.getSubclasses(CraftMetaItem.class.getName()); + assertFalse(subclasses.isEmpty(), "found 0 sub types"); + for (final ClassInfo subclass : subclasses) { diff --git a/patches/server/0976-Brigadier-based-command-API.patch b/patches/server/0976-Brigadier-based-command-API.patch index e548c59e56..3ae23da312 100644 --- a/patches/server/0976-Brigadier-based-command-API.patch +++ b/patches/server/0976-Brigadier-based-command-API.patch @@ -2817,7 +2817,7 @@ index 0000000000000000000000000000000000000000..6475510ea1084a003fb2c8645cb4538b + } +} diff --git a/src/test/java/org/bukkit/support/DummyServer.java b/src/test/java/org/bukkit/support/DummyServer.java -index 41dcf87d945a0acb7806cb1704ee12f7f447daf7..53b49a7ee1ae185e0def7c90cf11223f55a57e65 100644 +index cce9e2226ef554c10e1df1dbaa1791656d5d0799..6e9ee1b56b4151c31c373e58172055e02fd7875a 100644 --- a/src/test/java/org/bukkit/support/DummyServer.java +++ b/src/test/java/org/bukkit/support/DummyServer.java @@ -100,7 +100,7 @@ public final class DummyServer { @@ -2827,5 +2827,5 @@ index 41dcf87d945a0acb7806cb1704ee12f7f447daf7..53b49a7ee1ae185e0def7c90cf11223f - final org.bukkit.plugin.PluginManager pluginManager = new io.papermc.paper.plugin.manager.PaperPluginManagerImpl(instance, new org.bukkit.command.SimpleCommandMap(instance), null); + final org.bukkit.plugin.PluginManager pluginManager = new io.papermc.paper.plugin.manager.PaperPluginManagerImpl(instance, new org.bukkit.command.SimpleCommandMap(instance, new java.util.HashMap<>()), null); // Paper when(instance.getPluginManager()).thenReturn(pluginManager); - when(instance.getTag(anyString(), any(org.bukkit.NamespacedKey.class), any())).thenAnswer(ignored -> new io.papermc.paper.util.EmptyTag()); // paper end - testing additions + diff --git a/patches/server/0977-Fix-issues-with-Recipe-API.patch b/patches/server/0977-Fix-issues-with-Recipe-API.patch index 9f8f34dc50..bb85dca687 100644 --- a/patches/server/0977-Fix-issues-with-Recipe-API.patch +++ b/patches/server/0977-Fix-issues-with-Recipe-API.patch @@ -96,11 +96,11 @@ index 0000000000000000000000000000000000000000..b6816485a2360b936c049b398183658e + } +} diff --git a/src/test/java/org/bukkit/support/DummyServer.java b/src/test/java/org/bukkit/support/DummyServer.java -index 53b49a7ee1ae185e0def7c90cf11223f55a57e65..7862d578f53e48bc467cc4f475d32d9d6ea71e04 100644 +index 6e9ee1b56b4151c31c373e58172055e02fd7875a..11ba7a3db4c56ec00d9ad1ed8e46b242c033fe74 100644 --- a/src/test/java/org/bukkit/support/DummyServer.java +++ b/src/test/java/org/bukkit/support/DummyServer.java -@@ -105,6 +105,14 @@ public final class DummyServer { - when(instance.getTag(anyString(), any(org.bukkit.NamespacedKey.class), any())).thenAnswer(ignored -> new io.papermc.paper.util.EmptyTag()); +@@ -104,6 +104,14 @@ public final class DummyServer { + when(instance.getPluginManager()).thenReturn(pluginManager); // paper end - testing additions + // Paper start - add test for recipe conversion