From 443c5062c1b636e169707c2dcd7eb3ab5d6c7ed9 Mon Sep 17 00:00:00 2001 From: Peter Crawley <49043380+Peter-Crawley@users.noreply.github.com> Date: Sat, 2 Apr 2022 04:14:56 +0100 Subject: [PATCH] Fix Nullability Annotations for PrepareItemEnchantEvent (#7681) --- .../0175-Fix-Spigot-annotation-mistakes.patch | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/patches/api/0175-Fix-Spigot-annotation-mistakes.patch b/patches/api/0175-Fix-Spigot-annotation-mistakes.patch index 26d3650870..17b24dd5d2 100644 --- a/patches/api/0175-Fix-Spigot-annotation-mistakes.patch +++ b/patches/api/0175-Fix-Spigot-annotation-mistakes.patch @@ -103,9 +103,18 @@ index f124b35ec76e6cb6a1a0dc464005087043c3efd0..94a2fef0dc9e13c754cd31d5eabc1bde +@Deprecated // Paper public interface LingeringPotion extends ThrownPotion { } diff --git a/src/main/java/org/bukkit/event/enchantment/PrepareItemEnchantEvent.java b/src/main/java/org/bukkit/event/enchantment/PrepareItemEnchantEvent.java -index 2ff1b1308571d8f8056d3359e8a8ba4a589c3726..e669ad8ecd182c6899c7820414e6ee1f7312d699 100644 +index 2ff1b1308571d8f8056d3359e8a8ba4a589c3726..8eb6f4090578d9e1b12aff813840108fdeece730 100644 --- a/src/main/java/org/bukkit/event/enchantment/PrepareItemEnchantEvent.java +++ b/src/main/java/org/bukkit/event/enchantment/PrepareItemEnchantEvent.java +@@ -23,7 +23,7 @@ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellab + private boolean cancelled; + private final Player enchanter; + +- public PrepareItemEnchantEvent(@NotNull final Player enchanter, @NotNull InventoryView view, @NotNull final Block table, @NotNull final ItemStack item, @NotNull final EnchantmentOffer[] offers, final int bonus) { ++ public PrepareItemEnchantEvent(@NotNull final Player enchanter, @NotNull InventoryView view, @NotNull final Block table, @NotNull final ItemStack item, @org.jetbrains.annotations.Nullable final EnchantmentOffer @NotNull [] offers, final int bonus) { // Paper - offers can contain null values + super(view); + this.enchanter = enchanter; + this.table = table; @@ -68,6 +68,7 @@ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellab * @return experience level costs offered * @deprecated Use {@link #getOffers()} instead of this method @@ -114,6 +123,16 @@ index 2ff1b1308571d8f8056d3359e8a8ba4a589c3726..e669ad8ecd182c6899c7820414e6ee1f @NotNull public int[] getExpLevelCostsOffered() { int[] levelOffers = new int[offers.length]; +@@ -85,8 +86,7 @@ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellab + * + * @return list of available enchantment offers + */ +- @NotNull +- public EnchantmentOffer[] getOffers() { ++ public @org.jetbrains.annotations.Nullable EnchantmentOffer @NotNull [] getOffers() { // Paper offers can contain null values + return offers; + } + diff --git a/src/main/java/org/bukkit/inventory/CraftingInventory.java b/src/main/java/org/bukkit/inventory/CraftingInventory.java index df81bac9ecff697f98941e5c8490e10391e90090..a32977ba3ba60a1c9aee6e469d5d6cd1887c55a2 100644 --- a/src/main/java/org/bukkit/inventory/CraftingInventory.java