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 b0965734f..a149ded15 100644 --- a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java +++ b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java @@ -56,23 +56,29 @@ public final class AlchemyPotionBrewer { return item == null || item.getType() == Material.AIR || item.getAmount() == 0; } - private static boolean removeIngredient(BrewerInventory inventory, Player player) { + private static void removeIngredient(BrewerInventory inventory, Player player) { ItemStack ingredient = inventory.getIngredient() == null ? null : inventory.getIngredient().clone(); if (isEmpty(ingredient) || !isValidIngredient(player, ingredient)) { - return false; + return; } else if (ingredient.getAmount() <= 1) { inventory.setIngredient(null); - return true; + return; } else { ingredient.setAmount(ingredient.getAmount() - 1); inventory.setIngredient(ingredient); - return true; + return; } } + private static boolean hasIngredient(BrewerInventory inventory, Player player) { + ItemStack ingredient = inventory.getIngredient() == null ? null : inventory.getIngredient().clone(); + + return !isEmpty(ingredient) && isValidIngredient(player, ingredient); + } + public static boolean isValidIngredient(Player player, ItemStack item) { if (isEmpty(item)) { return false; @@ -99,7 +105,7 @@ public final class AlchemyPotionBrewer { BrewerInventory inventory = ((BrewingStand) brewingStand).getInventory(); ItemStack ingredient = inventory.getIngredient() == null ? null : inventory.getIngredient().clone(); - if (!removeIngredient(inventory, player)) { + if (!hasIngredient(inventory, player)) { return; } @@ -129,6 +135,8 @@ public final class AlchemyPotionBrewer { return; } + removeIngredient(inventory, player); + for (AlchemyPotion input : inputList) { AlchemyPotion output = PotionConfig.getInstance().getPotion(input.getChildDataValue(ingredient));