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
This commit is contained in:
Jake Potrebic 2023-09-21 09:48:55 -07:00
parent 6cc04e3081
commit efc1f99846
19 changed files with 99 additions and 395 deletions

View file

@ -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) {

View file

@ -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<T extends Keyed> extends Iterable<T> {
return GameEvent.getByKey(key);
}
};
* @see GameEvent
*/
Registry<GameEvent> 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<io.papermc.paper.world.structure.ConfiguredStructure> CONFIGURED_STRUCTURE = Bukkit.getRegistry(io.papermc.paper.world.structure.ConfiguredStructure.class);
+ // Paper end
+
/**
* Get the object by its key.
*

View file

@ -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<NamespacedKey, MusicInstrument> 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
}

View file

@ -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
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <version>5.5.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ow2.asm</groupId>
- <artifactId>asm-tree</artifactId>
- <version>9.5</version>

View file

@ -31,6 +31,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public Iterator<org.bukkit.potion.PotionEffectType> iterator() {
+ return Arrays.stream(org.bukkit.potion.PotionEffectType.values()).iterator();
+ }
+
+ @Override
+ public @NotNull Stream<org.bukkit.potion.PotionEffectType> stream() {
+ return StreamSupport.stream(this.spliterator(), false);
+ }
+ };
// Paper end

View file

@ -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);

View file

@ -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
}

View file

@ -12,47 +12,6 @@ Subject: [PATCH] Test changes
Co-authored-by: Riley Park <rileysebastianpark@gmail.com>
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
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<Keyed> {
+
+ @NotNull
+ @Override
+ public Iterator<Keyed> 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<Method, Object[]>() {
@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<Method, MethodHandler> methods;
-
- static {
- try {
- ImmutableMap.Builder<Method, MethodHandler> 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<Method, MethodHandler> 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

View file

@ -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);
+ }

View file

@ -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

View file

@ -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")

View file

@ -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");

View file

@ -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<Material> builder = ImmutableList.builder();
for (Material m : Material.values()) {
CraftRegistry.setMinecraftRegistry(REGISTRY_CUSTOM);

View file

@ -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<SculkCatalystBlock
public CraftSculkCatalyst(World world, SculkCatalystBlockEntity tileEntity) {
super(world, tileEntity);
getTileEntity().getListener().bloom(world.getHandle(), getPosition(), getHandle(), world.getHandle().getRandom());
getTileEntity().getListener().getSculkSpreader().addCursors(new BlockPos(block.getX(), block.getY(), block.getZ()), charge);
}
+
+ // Paper start - SculkCatalyst bloom API

View file

@ -46,7 +46,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ implementation("org.apache.logging.log4j:log4j-iostreams:2.19.0") {
+ exclude(group = "org.apache.logging.log4j", module = "log4j-api")
+ }
+ implementation("org.ow2.asm:asm:9.4")
+ implementation("org.ow2.asm:asm:9.5")
+ 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")
@ -239,7 +239,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- <dependency>
- <groupId>org.ow2.asm</groupId>
- <artifactId>asm</artifactId>
- <version>9.4</version>
- <version>9.5</version>
- <scope>compile</scope>
- </dependency>
- <!-- Mojang depends -->

View file

@ -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<Keyed> 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<Material> 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

View file

@ -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 {
}

@ -1 +1 @@
Subproject commit 6b34da8f0c34fb308c825d3e12abf9cf5bac6ab9
Subproject commit 69c7ce23f295a5bf1b1b7128bc1daece4ead768e

@ -1 +1 @@
Subproject commit db4ba289785418d608eeca8dec2013e513adf9ad
Subproject commit 78796c9de6c7c5f64c51a627ee36a7b972f57878