diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/SmithItemEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/SmithItemEvent.java new file mode 100644 index 000000000..f8e45134c --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/event/inventory/SmithItemEvent.java @@ -0,0 +1,25 @@ +package org.bukkit.event.inventory; + +import org.bukkit.inventory.InventoryView; +import org.bukkit.inventory.SmithingInventory; +import org.jetbrains.annotations.NotNull; + +/** + * Called when the recipe of an Item is completed inside a smithing table. + */ +public class SmithItemEvent extends InventoryClickEvent { + + public SmithItemEvent(@NotNull InventoryView view, @NotNull InventoryType.SlotType type, int slot, @NotNull ClickType click, @NotNull InventoryAction action) { + super(view, type, slot, click, action); + } + + public SmithItemEvent(@NotNull InventoryView view, @NotNull InventoryType.SlotType type, int slot, @NotNull ClickType click, @NotNull InventoryAction action, int key) { + super(view, type, slot, click, action, key); + } + + @NotNull + @Override + public SmithingInventory getInventory() { + return (SmithingInventory) super.getInventory(); + } +} diff --git a/paper-api/src/main/java/org/bukkit/inventory/SmithingInventory.java b/paper-api/src/main/java/org/bukkit/inventory/SmithingInventory.java index 616495f85..96d526b7b 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/SmithingInventory.java +++ b/paper-api/src/main/java/org/bukkit/inventory/SmithingInventory.java @@ -1,6 +1,33 @@ package org.bukkit.inventory; +import org.jetbrains.annotations.Nullable; + /** * Interface to the inventory of a Smithing table. */ -public interface SmithingInventory extends Inventory { } +public interface SmithingInventory extends Inventory { + + /** + * Check what item is in the result slot of this smithing table. + * + * @return the result item + */ + @Nullable + ItemStack getResult(); + + /** + * Set the item in the result slot of the smithing table + * + * @param newResult the new result item + */ + void setResult(@Nullable ItemStack newResult); + + /** + * Get the current recipe formed on the smithing table, if any. + * + * @return the recipe, or null if the current contents don't match any + * recipe + */ + @Nullable + Recipe getRecipe(); +}