Commits

md_5 authored b00ec19acfd
SPIGOT-8014: Add method for getting and setting remaining items in CrafterCraftEvent
No tags

src/main/java/org/bukkit/event/block/CrafterCraftEvent.java

Modified
1 1 package org.bukkit.event.block;
2 2
3 +import java.util.ArrayList;
4 +import java.util.List;
3 5 import org.bukkit.block.Block;
4 6 import org.bukkit.event.Cancellable;
5 7 import org.bukkit.event.HandlerList;
6 8 import org.bukkit.inventory.CraftingRecipe;
7 9 import org.bukkit.inventory.ItemStack;
8 10 import org.jetbrains.annotations.NotNull;
9 11
10 12 /**
11 13 * Event called when a Crafter is about to craft an item.
12 14 */
13 15 public class CrafterCraftEvent extends BlockEvent implements Cancellable {
14 16
15 17 private static final HandlerList handlers = new HandlerList();
16 18 private final CraftingRecipe recipe;
17 19 private ItemStack result;
20 + private List<ItemStack> remainingItems;
18 21 private boolean cancelled;
19 22
23 + @Deprecated
20 24 public CrafterCraftEvent(@NotNull Block theBlock, @NotNull CraftingRecipe recipe, @NotNull ItemStack result) {
25 + this(theBlock, recipe, result, new ArrayList<>());
26 + }
27 +
28 + public CrafterCraftEvent(@NotNull Block theBlock, @NotNull CraftingRecipe recipe, @NotNull ItemStack result, @NotNull List<ItemStack> remainingItems) {
21 29 super(theBlock);
22 30 this.result = result;
23 31 this.recipe = recipe;
32 + this.remainingItems = remainingItems;
24 33 }
25 34
26 35 /**
27 36 * Gets the result for the craft.
28 37 *
29 38 * @return the result for the craft
30 39 */
31 40 @NotNull
32 41 public ItemStack getResult() {
33 42 return result.clone();
34 43 }
35 44
36 45 /**
37 46 * Sets the result of the craft.
38 47 *
39 48 * @param result the result of the craft
40 49 */
41 50 public void setResult(@NotNull ItemStack result) {
42 51 this.result = result.clone();
43 52 }
44 53
54 + /**
55 + * Gets the items that will remain after the recipe has been crafted.
56 + *
57 + * @return a list of the remaining items
58 + */
59 + @NotNull
60 + public List<ItemStack> getRemainingItems() {
61 + return remainingItems;
62 + }
63 +
45 64 /**
46 65 * Gets the recipe that was used to craft this item.
47 66 *
48 67 * @return the recipe that was used to craft this item
49 68 */
50 69 @NotNull
51 70 public CraftingRecipe getRecipe() {
52 71 return recipe;
53 72 }
54 73

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut