Fix NPE with enchantable (#11557)

This commit is contained in:
Lulu13022002 2024-11-09 23:26:01 +01:00 committed by GitHub
parent 9d1c91d083
commit 59b79c8bbb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
44 changed files with 189 additions and 138 deletions

View file

@ -207,10 +207,10 @@ index 3470755c65a2db38e679adc35d3d43f7fef5468d..1fe3a5e2f5c15fddfbcd503a061ebf75
return server.getRegistry(tClass);
}
diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java
index b4f297f90e3c1deaa1fc3f4418418588ab19b6c5..099c8acc0338dc0e6ac81f77d99cd2a02a630535 100644
index b4f297f90e3c1deaa1fc3f4418418588ab19b6c5..46dce7c2a543f6b165975565ea9d40654a132b9b 100644
--- a/src/main/java/org/bukkit/Registry.java
+++ b/src/main/java/org/bukkit/Registry.java
@@ -86,26 +86,34 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
@@ -86,26 +86,32 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
* Server art.
*
* @see Art
@ -223,11 +223,9 @@ index b4f297f90e3c1deaa1fc3f4418418588ab19b6c5..099c8acc0338dc0e6ac81f77d99cd2a0
* Attribute.
*
* @see Attribute
+ * @deprecated use {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)} with {@link io.papermc.paper.registry.RegistryKey#ATTRIBUTE}
*/
- Registry<Attribute> ATTRIBUTE = Objects.requireNonNull(Bukkit.getRegistry(Attribute.class), "No registry present for Attribute. This is a bug.");
+ @Deprecated(since = "1.21.3") // Paper
+ Registry<Attribute> ATTRIBUTE = Objects.requireNonNull(io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(Attribute.class), "No registry present for Attribute. This is a bug.");
+ Registry<Attribute> ATTRIBUTE = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.ATTRIBUTE); // Paper
/**
* Server banner patterns.
*
@ -249,7 +247,7 @@ index b4f297f90e3c1deaa1fc3f4418418588ab19b6c5..099c8acc0338dc0e6ac81f77d99cd2a0
/**
* Server block types.
*
@@ -113,7 +121,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
@@ -113,7 +119,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
* @apiNote BlockType is not ready for public usage yet
*/
@ApiStatus.Internal
@ -258,7 +256,7 @@ index b4f297f90e3c1deaa1fc3f4418418588ab19b6c5..099c8acc0338dc0e6ac81f77d99cd2a0
/**
* Custom boss bars.
*
@@ -155,13 +163,15 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
@@ -155,13 +161,15 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
*
* @see Cat.Type
*/
@ -276,12 +274,15 @@ index b4f297f90e3c1deaa1fc3f4418418588ab19b6c5..099c8acc0338dc0e6ac81f77d99cd2a0
/**
* Server entity types.
*
@@ -173,7 +183,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
@@ -172,8 +180,10 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
* Server instruments.
*
* @see MusicInstrument
+ * @deprecated use {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)} with {@link io.papermc.paper.registry.RegistryKey#INSTRUMENT}
*/
- Registry<MusicInstrument> INSTRUMENT = Objects.requireNonNull(Bukkit.getRegistry(MusicInstrument.class), "No registry present for MusicInstrument. This is a bug.");
+ Registry<MusicInstrument> INSTRUMENT = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.INSTRUMENT); // Paper
+ @Deprecated(since = "1.21.2")
+ Registry<MusicInstrument> INSTRUMENT = Objects.requireNonNull(io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(MusicInstrument.class), "No registry present for Instruments. This is a bug."); // Paper
/**
* Server item types.
*
@ -388,15 +389,12 @@ index b4f297f90e3c1deaa1fc3f4418418588ab19b6c5..099c8acc0338dc0e6ac81f77d99cd2a0
/**
* Memory Keys.
*
@@ -320,32 +339,36 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
* Server fluids.
@@ -321,31 +340,33 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
*
* @see Fluid
+ * @deprecated use {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)} with {@link io.papermc.paper.registry.RegistryKey#FLUID}
*/
- Registry<Fluid> FLUID = Objects.requireNonNull(Bukkit.getRegistry(Fluid.class), "No registry present for Fluid. This is a bug.");
+ @Deprecated(since = "1.21.3")
+ Registry<Fluid> FLUID = Objects.requireNonNull(io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(Fluid.class), "No registry present for Fluid. This is a bug.");
+ Registry<Fluid> FLUID = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.FLUID); // Paper
/**
* Frog variants.
*