From f594b47eda0e6ed646619ab6189f82b4ff8e0312 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) --- .../server/Brigadier-based-command-API.patch | 2 +- .../server/Fix-issues-with-Recipe-API.patch | 2 +- patches/server/Paper-Plugins.patch | 2 +- patches/server/Test-changes.patch | 32 ++++++++++++++++++- ...ve-checking-handled-tags-in-itemmeta.patch | 2 +- 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/patches/server/Brigadier-based-command-API.patch b/patches/server/Brigadier-based-command-API.patch index 37bef66ff4..19cd9119c1 100644 --- a/patches/server/Brigadier-based-command-API.patch +++ b/patches/server/Brigadier-based-command-API.patch @@ -2827,5 +2827,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - 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/Fix-issues-with-Recipe-API.patch b/patches/server/Fix-issues-with-Recipe-API.patch index 46ea65eb92..529ebb9150 100644 --- a/patches/server/Fix-issues-with-Recipe-API.patch +++ b/patches/server/Fix-issues-with-Recipe-API.patch @@ -100,7 +100,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/test/java/org/bukkit/support/DummyServer.java +++ b/src/test/java/org/bukkit/support/DummyServer.java @@ -0,0 +0,0 @@ public final class DummyServer { - when(instance.getTag(anyString(), any(org.bukkit.NamespacedKey.class), any())).thenAnswer(ignored -> new io.papermc.paper.util.EmptyTag()); + when(instance.getPluginManager()).thenReturn(pluginManager); // paper end - testing additions + // Paper start - add test for recipe conversion diff --git a/patches/server/Paper-Plugins.patch b/patches/server/Paper-Plugins.patch index b95bb91b25..4518df27a3 100644 --- a/patches/server/Paper-Plugins.patch +++ b/patches/server/Paper-Plugins.patch @@ -8161,5 +8161,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - 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/Test-changes.patch b/patches/server/Test-changes.patch index 64747ee059..20f5288944 100644 --- a/patches/server/Test-changes.patch +++ b/patches/server/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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -355,6 +356,36 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/test/java/org/bukkit/support/DummyServer.java +++ b/src/test/java/org/bukkit/support/DummyServer.java @@ -0,0 +0,0 @@ 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 -> { +@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + 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/improve-checking-handled-tags-in-itemmeta.patch b/patches/server/improve-checking-handled-tags-in-itemmeta.patch index c3655cc245..91accdc79e 100644 --- a/patches/server/improve-checking-handled-tags-in-itemmeta.patch +++ b/patches/server/improve-checking-handled-tags-in-itemmeta.patch @@ -808,7 +808,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + 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) {