From ba1f15b65556552220bde10f8ef5841e86802ef0 Mon Sep 17 00:00:00 2001 From: NemuruYama Date: Sun, 14 Nov 2021 17:05:42 +0100 Subject: [PATCH] Fixed the alchemy properly (#4658) --- .../nossr50/skills/alchemy/AlchemyPotionBrewer.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java index c6e8cff4d..2a7559af7 100644 --- a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java +++ b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java @@ -22,6 +22,7 @@ import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; import java.util.ArrayList; +import java.util.Collections; import java.util.List; public final class AlchemyPotionBrewer { @@ -113,8 +114,8 @@ public final class AlchemyPotionBrewer { return; } - List inputList = new ArrayList<>(); - var outputList = new ArrayList(); + List inputList = new ArrayList<>(Collections.nCopies(3, null)); + List outputList = new ArrayList<>(Collections.nCopies(3, null)); for (int i = 0; i < 3; i++) { ItemStack item = inventory.getItem(i); @@ -126,10 +127,10 @@ public final class AlchemyPotionBrewer { AlchemyPotion input = PotionConfig.getInstance().getPotion(item); AlchemyPotion output = input.getChild(ingredient); - inputList.add(input); + inputList.set(i, input); if (output != null) { - outputList.add(output.toItemStack(item.getAmount()).clone()); + outputList.set(i, output.toItemStack(item.getAmount()).clone()); } } @@ -149,6 +150,8 @@ public final class AlchemyPotionBrewer { removeIngredient(inventory, player); for (AlchemyPotion input : inputList) { + if (input == null) continue;; + AlchemyPotion output = input.getChild(ingredient); if (output != null && player != null) {