From efc1f99846d7926640608578cbc965e1214875f3 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Thu, 21 Sep 2023 09:48:55 -0700 Subject: [PATCH] Updated Upstream (Bukkit/CraftBukkit) (#9739) 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: 69c7ce23 PR-990: Use Mockito instead of InvocationHandler for test mocking 997de31d PR-893: Add a stream method to Registry to make it easier to use and to avoid unnecessary wrapping 6a8ce581 Fix malformed javadoc in previous commit 26c74f6d PR-890: Add more Sculk API (bloom, shriek, bloom event) aa067abf PR-895: Load GameEvent and MusicInstrument from registry CraftBukkit Changes: 78796c9de Add support for Java 21 ddc9a2dad SPIGOT-7475: Don't fire SculkBloomEvent during world generation caee2311a PR-1245: Add a stream method to Registry to make it easier to use and to avoid unnecessary wrapping de421cf56 PR-1242: Add more Sculk API (bloom, shriek, bloom event) 00f5a80fb PR-1252: Fix error when generating a tree in water 10219df3a PR-1248: Load GameEvent and MusicInstrument from registry --- patches/api/Add-Material-Tags.patch | 15 +- patches/api/Add-StructuresLocateEvent.patch | 10 +- .../Add-methods-to-get-translation-keys.patch | 16 +- patches/api/Convert-project-to-Gradle.patch | 7 + patches/api/More-PotionEffectType-API.patch | 5 + patches/api/Paper-Plugins.patch | 43 +-- patches/api/SculkCatalyst-bloom-API.patch | 10 +- patches/api/Test-changes.patch | 332 +----------------- ...rtant-BlockStateListPopulator-method.patch | 9 +- .../Add-support-for-Proxy-Protocol.patch | 2 +- patches/server/Build-system-changes.patch | 4 +- .../server/Improve-java-version-check.patch | 4 +- patches/server/Paper-config-files.patch | 8 +- patches/server/SculkCatalyst-bloom-API.patch | 4 +- patches/server/Setup-Gradle-project.patch | 4 +- patches/server/Test-changes.patch | 13 +- ...oleAppender-for-console-improvements.patch | 4 +- work/Bukkit | 2 +- work/CraftBukkit | 2 +- 19 files changed, 99 insertions(+), 395 deletions(-) diff --git a/patches/api/Add-Material-Tags.patch b/patches/api/Add-Material-Tags.patch index 90a0c941b2..76ece994a5 100644 --- a/patches/api/Add-Material-Tags.patch +++ b/patches/api/Add-Material-Tags.patch @@ -1146,9 +1146,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import io.papermc.paper.tag.BaseTag; +import io.papermc.paper.tag.EntityTags; -+import io.papermc.paper.testing.TestServer; +import org.bukkit.Bukkit; -+import org.junit.Before; ++import org.bukkit.support.AbstractTestingBase; +import org.junit.Test; + +import java.lang.reflect.Field; @@ -1159,12 +1158,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import static org.junit.Assert.assertTrue; + -+public class MaterialTagsTest { -+ -+ @Before -+ public void before() { -+ TestServer.setup(); -+ } ++public class MaterialTagsTest extends AbstractTestingBase { + + @Test + public void testInitialize() { @@ -1212,17 +1206,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +package io.papermc.paper; + +import io.papermc.paper.tag.EntityTags; -+import io.papermc.paper.testing.TestServer; +import java.util.logging.Level; +import org.bukkit.Bukkit; ++import org.bukkit.support.AbstractTestingBase; +import org.junit.Test; + -+public class EntityTagsTest { ++public class EntityTagsTest extends AbstractTestingBase { + + @Test + public void testInitialize() { + try { -+ TestServer.setup(); + EntityTags.HORSES.getValues(); + assert true; + } catch (Throwable e) { diff --git a/patches/api/Add-StructuresLocateEvent.patch b/patches/api/Add-StructuresLocateEvent.patch index 246c22b7cc..5838fff4c6 100644 --- a/patches/api/Add-StructuresLocateEvent.patch +++ b/patches/api/Add-StructuresLocateEvent.patch @@ -509,9 +509,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/Registry.java +++ b/src/main/java/org/bukkit/Registry.java @@ -0,0 +0,0 @@ public interface Registry extends Iterable { - return GameEvent.getByKey(key); - } - }; + * @see GameEvent + */ + Registry GAME_EVENT = Objects.requireNonNull(Bukkit.getRegistry(GameEvent.class), "No registry present for GameEvent. This is a bug."); ++ + // Paper start + /** + * Configured structures. @@ -521,6 +522,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Deprecated(forRemoval = true) + Registry CONFIGURED_STRUCTURE = Bukkit.getRegistry(io.papermc.paper.world.structure.ConfiguredStructure.class); + // Paper end - ++ /** * Get the object by its key. + * diff --git a/patches/api/Add-methods-to-get-translation-keys.patch b/patches/api/Add-methods-to-get-translation-keys.patch index 8b46fe3009..9239bb096f 100644 --- a/patches/api/Add-methods-to-get-translation-keys.patch +++ b/patches/api/Add-methods-to-get-translation-keys.patch @@ -188,24 +188,24 @@ diff --git a/src/main/java/org/bukkit/MusicInstrument.java b/src/main/java/org/b index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/MusicInstrument.java +++ b/src/main/java/org/bukkit/MusicInstrument.java -@@ -0,0 +0,0 @@ import java.util.Map; +@@ -0,0 +0,0 @@ import java.util.Collections; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; --public final class MusicInstrument implements Keyed { -+public final class MusicInstrument implements Keyed, net.kyori.adventure.translation.Translatable { // Paper - translation keys +-public abstract class MusicInstrument implements Keyed { ++public abstract class MusicInstrument implements Keyed, net.kyori.adventure.translation.Translatable { // Paper - translation keys - private static final Map INSTRUMENTS = new HashMap<>(); - // -@@ -0,0 +0,0 @@ public final class MusicInstrument implements Keyed { + public static final MusicInstrument PONDER = getInstrument("ponder_goat_horn"); + public static final MusicInstrument SING = getInstrument("sing_goat_horn"); +@@ -0,0 +0,0 @@ public abstract class MusicInstrument implements Keyed { - return new MusicInstrument(NamespacedKey.minecraft(name)); + return instrument; } + + // Paper start - translation key + @Override + public @NotNull String translationKey() { -+ return "instrument.minecraft." + this.key.value(); ++ return "instrument.minecraft." + this.getKey().value(); + } + // Paper end - translation key } diff --git a/patches/api/Convert-project-to-Gradle.patch b/patches/api/Convert-project-to-Gradle.patch index 12e235f8ff..b1234ae264 100644 --- a/patches/api/Convert-project-to-Gradle.patch +++ b/patches/api/Convert-project-to-Gradle.patch @@ -63,6 +63,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + testImplementation("org.apache.commons:commons-lang3:3.12.0") + testImplementation("junit:junit:4.13.2") + testImplementation("org.hamcrest:hamcrest-library:1.3") ++ testImplementation("org.mockito:mockito-core:5.5.0") + testImplementation("org.ow2.asm:asm-tree:9.5") +} + @@ -230,6 +231,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - test - - +- org.mockito +- mockito-core +- 5.5.0 +- test +- +- - org.ow2.asm - asm-tree - 9.5 diff --git a/patches/api/More-PotionEffectType-API.patch b/patches/api/More-PotionEffectType-API.patch index 2c0101ad5b..efb7562f4d 100644 --- a/patches/api/More-PotionEffectType-API.patch +++ b/patches/api/More-PotionEffectType-API.patch @@ -31,6 +31,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public Iterator iterator() { + return Arrays.stream(org.bukkit.potion.PotionEffectType.values()).iterator(); + } ++ ++ @Override ++ public @NotNull Stream stream() { ++ return StreamSupport.stream(this.spliterator(), false); ++ } + }; // Paper end diff --git a/patches/api/Paper-Plugins.patch b/patches/api/Paper-Plugins.patch index 171692d54c..5005d5013d 100644 --- a/patches/api/Paper-Plugins.patch +++ b/patches/api/Paper-Plugins.patch @@ -2276,20 +2276,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + // Paper end } -diff --git a/src/test/java/io/papermc/paper/testing/TestServer.java b/src/test/java/io/papermc/paper/testing/TestServer.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/test/java/io/papermc/paper/testing/TestServer.java -+++ b/src/test/java/io/papermc/paper/testing/TestServer.java -@@ -0,0 +0,0 @@ public final class TestServer { - - when(dummyServer.getTag(anyString(), any(NamespacedKey.class), any())).thenAnswer(ignored -> new EmptyTag()); - -- final PluginManager pluginManager = new SimplePluginManager(dummyServer, new SimpleCommandMap(dummyServer)); -- when(dummyServer.getPluginManager()).thenReturn(pluginManager); -- - when(dummyServer.getRegistry(any())).thenAnswer(ignored -> new EmptyRegistry()); - when(dummyServer.getScoreboardCriteria(anyString())).thenReturn(null); - diff --git a/src/test/java/org/bukkit/event/SyntheticEventTest.java b/src/test/java/org/bukkit/event/SyntheticEventTest.java deleted file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 @@ -2298,26 +2284,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ -package org.bukkit.event; - +-import org.bukkit.Bukkit; -import org.bukkit.plugin.PluginLoader; -import org.bukkit.plugin.SimplePluginManager; -import org.bukkit.plugin.TestPlugin; -import org.bukkit.plugin.java.JavaPluginLoader; +-import org.bukkit.support.AbstractTestingBase; -import org.junit.Assert; -import org.junit.Test; - --public class SyntheticEventTest { +-public class SyntheticEventTest extends AbstractTestingBase { - @SuppressWarnings("deprecation") - @Test - public void test() { -- io.papermc.paper.testing.TestServer.setup(); // Paper -- final JavaPluginLoader loader = new JavaPluginLoader(org.bukkit.Bukkit.getServer()); // Paper +- final JavaPluginLoader loader = new JavaPluginLoader(Bukkit.getServer()); - TestPlugin plugin = new TestPlugin(getClass().getName()) { - @Override - public PluginLoader getPluginLoader() { - return loader; - } - }; -- SimplePluginManager pluginManager = new SimplePluginManager(org.bukkit.Bukkit.getServer(), null); // Paper +- SimplePluginManager pluginManager = new SimplePluginManager(Bukkit.getServer(), null); - - TestEvent event = new TestEvent(false); - Impl impl = new Impl(); @@ -2354,18 +2341,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - -import static org.hamcrest.Matchers.*; -import static org.junit.Assert.*; +-import org.bukkit.Bukkit; -import org.bukkit.event.Event; -import org.bukkit.event.TestEvent; -import org.bukkit.permissions.Permission; +-import org.bukkit.support.AbstractTestingBase; -import org.junit.After; -import org.junit.Test; - --public class PluginManagerTest { +-public class PluginManagerTest extends AbstractTestingBase { - private class MutableObject { - volatile Object value = null; - } - -- private static final PluginManager pm = org.bukkit.Bukkit.getServer().getPluginManager(); // Paper +- private static final PluginManager pm = Bukkit.getServer().getPluginManager(); - - private final MutableObject store = new MutableObject(); - @@ -2550,3 +2539,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public FileConfiguration getConfig() { +diff --git a/src/test/java/org/bukkit/support/TestServer.java b/src/test/java/org/bukkit/support/TestServer.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/test/java/org/bukkit/support/TestServer.java ++++ b/src/test/java/org/bukkit/support/TestServer.java +@@ -0,0 +0,0 @@ public final class TestServer { + Thread creatingThread = Thread.currentThread(); + when(instance.isPrimaryThread()).then(mock -> Thread.currentThread().equals(creatingThread)); + +- PluginManager pluginManager = new SimplePluginManager(instance, new SimpleCommandMap(instance)); +- when(instance.getPluginManager()).thenReturn(pluginManager); ++ // Paper - remove plugin manager for Paper Plugins + + Logger logger = Logger.getLogger(TestServer.class.getCanonicalName()); + when(instance.getLogger()).thenReturn(logger); diff --git a/patches/api/SculkCatalyst-bloom-API.patch b/patches/api/SculkCatalyst-bloom-API.patch index e136dbbf0d..3d938ecc74 100644 --- a/patches/api/SculkCatalyst-bloom-API.patch +++ b/patches/api/SculkCatalyst-bloom-API.patch @@ -8,10 +8,10 @@ diff --git a/src/main/java/org/bukkit/block/SculkCatalyst.java b/src/main/java/o index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/block/SculkCatalyst.java +++ b/src/main/java/org/bukkit/block/SculkCatalyst.java -@@ -0,0 +0,0 @@ package org.bukkit.block; - * Represents a captured state of a sculk catalyst. - */ - public interface SculkCatalyst extends TileState { +@@ -0,0 +0,0 @@ public interface SculkCatalyst extends TileState { + * @param charges how much charge to spawn. + */ + void bloom(@NotNull Block block, int charges); + + // Paper start - SculkCatalyst bloom API + /** @@ -21,5 +21,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param charge charge to bloom with, normally the amount of experience dropped from the dead entity + */ + void bloom(@org.jetbrains.annotations.NotNull io.papermc.paper.math.Position position, int charge); -+ // Paper end ++ // Paper end - SculkCatalyst bloom API } diff --git a/patches/api/Test-changes.patch b/patches/api/Test-changes.patch index 6de13bdf65..9e1db3548c 100644 --- a/patches/api/Test-changes.patch +++ b/patches/api/Test-changes.patch @@ -12,47 +12,6 @@ Subject: [PATCH] Test changes Co-authored-by: Riley Park Co-authored-by: Jake Potrebic -diff --git a/build.gradle.kts b/build.gradle.kts -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/build.gradle.kts -+++ b/build.gradle.kts -@@ -0,0 +0,0 @@ dependencies { - compileOnlyApi(checkerQual) - testCompileOnly(checkerQual) - // Paper end -+ testImplementation("org.mockito:mockito-core:4.9.0") // Paper - add mockito - - testImplementation("org.apache.commons:commons-lang3:3.12.0") - testImplementation("junit:junit:4.13.2") -diff --git a/src/test/java/io/papermc/paper/testing/EmptyRegistry.java b/src/test/java/io/papermc/paper/testing/EmptyRegistry.java -new file mode 100644 -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 ---- /dev/null -+++ b/src/test/java/io/papermc/paper/testing/EmptyRegistry.java -@@ -0,0 +0,0 @@ -+package io.papermc.paper.testing; -+ -+import java.util.Collections; -+import java.util.Iterator; -+import org.bukkit.Keyed; -+import org.bukkit.NamespacedKey; -+import org.bukkit.Registry; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; -+ -+public record EmptyRegistry() implements Registry { -+ -+ @NotNull -+ @Override -+ public Iterator iterator() { -+ return Collections.emptyIterator(); -+ } -+ -+ @Override -+ public @Nullable Keyed get(@NotNull final NamespacedKey key) { -+ return null; -+ } -+} diff --git a/src/test/java/io/papermc/paper/testing/EmptyTag.java b/src/test/java/io/papermc/paper/testing/EmptyTag.java new file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 @@ -90,60 +49,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return Collections.emptySet(); + } +} -diff --git a/src/test/java/io/papermc/paper/testing/TestServer.java b/src/test/java/io/papermc/paper/testing/TestServer.java -new file mode 100644 -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 ---- /dev/null -+++ b/src/test/java/io/papermc/paper/testing/TestServer.java -@@ -0,0 +0,0 @@ -+package io.papermc.paper.testing; -+ -+import java.util.logging.Logger; -+import org.bukkit.Bukkit; -+import org.bukkit.NamespacedKey; -+import org.bukkit.Server; -+import org.bukkit.command.SimpleCommandMap; -+import org.bukkit.plugin.PluginManager; -+import org.bukkit.plugin.SimplePluginManager; -+ -+import static org.mockito.ArgumentMatchers.anyString; -+import static org.mockito.Mockito.any; -+import static org.mockito.Mockito.mock; -+import static org.mockito.Mockito.when; -+ -+public final class TestServer { -+ -+ @SuppressWarnings("removal") -+ public static void setup() { -+ //noinspection ConstantValue -+ if (Bukkit.getServer() != null) { -+ return; -+ } -+ -+ final Server dummyServer = mock(Server.class); -+ -+ final Logger logger = Logger.getLogger(TestServer.class.getCanonicalName()); -+ when(dummyServer.getLogger()).thenReturn(logger); -+ when(dummyServer.getName()).thenReturn(TestServer.class.getSimpleName()); -+ when(dummyServer.getVersion()).thenReturn("Version_" + TestServer.class.getPackage().getImplementationVersion()); -+ when(dummyServer.getBukkitVersion()).thenReturn("BukkitVersion_" + TestServer.class.getPackage().getImplementationVersion()); -+ -+ -+ final Thread currentThread = Thread.currentThread(); -+ when(dummyServer.isPrimaryThread()).thenAnswer(ignored -> Thread.currentThread().equals(currentThread)); -+ -+ when(dummyServer.getTag(anyString(), any(NamespacedKey.class), any())).thenAnswer(ignored -> new EmptyTag()); -+ -+ final PluginManager pluginManager = new SimplePluginManager(dummyServer, new SimpleCommandMap(dummyServer)); -+ when(dummyServer.getPluginManager()).thenReturn(pluginManager); -+ -+ when(dummyServer.getRegistry(any())).thenAnswer(ignored -> new EmptyRegistry()); -+ when(dummyServer.getScoreboardCriteria(anyString())).thenReturn(null); -+ -+ Bukkit.setServer(dummyServer); -+ } -+ -+} diff --git a/src/test/java/org/bukkit/AnnotationTest.java b/src/test/java/org/bukkit/AnnotationTest.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/test/java/org/bukkit/AnnotationTest.java @@ -311,232 +216,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return Lists.transform(Arrays.asList(Server.class.getDeclaredMethods()), new Function() { @Override public Object[] apply(Method input) { -diff --git a/src/test/java/org/bukkit/TestServer.java b/src/test/java/org/bukkit/TestServer.java -deleted file mode 100644 -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 ---- a/src/test/java/org/bukkit/TestServer.java -+++ /dev/null -@@ -0,0 +0,0 @@ --package org.bukkit; -- --import com.google.common.collect.ImmutableMap; --import java.lang.reflect.InvocationHandler; --import java.lang.reflect.Method; --import java.lang.reflect.Proxy; --import java.util.Iterator; --import java.util.Map; --import java.util.logging.Logger; --import org.bukkit.command.SimpleCommandMap; --import org.bukkit.plugin.PluginManager; --import org.bukkit.plugin.SimplePluginManager; --import org.jetbrains.annotations.NotNull; --import org.jetbrains.annotations.Nullable; -- --public final class TestServer implements InvocationHandler { -- private static interface MethodHandler { -- Object handle(TestServer server, Object[] args); -- } -- -- private static final Map methods; -- -- static { -- try { -- ImmutableMap.Builder methodMap = ImmutableMap.builder(); -- methodMap.put( -- Server.class.getMethod("isPrimaryThread"), -- new MethodHandler() { -- @Override -- public Object handle(TestServer server, Object[] args) { -- return Thread.currentThread().equals(server.creatingThread); -- } -- } -- ); -- methodMap.put( -- Server.class.getMethod("getPluginManager"), -- new MethodHandler() { -- @Override -- public Object handle(TestServer server, Object[] args) { -- return server.pluginManager; -- } -- } -- ); -- methodMap.put( -- Server.class.getMethod("getLogger"), -- new MethodHandler() { -- final Logger logger = Logger.getLogger(TestServer.class.getCanonicalName()); -- @Override -- public Object handle(TestServer server, Object[] args) { -- return logger; -- } -- } -- ); -- methodMap.put( -- Server.class.getMethod("getName"), -- new MethodHandler() { -- @Override -- public Object handle(TestServer server, Object[] args) { -- return TestServer.class.getSimpleName(); -- } -- } -- ); -- methodMap.put( -- Server.class.getMethod("getVersion"), -- new MethodHandler() { -- @Override -- public Object handle(TestServer server, Object[] args) { -- return "Version_" + TestServer.class.getPackage().getImplementationVersion(); -- } -- } -- ); -- methodMap.put( -- Server.class.getMethod("getBukkitVersion"), -- new MethodHandler() { -- @Override -- public Object handle(TestServer server, Object[] args) { -- return "BukkitVersion_" + TestServer.class.getPackage().getImplementationVersion(); -- } -- } -- ); -- methodMap.put( -- Server.class.getMethod("getRegistry", Class.class), -- new MethodHandler() { -- @Override -- public Object handle(TestServer server, Object[] args) { -- return new Registry() { -- @NotNull -- @Override -- public Iterator iterator() { -- return null; -- } -- -- @Nullable -- @Override -- public Keyed get(@NotNull NamespacedKey key) { -- return null; -- } -- }; -- } -- } -- ); -- methodMap.put( -- Server.class.getMethod("getScoreboardCriteria", String.class), -- new MethodHandler() { -- @Override -- public Object handle(TestServer server, Object[] args) { -- // Does not need to return anything. Exists solely to test CriteriaTest which has static init fields -- return null; -- } -- } -- ); -- methods = methodMap.build(); -- -- TestServer server = new TestServer(); -- Server instance = Proxy.getProxyClass(Server.class.getClassLoader(), Server.class).asSubclass(Server.class).getConstructor(InvocationHandler.class).newInstance(server); -- Bukkit.setServer(instance); -- server.pluginManager = new SimplePluginManager(instance, new SimpleCommandMap(instance)); -- } catch (Throwable t) { -- throw new Error(t); -- } -- } -- -- private Thread creatingThread = Thread.currentThread(); -- private PluginManager pluginManager; -- private TestServer() {}; -- -- public static Server getInstance() { -- return Bukkit.getServer(); -- } -- -- @Override -- public Object invoke(Object proxy, Method method, Object[] args) { -- MethodHandler handler = methods.get(method); -- if (handler != null) { -- return handler.handle(this, args); -- } -- throw new UnsupportedOperationException(String.valueOf(method)); -- } --} -diff --git a/src/test/java/org/bukkit/TestWorld.java b/src/test/java/org/bukkit/TestWorld.java +diff --git a/src/test/java/org/bukkit/support/TestServer.java b/src/test/java/org/bukkit/support/TestServer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/test/java/org/bukkit/TestWorld.java -+++ b/src/test/java/org/bukkit/TestWorld.java -@@ -0,0 +0,0 @@ public final class TestWorld implements InvocationHandler { +--- a/src/test/java/org/bukkit/support/TestServer.java ++++ b/src/test/java/org/bukkit/support/TestServer.java +@@ -0,0 +0,0 @@ public final class TestServer { + UnsafeValues unsafeValues = mock(withSettings().stubOnly()); + when(instance.getUnsafe()).thenReturn(unsafeValues); - static { - try { -- TestServer.getInstance(); -+ io.papermc.paper.testing.TestServer.setup(); // Paper - - ImmutableMap.Builder methodMap = ImmutableMap.builder(); - methodMap.put( -diff --git a/src/test/java/org/bukkit/event/SyntheticEventTest.java b/src/test/java/org/bukkit/event/SyntheticEventTest.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/test/java/org/bukkit/event/SyntheticEventTest.java -+++ b/src/test/java/org/bukkit/event/SyntheticEventTest.java -@@ -0,0 +0,0 @@ - package org.bukkit.event; - --import org.bukkit.TestServer; - import org.bukkit.plugin.PluginLoader; - import org.bukkit.plugin.SimplePluginManager; - import org.bukkit.plugin.TestPlugin; -@@ -0,0 +0,0 @@ public class SyntheticEventTest { - @SuppressWarnings("deprecation") - @Test - public void test() { -- final JavaPluginLoader loader = new JavaPluginLoader(TestServer.getInstance()); -+ io.papermc.paper.testing.TestServer.setup(); // Paper -+ final JavaPluginLoader loader = new JavaPluginLoader(org.bukkit.Bukkit.getServer()); // Paper - TestPlugin plugin = new TestPlugin(getClass().getName()) { - @Override - public PluginLoader getPluginLoader() { - return loader; - } - }; -- SimplePluginManager pluginManager = new SimplePluginManager(TestServer.getInstance(), null); -+ SimplePluginManager pluginManager = new SimplePluginManager(org.bukkit.Bukkit.getServer(), null); // Paper - - TestEvent event = new TestEvent(false); - Impl impl = new Impl(); -diff --git a/src/test/java/org/bukkit/plugin/PluginManagerTest.java b/src/test/java/org/bukkit/plugin/PluginManagerTest.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/test/java/org/bukkit/plugin/PluginManagerTest.java -+++ b/src/test/java/org/bukkit/plugin/PluginManagerTest.java -@@ -0,0 +0,0 @@ package org.bukkit.plugin; - - import static org.hamcrest.Matchers.*; - import static org.junit.Assert.*; --import org.bukkit.TestServer; - import org.bukkit.event.Event; - import org.bukkit.event.TestEvent; - import org.bukkit.permissions.Permission; -@@ -0,0 +0,0 @@ public class PluginManagerTest { - volatile Object value = null; ++ // Paper start - testing changes ++ when(instance.getTag(anyString(), any(NamespacedKey.class), any())).thenAnswer(ignored -> new io.papermc.paper.testing.EmptyTag()); ++ when(instance.getScoreboardCriteria(anyString())).thenReturn(null); ++ // Paper end - testing changes ++ + Bukkit.setServer(instance); } -- private static final PluginManager pm = TestServer.getInstance().getPluginManager(); -+ private static final PluginManager pm = org.bukkit.Bukkit.getServer().getPluginManager(); // Paper - - private final MutableObject store = new MutableObject(); - -diff --git a/src/test/java/org/bukkit/scoreboard/CriteriaTest.java b/src/test/java/org/bukkit/scoreboard/CriteriaTest.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/test/java/org/bukkit/scoreboard/CriteriaTest.java -+++ b/src/test/java/org/bukkit/scoreboard/CriteriaTest.java -@@ -0,0 +0,0 @@ package org.bukkit.scoreboard; - - import org.bukkit.Material; - import org.bukkit.Statistic; --import org.bukkit.TestServer; - import org.bukkit.entity.EntityType; - import org.junit.Assert; - import org.junit.Test; -@@ -0,0 +0,0 @@ public class CriteriaTest { - - @Test - public void testStatistic() { -- TestServer.getInstance(); -+ io.papermc.paper.testing.TestServer.setup(); // Paper - - Assert.assertThrows(IllegalArgumentException.class, () -> Criteria.statistic(Statistic.AVIATE_ONE_CM, Material.STONE)); // Generic statistic with block - Assert.assertThrows(IllegalArgumentException.class, () -> Criteria.statistic(Statistic.AVIATE_ONE_CM, EntityType.CREEPER)); // Generic statistic with entity type diff --git a/patches/server/Add-missing-important-BlockStateListPopulator-method.patch b/patches/server/Add-missing-important-BlockStateListPopulator-method.patch index a5faaaea3d..9de999dc81 100644 --- a/patches/server/Add-missing-important-BlockStateListPopulator-method.patch +++ b/patches/server/Add-missing-important-BlockStateListPopulator-method.patch @@ -19,8 +19,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override @@ -0,0 +0,0 @@ public class BlockStateListPopulator extends DummyGeneratorAccess { - public RegistryAccess registryAccess() { - return this.world.registryAccess(); + public long nextSubTickCount() { + return this.world.nextSubTickCount(); } + + // Paper start @@ -42,11 +42,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + @Override -+ public net.minecraft.world.level.storage.LevelData getLevelData() { -+ return world.getLevelData(); -+ } -+ -+ @Override + public int getRawBrightness(BlockPos pos, int ambientDarkness) { + return world.getRawBrightness(pos, ambientDarkness); + } diff --git a/patches/server/Add-support-for-Proxy-Protocol.patch b/patches/server/Add-support-for-Proxy-Protocol.patch index b9e55ef5ab..d52c77364e 100644 --- a/patches/server/Add-support-for-Proxy-Protocol.patch +++ b/patches/server/Add-support-for-Proxy-Protocol.patch @@ -15,7 +15,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + implementation("io.netty:netty-codec-haproxy:4.1.87.Final") // Paper - Add support for proxy protocol // Paper end implementation("org.apache.logging.log4j:log4j-iostreams:2.19.0") // Paper - remove exclusion - implementation("org.ow2.asm:asm:9.4") + implementation("org.ow2.asm:asm:9.5") diff --git a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java diff --git a/patches/server/Build-system-changes.patch b/patches/server/Build-system-changes.patch index 624edf0ef3..b4809c54ae 100644 --- a/patches/server/Build-system-changes.patch +++ b/patches/server/Build-system-changes.patch @@ -20,8 +20,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - exclude(group = "org.apache.logging.log4j", module = "log4j-api") - } + implementation("org.apache.logging.log4j:log4j-iostreams:2.19.0") // Paper - remove exclusion - implementation("org.ow2.asm:asm:9.4") -+ implementation("org.ow2.asm:asm-commons:9.4") // Paper - ASM event executor generation + implementation("org.ow2.asm:asm:9.5") ++ implementation("org.ow2.asm:asm-commons:9.5") // Paper - ASM event executor generation implementation("commons-lang:commons-lang:2.6") runtimeOnly("org.xerial:sqlite-jdbc:3.42.0.0") runtimeOnly("com.mysql:mysql-connector-j:8.0.33") diff --git a/patches/server/Improve-java-version-check.patch b/patches/server/Improve-java-version-check.patch index fa63f447f1..c448bf7035 100644 --- a/patches/server/Improve-java-version-check.patch +++ b/patches/server/Improve-java-version-check.patch @@ -20,8 +20,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - System.err.println("Unsupported Java detected (" + javaVersion + "). This version of Minecraft requires at least Java 17. Check your Java version with the command 'java -version'."); - return; - } -- if (javaVersion > 64.0) { -- System.err.println("Unsupported Java detected (" + javaVersion + "). Only up to Java 20 is supported."); +- if (javaVersion > 65.0) { +- System.err.println("Unsupported Java detected (" + javaVersion + "). Only up to Java 21 is supported."); + boolean isOldVersion = javaVersion < 61.0; + if (!skip && isOldVersion) { + System.err.println("Unsupported Java detected (" + javaVersion + "). This version of Minecraft requires at least Java 17. Check your Java version with the command 'java -version'. For more info see https://docs.papermc.io/misc/java-install"); diff --git a/patches/server/Paper-config-files.patch b/patches/server/Paper-config-files.patch index 592a0e49a3..0dc79bfce8 100644 --- a/patches/server/Paper-config-files.patch +++ b/patches/server/Paper-config-files.patch @@ -18,8 +18,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -0,0 +0,0 @@ dependencies { - implementation("org.ow2.asm:asm:9.4") - implementation("org.ow2.asm:asm-commons:9.4") // Paper - ASM event executor generation + implementation("org.ow2.asm:asm:9.5") + implementation("org.ow2.asm:asm-commons:9.5") // Paper - ASM event executor generation testImplementation("org.mockito:mockito-core:4.9.0") // Paper - switch to mockito + implementation("org.spongepowered:configurate-yaml:4.1.2") // Paper - config files implementation("commons-lang:commons-lang:2.6") @@ -4822,5 +4822,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 DummyEnchantments.setup(); + io.papermc.paper.configuration.GlobalConfigTestingBase.setupGlobalConfigForTest(); // Paper - ImmutableList.Builder builder = ImmutableList.builder(); - for (Material m : Material.values()) { + CraftRegistry.setMinecraftRegistry(REGISTRY_CUSTOM); + diff --git a/patches/server/SculkCatalyst-bloom-API.patch b/patches/server/SculkCatalyst-bloom-API.patch index e0eb96ae73..cd002a46cc 100644 --- a/patches/server/SculkCatalyst-bloom-API.patch +++ b/patches/server/SculkCatalyst-bloom-API.patch @@ -11,8 +11,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftSculkCatalyst.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSculkCatalyst.java @@ -0,0 +0,0 @@ public class CraftSculkCatalyst extends CraftBlockEntityState - org.ow2.asm - asm -- 9.4 +- 9.5 - compile - - diff --git a/patches/server/Test-changes.patch b/patches/server/Test-changes.patch index 271362b6d8..a51cf56462 100644 --- a/patches/server/Test-changes.patch +++ b/patches/server/Test-changes.patch @@ -10,8 +10,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/build.gradle.kts @@ -0,0 +0,0 @@ dependencies { implementation("org.apache.logging.log4j:log4j-iostreams:2.19.0") // Paper - remove exclusion - implementation("org.ow2.asm:asm:9.4") - implementation("org.ow2.asm:asm-commons:9.4") // Paper - ASM event executor generation + implementation("org.ow2.asm:asm:9.5") + implementation("org.ow2.asm:asm-commons:9.5") // Paper - ASM event executor generation + testImplementation("org.mockito:mockito-core:4.9.0") // Paper - switch to mockito implementation("commons-lang:commons-lang:2.6") runtimeOnly("org.xerial:sqlite-jdbc:3.42.0.0") @@ -99,6 +99,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import java.util.Iterator; +import java.util.function.Supplier; ++import java.util.stream.Stream; ++import java.util.stream.StreamSupport; +import org.bukkit.Keyed; +import org.bukkit.NamespacedKey; +import org.bukkit.Registry; @@ -117,6 +119,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public @Nullable Keyed get(@NotNull final NamespacedKey key) { + return this.supplier().get().get(key); + } ++ ++ @Override ++ public @NotNull Stream stream() { ++ return StreamSupport.stream(this.supplier.get().spliterator(), false); ++ } +} diff --git a/src/test/java/org/bukkit/support/AbstractTestingBase.java b/src/test/java/org/bukkit/support/AbstractTestingBase.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -137,7 +144,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - DummyServer.setup(); DummyEnchantments.setup(); - ImmutableList.Builder builder = ImmutableList.builder(); + CraftRegistry.setMinecraftRegistry(REGISTRY_CUSTOM); diff --git a/src/test/java/org/bukkit/support/DummyServer.java b/src/test/java/org/bukkit/support/DummyServer.java deleted file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 diff --git a/patches/server/Use-TerminalConsoleAppender-for-console-improvements.patch b/patches/server/Use-TerminalConsoleAppender-for-console-improvements.patch index 7df23676f2..85cafa2b65 100644 --- a/patches/server/Use-TerminalConsoleAppender-for-console-improvements.patch +++ b/patches/server/Use-TerminalConsoleAppender-for-console-improvements.patch @@ -58,8 +58,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + alsoShade(log4jPlugins.output) + // Paper end implementation("org.apache.logging.log4j:log4j-iostreams:2.19.0") // Paper - remove exclusion - implementation("org.ow2.asm:asm:9.4") - implementation("org.ow2.asm:asm-commons:9.4") // Paper - ASM event executor generation + implementation("org.ow2.asm:asm:9.5") + implementation("org.ow2.asm:asm-commons:9.5") // Paper - ASM event executor generation @@ -0,0 +0,0 @@ relocation { } diff --git a/work/Bukkit b/work/Bukkit index 6b34da8f0c..69c7ce23f2 160000 --- a/work/Bukkit +++ b/work/Bukkit @@ -1 +1 @@ -Subproject commit 6b34da8f0c34fb308c825d3e12abf9cf5bac6ab9 +Subproject commit 69c7ce23f295a5bf1b1b7128bc1daece4ead768e diff --git a/work/CraftBukkit b/work/CraftBukkit index db4ba28978..78796c9de6 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit db4ba289785418d608eeca8dec2013e513adf9ad +Subproject commit 78796c9de6c7c5f64c51a627ee36a7b972f57878