aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/1014-Registry-Modification-API.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/server/1014-Registry-Modification-API.patch')
-rw-r--r--patches/server/1014-Registry-Modification-API.patch93
1 files changed, 80 insertions, 13 deletions
diff --git a/patches/server/1014-Registry-Modification-API.patch b/patches/server/1014-Registry-Modification-API.patch
index c31982d8a2..dba4fa5830 100644
--- a/patches/server/1014-Registry-Modification-API.patch
+++ b/patches/server/1014-Registry-Modification-API.patch
@@ -935,10 +935,10 @@ index 0000000000000000000000000000000000000000..7ee77022198bf5f9f88c6a1917a1da30
+ }
+}
diff --git a/src/main/java/io/papermc/paper/registry/legacy/DelayedRegistry.java b/src/main/java/io/papermc/paper/registry/legacy/DelayedRegistry.java
-index 5562e8da5ebaef2a3add46e88d64358b7737b59e..e5880f76cdb8ebf01fcefdf77ba9b95674b997a8 100644
+index 9400fed345344a0a8e4fb301cca6a1867adf625b..0cdc92acd3ebb6efb10e1b66419cc05618301581 100644
--- a/src/main/java/io/papermc/paper/registry/legacy/DelayedRegistry.java
+++ b/src/main/java/io/papermc/paper/registry/legacy/DelayedRegistry.java
-@@ -1,12 +1,13 @@
+@@ -1,5 +1,7 @@
package io.papermc.paper.registry.legacy;
+import io.papermc.paper.registry.tag.Tag;
@@ -946,6 +946,7 @@ index 5562e8da5ebaef2a3add46e88d64358b7737b59e..e5880f76cdb8ebf01fcefdf77ba9b956
import java.util.Iterator;
import java.util.function.Supplier;
import java.util.stream.Stream;
+@@ -7,7 +9,6 @@ import net.kyori.adventure.key.Key;
import org.bukkit.Keyed;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
@@ -953,7 +954,7 @@ index 5562e8da5ebaef2a3add46e88d64358b7737b59e..e5880f76cdb8ebf01fcefdf77ba9b956
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.jetbrains.annotations.NotNull;
-@@ -52,4 +53,14 @@ public final class DelayedRegistry<T extends Keyed, R extends Registry<T>> imple
+@@ -58,4 +59,14 @@ public final class DelayedRegistry<T extends Keyed, R extends Registry<T>> imple
public NamespacedKey getKey(final T value) {
return this.delegate().getKey(value);
}
@@ -1321,7 +1322,7 @@ index 397bdacab9517354875ebc0bc68d35059b3c318b..908431652a0fea79b5a0cee1efd0c7a7
return writableRegistry;
},
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java
-index bd16933a5341908b21e549f66080c33466ad1079..90046c85ce1b9901de7476761da156141249300a 100644
+index 4dff173bbed34a49c22532bbee2b35ebf5920d22..53c70846666b746af6706ed2e363fe388e463e56 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java
@@ -167,11 +167,11 @@ public class CraftRegistry<B extends Keyed, M> implements Registry<B> {
@@ -1338,7 +1339,7 @@ index bd16933a5341908b21e549f66080c33466ad1079..90046c85ce1b9901de7476761da15614
this.bukkitClass = bukkitClass;
this.minecraftRegistry = minecraftRegistry;
this.minecraftToBukkit = minecraftToBukkit;
-@@ -244,4 +244,17 @@ public class CraftRegistry<B extends Keyed, M> implements Registry<B> {
+@@ -254,4 +254,17 @@ public class CraftRegistry<B extends Keyed, M> implements Registry<B> {
return this.byValue.get(value);
}
// Paper end - improve Registry
@@ -1357,10 +1358,10 @@ index bd16933a5341908b21e549f66080c33466ad1079..90046c85ce1b9901de7476761da15614
+ // Paper end - RegistrySet API
}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
-index 9e0d8fc51196ca07677f45e41614262036155e85..0286375531b944ce572708e6c7cc9982e0d2b5b8 100644
+index 9f2ddd47dc0658db2f95ef80543fb9a4d2f94f9f..68a6cd43042e87501f5bd48565222638dd58a1cf 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
-@@ -668,6 +668,21 @@ public final class CraftMagicNumbers implements UnsafeValues {
+@@ -674,6 +674,21 @@ public final class CraftMagicNumbers implements UnsafeValues {
}
// Paper end - lifecycle event API
@@ -1391,10 +1392,10 @@ index 0000000000000000000000000000000000000000..8bee1a5ed877a04e4d027593df1f42ce
+io.papermc.paper.registry.event.RegistryEventTypeProviderImpl
diff --git a/src/test/java/io/papermc/paper/registry/RegistryBuilderTest.java b/src/test/java/io/papermc/paper/registry/RegistryBuilderTest.java
new file mode 100644
-index 0000000000000000000000000000000000000000..f27e5e0037b719b1fc10703f8d298d2326b00432
+index 0000000000000000000000000000000000000000..47b8ebac8496179008b8932c5ca2aadc274e24e0
--- /dev/null
+++ b/src/test/java/io/papermc/paper/registry/RegistryBuilderTest.java
-@@ -0,0 +1,34 @@
+@@ -0,0 +1,36 @@
+package io.papermc.paper.registry;
+
+import io.papermc.paper.registry.data.util.Conversions;
@@ -1403,7 +1404,8 @@ index 0000000000000000000000000000000000000000..f27e5e0037b719b1fc10703f8d298d23
+import net.minecraft.core.Registry;
+import net.minecraft.resources.RegistryOps;
+import net.minecraft.resources.ResourceKey;
-+import org.bukkit.support.AbstractTestingBase;
++import org.bukkit.support.RegistryHelper;
++import org.bukkit.support.environment.AllFeatures;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
@@ -1411,7 +1413,8 @@ index 0000000000000000000000000000000000000000..f27e5e0037b719b1fc10703f8d298d23
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
-+class RegistryBuilderTest extends AbstractTestingBase {
++@AllFeatures
++class RegistryBuilderTest {
+
+ static List<Arguments> registries() {
+ return List.of(
@@ -1422,10 +1425,74 @@ index 0000000000000000000000000000000000000000..f27e5e0037b719b1fc10703f8d298d23
+ @ParameterizedTest
+ @MethodSource("registries")
+ <M, T> void testEquality(final ResourceKey<? extends Registry<M>> resourceKey, final PaperRegistryBuilder.Filler<M, T, ?> filler) {
-+ final Registry<M> registry = AbstractTestingBase.REGISTRY_CUSTOM.registryOrThrow(resourceKey);
++ final Registry<M> registry = RegistryHelper.getRegistry().registryOrThrow(resourceKey);
+ for (final Map.Entry<ResourceKey<M>, M> entry : registry.entrySet()) {
-+ final M built = filler.fill(new Conversions(new RegistryOps.HolderLookupAdapter(AbstractTestingBase.REGISTRY_CUSTOM)), PaperRegistries.fromNms(entry.getKey()), entry.getValue()).build();
++ final M built = filler.fill(new Conversions(new RegistryOps.HolderLookupAdapter(RegistryHelper.getRegistry())), PaperRegistries.fromNms(entry.getKey()), entry.getValue()).build();
+ assertEquals(entry.getValue(), built);
+ }
+ }
+}
+diff --git a/src/test/java/org/bukkit/registry/RegistryClassTest.java b/src/test/java/org/bukkit/registry/RegistryClassTest.java
+index 575a06125e0b60b5bb8b6f85131f7d6cf86f5083..85f93d8c9b3a48b267e0575ba7fbb3b9f273e70c 100644
+--- a/src/test/java/org/bukkit/registry/RegistryClassTest.java
++++ b/src/test/java/org/bukkit/registry/RegistryClassTest.java
+@@ -111,7 +111,7 @@ public class RegistryClassTest {
+ outsideRequest.clear();
+ MockUtil.resetMock(spyRegistry);
+ doAnswer(invocation -> {
+- Keyed item = realRegistry.get(invocation.getArgument(0));
++ Keyed item = realRegistry.get((NamespacedKey) invocation.getArgument(0)); // Paper - registry modification api - specifically call namespaced key overload
+
+ if (item == null) {
+ nullValue.add(invocation.getArgument(0));
+@@ -120,10 +120,10 @@ public class RegistryClassTest {
+ nullAble.add(invocation.getArgument(0));
+
+ return item;
+- }).when(spyRegistry).get(any());
++ }).when(spyRegistry).get((NamespacedKey) any()); // Paper - registry modification api - specifically call namespaced key overload
+
+ doAnswer(invocation -> {
+- Keyed item = realRegistry.get(invocation.getArgument(0));
++ Keyed item = realRegistry.get((NamespacedKey) invocation.getArgument(0)); // Paper - registry modification api - specifically call namespaced key overload
+
+ if (item == null) {
+ nullValue.add(invocation.getArgument(0));
+@@ -138,7 +138,7 @@ public class RegistryClassTest {
+ notNullAble.add(invocation.getArgument(0));
+
+ return item;
+- }).when(spyRegistry).getOrThrow(any());
++ }).when(spyRegistry).getOrThrow((NamespacedKey) any()); // Paper - registry modification api - specifically call namespaced key overload
+
+ // Load class
+ try {
+@@ -171,13 +171,13 @@ public class RegistryClassTest {
+ outsideRequest
+ .computeIfAbsent(type, ty -> new ArrayList<>()).add(invocation.getArgument(0));
+ return mock(type);
+- }).when(spyRegistry).get(any());
++ }).when(spyRegistry).get((NamespacedKey) any()); // Paper - registry modification api - specifically call namespaced key overload
+
+ doAnswer(invocation -> {
+ outsideRequest
+ .computeIfAbsent(type, ty -> new ArrayList<>()).add(invocation.getArgument(0));
+ return mock(type);
+- }).when(spyRegistry).getOrThrow(any());
++ }).when(spyRegistry).getOrThrow((NamespacedKey) any()); // Paper - registry modification api - specifically call namespaced key overload
+ }
+
+ private static void initFieldDataCache() {
+diff --git a/src/test/java/org/bukkit/support/extension/NormalExtension.java b/src/test/java/org/bukkit/support/extension/NormalExtension.java
+index 8b5dcc4d0ecf7f9c51f73080c123ca08e31b1898..a809ea2f0d2b477c61857aa02a7e55024b2a7e0d 100644
+--- a/src/test/java/org/bukkit/support/extension/NormalExtension.java
++++ b/src/test/java/org/bukkit/support/extension/NormalExtension.java
+@@ -62,7 +62,7 @@ public class NormalExtension extends BaseExtension {
+
+ doAnswer(invocation ->
+ mocks.computeIfAbsent(invocation.getArgument(0), k -> mock(RegistryHelper.updateClass(keyed, invocation.getArgument(0)), withSettings().stubOnly().defaultAnswer(DEFAULT_ANSWER)))
+- ).when(registry).get(any()); // Allow static classes to fill there fields, so that it does not error out, just by loading them
++ ).when(registry).get((NamespacedKey) any()); // Allow static classes to fill there fields, so that it does not error out, just by loading them // Paper - registry modification api - specifically call namespaced key overload
+
+ return registry;
+ }