Fixed the alchemy properly (#4658)

This commit is contained in:
NemuruYama 2021-11-14 17:05:42 +01:00 committed by GitHub
parent 5b1a69b3f7
commit ba1f15b655
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,6 +22,7 @@ import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
public final class AlchemyPotionBrewer { public final class AlchemyPotionBrewer {
@ -113,8 +114,8 @@ public final class AlchemyPotionBrewer {
return; return;
} }
List<AlchemyPotion> inputList = new ArrayList<>(); List<AlchemyPotion> inputList = new ArrayList<>(Collections.nCopies(3, null));
var outputList = new ArrayList<ItemStack>(); List<ItemStack> outputList = new ArrayList<>(Collections.nCopies(3, null));
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
ItemStack item = inventory.getItem(i); ItemStack item = inventory.getItem(i);
@ -126,10 +127,10 @@ public final class AlchemyPotionBrewer {
AlchemyPotion input = PotionConfig.getInstance().getPotion(item); AlchemyPotion input = PotionConfig.getInstance().getPotion(item);
AlchemyPotion output = input.getChild(ingredient); AlchemyPotion output = input.getChild(ingredient);
inputList.add(input); inputList.set(i, input);
if (output != null) { 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); removeIngredient(inventory, player);
for (AlchemyPotion input : inputList) { for (AlchemyPotion input : inputList) {
if (input == null) continue;;
AlchemyPotion output = input.getChild(ingredient); AlchemyPotion output = input.getChild(ingredient);
if (output != null && player != null) { if (output != null && player != null) {