Fix NPE with enchantable (#11557)
This commit is contained in:
parent
9d1c91d083
commit
59b79c8bbb
44 changed files with 189 additions and 138 deletions
|
@ -85,7 +85,7 @@ index 0000000000000000000000000000000000000000..2512dba27edfdccbc4430815b6cba048
|
|||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/registry/RegistryKey.java b/src/main/java/io/papermc/paper/registry/RegistryKey.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..d895b36e14f7fab6e3e78160dfa559d2c5331601
|
||||
index 0000000000000000000000000000000000000000..647f6a1ec1f9d3c203b41f90a99bfd415bf67366
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/registry/RegistryKey.java
|
||||
@@ -0,0 +1,196 @@
|
||||
|
@ -155,11 +155,6 @@ index 0000000000000000000000000000000000000000..d895b36e14f7fab6e3e78160dfa559d2
|
|||
+ */
|
||||
+ RegistryKey<StructureType> STRUCTURE_TYPE = create("worldgen/structure_type");
|
||||
+ /**
|
||||
+ * Built-in registry for instruments.
|
||||
+ * @see io.papermc.paper.registry.keys.InstrumentKeys
|
||||
+ */
|
||||
+ RegistryKey<MusicInstrument> INSTRUMENT = create("instrument");
|
||||
+ /**
|
||||
+ * Built-in registry for potion effect types (mob effects).
|
||||
+ * @see io.papermc.paper.registry.keys.MobEffectKeys
|
||||
+ */
|
||||
|
@ -275,6 +270,11 @@ index 0000000000000000000000000000000000000000..d895b36e14f7fab6e3e78160dfa559d2
|
|||
+ * @see io.papermc.paper.registry.keys.PaintingVariantKeys
|
||||
+ */
|
||||
+ RegistryKey<Art> PAINTING_VARIANT = create("painting_variant");
|
||||
+ /**
|
||||
+ * Data-driven registry for instruments.
|
||||
+ * @see io.papermc.paper.registry.keys.InstrumentKeys
|
||||
+ */
|
||||
+ RegistryKey<MusicInstrument> INSTRUMENT = create("instrument");
|
||||
+
|
||||
+
|
||||
+ /* ******************* *
|
||||
|
|
|
@ -187,7 +187,7 @@ index 309a79cbe65498c90d9e135607bc246688ac6274..8820dd330cee4f8463f2f39f84d4be07
|
|||
if (this.isItem()) {
|
||||
return asItemType().getTranslationKey();
|
||||
diff --git a/src/main/java/org/bukkit/MusicInstrument.java b/src/main/java/org/bukkit/MusicInstrument.java
|
||||
index 807e89d026bffae521ead39c514a872ae4d406b3..c9f02466a04d20579fe2258bb02acf98e163ca81 100644
|
||||
index 807e89d026bffae521ead39c514a872ae4d406b3..f87364de1bf24ee78e0d823d9081a5f352934405 100644
|
||||
--- a/src/main/java/org/bukkit/MusicInstrument.java
|
||||
+++ b/src/main/java/org/bukkit/MusicInstrument.java
|
||||
@@ -6,7 +6,7 @@ import java.util.Collections;
|
||||
|
@ -199,17 +199,20 @@ index 807e89d026bffae521ead39c514a872ae4d406b3..c9f02466a04d20579fe2258bb02acf98
|
|||
|
||||
public static final MusicInstrument PONDER_GOAT_HORN = getInstrument("ponder_goat_horn");
|
||||
public static final MusicInstrument SING_GOAT_HORN = getInstrument("sing_goat_horn");
|
||||
@@ -46,4 +46,11 @@ public abstract class MusicInstrument implements Keyed {
|
||||
@@ -46,4 +46,14 @@ public abstract class MusicInstrument implements Keyed {
|
||||
private static MusicInstrument getInstrument(@NotNull String key) {
|
||||
return Registry.INSTRUMENT.getOrThrow(NamespacedKey.minecraft(key));
|
||||
}
|
||||
+
|
||||
+ // Paper start - translation key
|
||||
+ // Paper start - mark translation key as deprecated
|
||||
+ /**
|
||||
+ * @deprecated this method assumes that the instrument description
|
||||
+ * always be a translatable component which is not guaranteed.
|
||||
+ */
|
||||
+ @Override
|
||||
+ public @NotNull String translationKey() {
|
||||
+ return "instrument.minecraft." + this.getKey().value();
|
||||
+ }
|
||||
+ // Paper end - translation key
|
||||
+ @Deprecated(forRemoval = true)
|
||||
+ public abstract @NotNull String translationKey();
|
||||
+ // Paper end - mark translation key as deprecated
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/Translatable.java b/src/main/java/org/bukkit/Translatable.java
|
||||
index e3faa2c675c85a9cbdbbb1debec0ff81c58a1bbd..fd1629c2d2028a88fb3d56b0aeb833d17235080a 100644
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -5,10 +5,10 @@ Subject: [PATCH] More PotionEffectType API
|
|||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java
|
||||
index 099c8acc0338dc0e6ac81f77d99cd2a02a630535..a5db0a013921423f87abb14dc08b24f47d4093f6 100644
|
||||
index 46dce7c2a543f6b165975565ea9d40654a132b9b..ae76b0d2b84dda5eefb9ffd9d76383408f67fbe3 100644
|
||||
--- a/src/main/java/org/bukkit/Registry.java
|
||||
+++ b/src/main/java/org/bukkit/Registry.java
|
||||
@@ -369,6 +369,15 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
||||
@@ -367,6 +367,15 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
||||
* @see GameEvent
|
||||
*/
|
||||
Registry<GameEvent> GAME_EVENT = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.GAME_EVENT); // Paper
|
||||
|
|
|
@ -31,7 +31,7 @@ index d24bf449f58fd7c1b8ffab8dbc42f9f1fef8c4ef..00a290f1bf58cdc2238c13fd5a6048a2
|
|||
* Get a painting by its numeric ID
|
||||
*
|
||||
diff --git a/src/main/java/org/bukkit/MusicInstrument.java b/src/main/java/org/bukkit/MusicInstrument.java
|
||||
index c9f02466a04d20579fe2258bb02acf98e163ca81..bffd4ab2d08e5c3f83a49a31e1e55cc1eab7b319 100644
|
||||
index f87364de1bf24ee78e0d823d9081a5f352934405..84edda17692eca0f21eeb01a9eb94eba81c356ab 100644
|
||||
--- a/src/main/java/org/bukkit/MusicInstrument.java
|
||||
+++ b/src/main/java/org/bukkit/MusicInstrument.java
|
||||
@@ -47,6 +47,16 @@ public abstract class MusicInstrument implements Keyed, net.kyori.adventure.tran
|
||||
|
@ -40,22 +40,22 @@ index c9f02466a04d20579fe2258bb02acf98e163ca81..bffd4ab2d08e5c3f83a49a31e1e55cc1
|
|||
|
||||
+ // Paper start - deprecate getKey
|
||||
+ /**
|
||||
+ * @deprecated use {@link Registry#getKey(Keyed)} and {@link Registry#INSTRUMENT}. MusicInstruments
|
||||
+ * can exist without a key.
|
||||
+ * @deprecated use {@link Registry#getKey(Keyed)}, {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)},
|
||||
+ * and {@link io.papermc.paper.registry.RegistryKey#INSTRUMENT}. MusicInstruments can exist without a key.
|
||||
+ */
|
||||
+ @Deprecated(forRemoval = true, since = "1.20.5")
|
||||
+ @Override
|
||||
+ public abstract @NotNull NamespacedKey getKey();
|
||||
+ // Paper end - deprecate getKey
|
||||
+
|
||||
// Paper start - translation key
|
||||
@Override
|
||||
public @NotNull String translationKey() {
|
||||
// Paper start - mark translation key as deprecated
|
||||
/**
|
||||
* @deprecated this method assumes that the instrument description
|
||||
diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java
|
||||
index a5db0a013921423f87abb14dc08b24f47d4093f6..9ed61b649d7e7056bd9ebcbb77f17c6c5798bf2d 100644
|
||||
index ae76b0d2b84dda5eefb9ffd9d76383408f67fbe3..67b9ab322baecf5b2453df4795106514cb073108 100644
|
||||
--- a/src/main/java/org/bukkit/Registry.java
|
||||
+++ b/src/main/java/org/bukkit/Registry.java
|
||||
@@ -387,6 +387,79 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
||||
@@ -385,6 +385,79 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
||||
@Nullable
|
||||
T get(@NotNull NamespacedKey key);
|
||||
|
||||
|
@ -135,7 +135,7 @@ index a5db0a013921423f87abb14dc08b24f47d4093f6..9ed61b649d7e7056bd9ebcbb77f17c6c
|
|||
/**
|
||||
* Get the object by its key.
|
||||
*
|
||||
@@ -483,5 +556,12 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
||||
@@ -481,5 +554,12 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
||||
public Class<T> getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ index eaf6cd758344eeba29f00f822a50c93704af8bda..eb192030832e1741850871bec9bf999f
|
|||
@NotNull
|
||||
public NamespacedKey getKey();
|
||||
diff --git a/src/main/java/org/bukkit/generator/structure/Structure.java b/src/main/java/org/bukkit/generator/structure/Structure.java
|
||||
index 20a7fd27ba3a029d58dd18ad9b470ffaed8c9578..a773550549b4093a5fb4ef47284c438dcddd99ab 100644
|
||||
index 20a7fd27ba3a029d58dd18ad9b470ffaed8c9578..542e3e32e77c0b8dfa707193787516f83b884780 100644
|
||||
--- a/src/main/java/org/bukkit/generator/structure/Structure.java
|
||||
+++ b/src/main/java/org/bukkit/generator/structure/Structure.java
|
||||
@@ -61,4 +61,13 @@ public abstract class Structure implements Keyed {
|
||||
|
@ -197,8 +197,8 @@ index 20a7fd27ba3a029d58dd18ad9b470ffaed8c9578..a773550549b4093a5fb4ef47284c438d
|
|||
public abstract StructureType getStructureType();
|
||||
+ // Paper start - deprecate getKey
|
||||
+ /**
|
||||
+ * @deprecated use {@link Registry#getKey(Keyed)} and {@link Registry#STRUCTURE}. Structures
|
||||
+ * can exist without a key.
|
||||
+ * @deprecated use {@link Registry#getKey(Keyed)}, {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)},
|
||||
+ * and {@link io.papermc.paper.registry.RegistryKey#STRUCTURE}. Structures can exist without a key.
|
||||
+ */
|
||||
+ @Override
|
||||
+ @Deprecated(since = "1.20.4")
|
||||
|
|
|
@ -809,10 +809,10 @@ index 0000000000000000000000000000000000000000..bf49125acc8a0508bf59674bba3ed350
|
|||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java
|
||||
index 9ed61b649d7e7056bd9ebcbb77f17c6c5798bf2d..16bef936a9aef957a73c33e45be7573584943a6b 100644
|
||||
index 67b9ab322baecf5b2453df4795106514cb073108..7cf7c6d05aa6cbf3f0c8612831404552c6a7b84a 100644
|
||||
--- a/src/main/java/org/bukkit/Registry.java
|
||||
+++ b/src/main/java/org/bukkit/Registry.java
|
||||
@@ -386,6 +386,27 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
||||
@@ -384,6 +384,27 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
||||
*/
|
||||
@Nullable
|
||||
T get(@NotNull NamespacedKey key);
|
||||
|
@ -840,7 +840,7 @@ index 9ed61b649d7e7056bd9ebcbb77f17c6c5798bf2d..16bef936a9aef957a73c33e45be75735
|
|||
|
||||
// Paper start - improve Registry
|
||||
/**
|
||||
@@ -460,6 +481,34 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
||||
@@ -458,6 +479,34 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
||||
}
|
||||
// Paper end - improve Registry
|
||||
|
||||
|
@ -875,7 +875,7 @@ index 9ed61b649d7e7056bd9ebcbb77f17c6c5798bf2d..16bef936a9aef957a73c33e45be75735
|
|||
/**
|
||||
* Get the object by its key.
|
||||
*
|
||||
@@ -563,5 +612,23 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
||||
@@ -561,5 +610,23 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
||||
return value.getKey();
|
||||
}
|
||||
// Paper end - improve Registry
|
||||
|
|
|
@ -5,10 +5,10 @@ Subject: [PATCH] Introduce registry entry and builders
|
|||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/registry/RegistryKey.java b/src/main/java/io/papermc/paper/registry/RegistryKey.java
|
||||
index 8410d7213370f01cbedbf7fac29bac96f150c49a..d8716f855806471728c35b3ec34efb808a5146cf 100644
|
||||
index 647f6a1ec1f9d3c203b41f90a99bfd415bf67366..9b39e33514b15a9d07104e2ad826d0da11f569d6 100644
|
||||
--- a/src/main/java/io/papermc/paper/registry/RegistryKey.java
|
||||
+++ b/src/main/java/io/papermc/paper/registry/RegistryKey.java
|
||||
@@ -79,9 +79,10 @@ public sealed interface RegistryKey<T> extends Keyed permits RegistryKeyImpl {
|
||||
@@ -74,9 +74,10 @@ public sealed interface RegistryKey<T> extends Keyed permits RegistryKeyImpl {
|
||||
@ApiStatus.Internal
|
||||
RegistryKey<BlockType> BLOCK = create("block");
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue