SPIGOT-8014: Add method for getting and setting remaining items in CrafterCraftEvent

This commit is contained in:
md_5 2025-03-09 16:18:27 +11:00
parent c0ecd48cfd
commit b00ec19acf
No known key found for this signature in database
GPG key ID: E8E901AC7C617C11

View file

@ -1,5 +1,7 @@
package org.bukkit.event.block; package org.bukkit.event.block;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
@ -15,12 +17,19 @@ public class CrafterCraftEvent extends BlockEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
private final CraftingRecipe recipe; private final CraftingRecipe recipe;
private ItemStack result; private ItemStack result;
private List<ItemStack> remainingItems;
private boolean cancelled; private boolean cancelled;
@Deprecated
public CrafterCraftEvent(@NotNull Block theBlock, @NotNull CraftingRecipe recipe, @NotNull ItemStack result) { public CrafterCraftEvent(@NotNull Block theBlock, @NotNull CraftingRecipe recipe, @NotNull ItemStack result) {
this(theBlock, recipe, result, new ArrayList<>());
}
public CrafterCraftEvent(@NotNull Block theBlock, @NotNull CraftingRecipe recipe, @NotNull ItemStack result, @NotNull List<ItemStack> remainingItems) {
super(theBlock); super(theBlock);
this.result = result; this.result = result;
this.recipe = recipe; this.recipe = recipe;
this.remainingItems = remainingItems;
} }
/** /**
@ -42,6 +51,16 @@ public class CrafterCraftEvent extends BlockEvent implements Cancellable {
this.result = result.clone(); this.result = result.clone();
} }
/**
* Gets the items that will remain after the recipe has been crafted.
*
* @return a list of the remaining items
*/
@NotNull
public List<ItemStack> getRemainingItems() {
return remainingItems;
}
/** /**
* Gets the recipe that was used to craft this item. * Gets the recipe that was used to craft this item.
* *