Package net.glowstone.inventory
Class GlowCraftingInventory
java.lang.Object
net.glowstone.inventory.GlowInventory
net.glowstone.inventory.GlowCraftingInventory
- All Implemented Interfaces:
Iterable<org.bukkit.inventory.ItemStack>
,org.bukkit.inventory.CraftingInventory
,org.bukkit.inventory.Inventory
public class GlowCraftingInventory
extends GlowInventory
implements org.bukkit.inventory.CraftingInventory
Represents a crafting grid inventory, both workbench and per-player.
-
Constructor Summary
ConstructorDescriptionGlowCraftingInventory
(org.bukkit.inventory.InventoryHolder owner, org.bukkit.event.inventory.InventoryType type) Create an inventory for the 2x2 or 3x3 crafting grid. -
Method Summary
Modifier and TypeMethodDescriptionvoid
craft()
Remove a layer of items from the inventory.org.bukkit.inventory.ItemStack[]
int
Gets the number of slots in this inventory according to the protocol.org.bukkit.inventory.Recipe
org.bukkit.inventory.ItemStack
void
handleShiftClick
(GlowPlayer player, org.bukkit.inventory.InventoryView view, int clickedSlot, org.bukkit.inventory.ItemStack clickedItem) Handle a shift click in this inventory by the specified player.boolean
itemShiftClickAllowed
(int slot, org.bukkit.inventory.ItemStack stack) Check whether, in a shift-click operation, an item of the specified type may be placed in the given slot.void
setItem
(int index, org.bukkit.inventory.ItemStack item) void
setMatrix
(org.bukkit.inventory.ItemStack[] contents) void
setResult
(org.bukkit.inventory.ItemStack newResult) void
Update the result slot with the current matrix.Methods inherited from class net.glowstone.inventory.GlowInventory
addItem, addItemStack, addViewer, all, all, clear, clear, close, consumeItem, consumeItem, contains, contains, contains, contains, containsAtLeast, first, first, firstEmpty, getContents, getHolder, getHolder, getItem, getLocation, getMaxStackSize, getSize, getSlot, getSlots, getSlotType, getStorageContents, getTitle, getType, getViewers, getViewersSet, initialize, isEmpty, itemPlaceAllowed, iterator, iterator, remove, remove, removeItem, removeItemAnySlot, removeItemStack, removeViewer, setContents, setMaxStackSize, setStorageContents, setTitle, toString, tryToFillSlots
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.bukkit.inventory.Inventory
addItem, all, all, clear, clear, close, contains, contains, contains, contains, containsAtLeast, first, first, firstEmpty, getContents, getHolder, getHolder, getItem, getLocation, getMaxStackSize, getSize, getStorageContents, getType, getViewers, isEmpty, iterator, iterator, remove, remove, removeItem, removeItemAnySlot, setContents, setMaxStackSize, setStorageContents
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
GlowCraftingInventory
public GlowCraftingInventory(org.bukkit.inventory.InventoryHolder owner, org.bukkit.event.inventory.InventoryType type) Create an inventory for the 2x2 or 3x3 crafting grid.- Parameters:
owner
- the crafting playertype
-InventoryType.CRAFTING
orInventoryType.WORKBENCH
-
-
Method Details
-
setItem
public void setItem(int index, org.bukkit.inventory.ItemStack item) - Specified by:
setItem
in interfaceorg.bukkit.inventory.Inventory
- Overrides:
setItem
in classGlowInventory
-
itemShiftClickAllowed
public boolean itemShiftClickAllowed(int slot, org.bukkit.inventory.ItemStack stack) Description copied from class:GlowInventory
Check whether, in a shift-click operation, an item of the specified type may be placed in the given slot.- Overrides:
itemShiftClickAllowed
in classGlowInventory
- Parameters:
slot
- The slot number.stack
- The stack to add.- Returns:
- Whether the stack can be added there.
-
handleShiftClick
public void handleShiftClick(GlowPlayer player, org.bukkit.inventory.InventoryView view, int clickedSlot, org.bukkit.inventory.ItemStack clickedItem) Description copied from class:GlowInventory
Handle a shift click in this inventory by the specified player.The default implementation distributes items from the right to the left and from the bottom to the top.
- Overrides:
handleShiftClick
in classGlowInventory
- Parameters:
player
- The player who clickedview
- The inventory view in which was clickedclickedSlot
- The slot in the viewclickedItem
- The item at which was clicked
-
getRawSlots
public int getRawSlots()Description copied from class:GlowInventory
Gets the number of slots in this inventory according to the protocol.Some inventories have 0 slots in the protocol, despite having slots.
- Overrides:
getRawSlots
in classGlowInventory
- Returns:
- The numbers of slots
-
craft
public void craft()Remove a layer of items from the inventory. -
getResult
public org.bukkit.inventory.ItemStack getResult()- Specified by:
getResult
in interfaceorg.bukkit.inventory.CraftingInventory
-
setResult
public void setResult(org.bukkit.inventory.ItemStack newResult) - Specified by:
setResult
in interfaceorg.bukkit.inventory.CraftingInventory
-
getMatrix
public org.bukkit.inventory.ItemStack[] getMatrix()- Specified by:
getMatrix
in interfaceorg.bukkit.inventory.CraftingInventory
-
setMatrix
public void setMatrix(org.bukkit.inventory.ItemStack[] contents) - Specified by:
setMatrix
in interfaceorg.bukkit.inventory.CraftingInventory
-
getRecipe
public org.bukkit.inventory.Recipe getRecipe()- Specified by:
getRecipe
in interfaceorg.bukkit.inventory.CraftingInventory
-
updateResultSlot
public void updateResultSlot()Update the result slot with the current matrix.
-