001 package org.bukkit.event.inventory; 002 003 import org.bukkit.event.HandlerList; 004 import org.bukkit.inventory.CraftingInventory; 005 import org.bukkit.inventory.InventoryView; 006 import org.bukkit.inventory.Recipe; 007 008 public class PrepareItemCraftEvent extends InventoryEvent { 009 private static final HandlerList handlers = new HandlerList(); 010 private boolean repair; 011 private CraftingInventory matrix; 012 013 public PrepareItemCraftEvent(CraftingInventory what, InventoryView view, boolean isRepair) { 014 super(view); 015 this.matrix = what; 016 this.repair = isRepair; 017 } 018 019 /** 020 * Get the recipe that has been formed. If this event was triggered by a 021 * tool repair, this will be a temporary shapeless recipe representing the 022 * repair. 023 * 024 * @return The recipe being crafted. 025 */ 026 public Recipe getRecipe() { 027 return matrix.getRecipe(); 028 } 029 030 /** 031 * @return The crafting inventory on which the recipe was formed. 032 */ 033 @Override 034 public CraftingInventory getInventory() { 035 return matrix; 036 } 037 038 /** 039 * Check if this event was triggered by a tool repair operation rather 040 * than a crafting recipe. 041 * 042 * @return True if this is a repair. 043 */ 044 public boolean isRepair() { 045 return repair; 046 } 047 048 @Override 049 public HandlerList getHandlers() { 050 return handlers; 051 } 052 053 public static HandlerList getHandlerList() { 054 return handlers; 055 } 056 }