Package net.glowstone.inventory
Class GlowPlayerInventory
java.lang.Object
net.glowstone.inventory.GlowInventory
net.glowstone.inventory.GlowPlayerInventory
- All Implemented Interfaces:
Iterable<org.bukkit.inventory.ItemStack>
,org.bukkit.inventory.EntityEquipment
,org.bukkit.inventory.Inventory
,org.bukkit.inventory.PlayerInventory
public class GlowPlayerInventory
extends GlowInventory
implements org.bukkit.inventory.PlayerInventory, org.bukkit.inventory.EntityEquipment
An Inventory representing the items a player is holding.
-
Constructor Summary
ConstructorDescriptionCreates the instance for the given player's inventory. -
Method Summary
Modifier and TypeMethodDescriptionint
clear
(org.bukkit.Material type, org.bukkit.material.MaterialData data) Remove all matching items from the inventory.int
consumeItemInHand
(org.bukkit.inventory.EquipmentSlot slot) Consumes an item in a hand slot.int
consumeItemInHand
(org.bukkit.inventory.EquipmentSlot slot, boolean wholeStack) Consumes an item in a hand slot.int
Consumes an item in the main hand slot.int
consumeItemInMainHand
(boolean wholeStack) Consumes an item or the full stack in the main hand slot.org.bukkit.inventory.ItemStack[]
org.bukkit.inventory.ItemStack
getBoots()
float
org.bukkit.inventory.ItemStack
float
The crafting inventory.Tracker for inventory drags by this player.float
getDropChance
(@NotNull org.bukkit.inventory.EquipmentSlot equipmentSlot) org.bukkit.inventory.ItemStack[]
int
The current held item slot.org.bukkit.inventory.ItemStack
float
org.bukkit.entity.HumanEntity
The owner of this inventory.@NotNull org.bukkit.inventory.ItemStack
getItem
(org.bukkit.inventory.EquipmentSlot slot) @NotNull org.bukkit.inventory.ItemStack
Deprecated.float
@NotNull org.bukkit.inventory.ItemStack
float
@NotNull org.bukkit.inventory.ItemStack
float
org.bukkit.inventory.ItemStack
float
org.bukkit.Location
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
itemPlaceAllowed
(int slot, org.bukkit.inventory.ItemStack stack) Check whether it is allowed for a player to insert the given ItemStack at the slot, regardless of the slot's current contents.void
setArmorContents
(org.bukkit.inventory.ItemStack[] items) void
setBoots
(@Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent) void
setBoots
(org.bukkit.inventory.ItemStack boots) void
setBootsDropChance
(float chance) void
setChestplate
(@Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent) void
setChestplate
(org.bukkit.inventory.ItemStack chestplate) void
setChestplateDropChance
(float chance) void
setDropChance
(@NotNull org.bukkit.inventory.EquipmentSlot equipmentSlot, float v) void
setExtraContents
(org.bukkit.inventory.ItemStack[] items) void
setHeldItemSlot
(int slot) void
setHelmet
(@Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent) void
setHelmet
(org.bukkit.inventory.ItemStack helmet) void
setHelmetDropChance
(float chance) void
setItem
(@NotNull org.bukkit.inventory.EquipmentSlot slot, @Nullable org.bukkit.inventory.ItemStack item, boolean silent) void
setItem
(org.bukkit.inventory.EquipmentSlot slot, org.bukkit.inventory.ItemStack item) void
setItemInHand
(org.bukkit.inventory.ItemStack item) Deprecated.void
setItemInHandDropChance
(float chance) void
setItemInMainHand
(@Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent) void
setItemInMainHand
(org.bukkit.inventory.ItemStack item) void
setItemInMainHandDropChance
(float chance) void
setItemInOffHand
(@Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent) void
setItemInOffHand
(org.bukkit.inventory.ItemStack item) void
setItemInOffHandDropChance
(float chance) void
setLeggings
(@Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent) void
setLeggings
(org.bukkit.inventory.ItemStack leggings) void
setLeggingsDropChance
(float chance) void
setRawHeldItemSlot
(int slot) Sets which hotbar slot is the main-hand item.void
setStorageContents
(org.bukkit.inventory.ItemStack[] items) 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, getItem, getMaxStackSize, getRawSlots, getSize, getSlot, getSlots, getSlotType, getTitle, getType, getViewers, getViewersSet, initialize, isEmpty, itemShiftClickAllowed, iterator, iterator, remove, remove, removeItem, removeItemAnySlot, removeItemStack, removeViewer, setContents, setItem, setMaxStackSize, 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.EntityEquipment
clear
Methods inherited from interface org.bukkit.inventory.Inventory
addItem, all, all, clear, clear, close, contains, contains, contains, contains, containsAtLeast, first, first, firstEmpty, getContents, getHolder, getItem, getMaxStackSize, getSize, getType, getViewers, isEmpty, iterator, iterator, remove, remove, removeItem, removeItemAnySlot, setContents, setMaxStackSize
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface org.bukkit.inventory.PlayerInventory
setItem
-
Constructor Details
-
GlowPlayerInventory
Creates the instance for the given player's inventory.- Parameters:
owner
- the player who owns this inventory
-
-
Method Details
-
setRawHeldItemSlot
public void setRawHeldItemSlot(int slot) Sets which hotbar slot is the main-hand item.- Parameters:
slot
- the slot number, starting with 0 (1 less than the default keyboard shortcut)
-
itemPlaceAllowed
public boolean itemPlaceAllowed(int slot, org.bukkit.inventory.ItemStack stack) Description copied from class:GlowInventory
Check whether it is allowed for a player to insert the given ItemStack at the slot, regardless of the slot's current contents.Should return false for crafting output slots or armor slots which cannot accept the given item.
- Overrides:
itemPlaceAllowed
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
-
getHolder
public org.bukkit.entity.HumanEntity getHolder()Description copied from class:GlowInventory
The owner of this inventory.- Specified by:
getHolder
in interfaceorg.bukkit.inventory.EntityEquipment
- Specified by:
getHolder
in interfaceorg.bukkit.inventory.Inventory
- Specified by:
getHolder
in interfaceorg.bukkit.inventory.PlayerInventory
- Overrides:
getHolder
in classGlowInventory
-
getDropChance
public float getDropChance(@NotNull @NotNull org.bukkit.inventory.EquipmentSlot equipmentSlot) - Specified by:
getDropChance
in interfaceorg.bukkit.inventory.EntityEquipment
-
setDropChance
public void setDropChance(@NotNull @NotNull org.bukkit.inventory.EquipmentSlot equipmentSlot, float v) - Specified by:
setDropChance
in interfaceorg.bukkit.inventory.EntityEquipment
-
getItem
@NotNull public @NotNull org.bukkit.inventory.ItemStack getItem(org.bukkit.inventory.EquipmentSlot slot) - Specified by:
getItem
in interfaceorg.bukkit.inventory.EntityEquipment
- Specified by:
getItem
in interfaceorg.bukkit.inventory.PlayerInventory
-
setItem
public void setItem(org.bukkit.inventory.EquipmentSlot slot, org.bukkit.inventory.ItemStack item) - Specified by:
setItem
in interfaceorg.bukkit.inventory.EntityEquipment
- Specified by:
setItem
in interfaceorg.bukkit.inventory.PlayerInventory
-
setItem
public void setItem(@NotNull @NotNull org.bukkit.inventory.EquipmentSlot slot, @Nullable @Nullable org.bukkit.inventory.ItemStack item, boolean silent) - Specified by:
setItem
in interfaceorg.bukkit.inventory.EntityEquipment
-
getStorageContents
public org.bukkit.inventory.ItemStack[] getStorageContents()- Specified by:
getStorageContents
in interfaceorg.bukkit.inventory.Inventory
- Overrides:
getStorageContents
in classGlowInventory
-
setStorageContents
public void setStorageContents(org.bukkit.inventory.ItemStack[] items) throws IllegalArgumentException - Specified by:
setStorageContents
in interfaceorg.bukkit.inventory.Inventory
- Overrides:
setStorageContents
in classGlowInventory
- Throws:
IllegalArgumentException
-
getArmorContents
public org.bukkit.inventory.ItemStack[] getArmorContents()- Specified by:
getArmorContents
in interfaceorg.bukkit.inventory.EntityEquipment
- Specified by:
getArmorContents
in interfaceorg.bukkit.inventory.PlayerInventory
-
setArmorContents
public void setArmorContents(org.bukkit.inventory.ItemStack[] items) - Specified by:
setArmorContents
in interfaceorg.bukkit.inventory.EntityEquipment
- Specified by:
setArmorContents
in interfaceorg.bukkit.inventory.PlayerInventory
-
getExtraContents
public org.bukkit.inventory.ItemStack[] getExtraContents()- Specified by:
getExtraContents
in interfaceorg.bukkit.inventory.PlayerInventory
-
setExtraContents
public void setExtraContents(org.bukkit.inventory.ItemStack[] items) - Specified by:
setExtraContents
in interfaceorg.bukkit.inventory.PlayerInventory
-
getHelmet
public org.bukkit.inventory.ItemStack getHelmet()- Specified by:
getHelmet
in interfaceorg.bukkit.inventory.EntityEquipment
- Specified by:
getHelmet
in interfaceorg.bukkit.inventory.PlayerInventory
-
setHelmet
public void setHelmet(org.bukkit.inventory.ItemStack helmet) - Specified by:
setHelmet
in interfaceorg.bukkit.inventory.EntityEquipment
- Specified by:
setHelmet
in interfaceorg.bukkit.inventory.PlayerInventory
-
setHelmet
public void setHelmet(@Nullable @Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent) - Specified by:
setHelmet
in interfaceorg.bukkit.inventory.EntityEquipment
-
getChestplate
public org.bukkit.inventory.ItemStack getChestplate()- Specified by:
getChestplate
in interfaceorg.bukkit.inventory.EntityEquipment
- Specified by:
getChestplate
in interfaceorg.bukkit.inventory.PlayerInventory
-
setChestplate
public void setChestplate(org.bukkit.inventory.ItemStack chestplate) - Specified by:
setChestplate
in interfaceorg.bukkit.inventory.EntityEquipment
- Specified by:
setChestplate
in interfaceorg.bukkit.inventory.PlayerInventory
-
setChestplate
public void setChestplate(@Nullable @Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent) - Specified by:
setChestplate
in interfaceorg.bukkit.inventory.EntityEquipment
-
getLeggings
public org.bukkit.inventory.ItemStack getLeggings()- Specified by:
getLeggings
in interfaceorg.bukkit.inventory.EntityEquipment
- Specified by:
getLeggings
in interfaceorg.bukkit.inventory.PlayerInventory
-
setLeggings
public void setLeggings(org.bukkit.inventory.ItemStack leggings) - Specified by:
setLeggings
in interfaceorg.bukkit.inventory.EntityEquipment
- Specified by:
setLeggings
in interfaceorg.bukkit.inventory.PlayerInventory
-
setLeggings
public void setLeggings(@Nullable @Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent) - Specified by:
setLeggings
in interfaceorg.bukkit.inventory.EntityEquipment
-
getBoots
public org.bukkit.inventory.ItemStack getBoots()- Specified by:
getBoots
in interfaceorg.bukkit.inventory.EntityEquipment
- Specified by:
getBoots
in interfaceorg.bukkit.inventory.PlayerInventory
-
setBoots
public void setBoots(org.bukkit.inventory.ItemStack boots) - Specified by:
setBoots
in interfaceorg.bukkit.inventory.EntityEquipment
- Specified by:
setBoots
in interfaceorg.bukkit.inventory.PlayerInventory
-
setBoots
public void setBoots(@Nullable @Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent) - Specified by:
setBoots
in interfaceorg.bukkit.inventory.EntityEquipment
-
getItemInMainHand
@NotNull public @NotNull org.bukkit.inventory.ItemStack getItemInMainHand()- Specified by:
getItemInMainHand
in interfaceorg.bukkit.inventory.EntityEquipment
- Specified by:
getItemInMainHand
in interfaceorg.bukkit.inventory.PlayerInventory
-
setItemInMainHand
public void setItemInMainHand(org.bukkit.inventory.ItemStack item) - Specified by:
setItemInMainHand
in interfaceorg.bukkit.inventory.EntityEquipment
- Specified by:
setItemInMainHand
in interfaceorg.bukkit.inventory.PlayerInventory
-
setItemInMainHand
public void setItemInMainHand(@Nullable @Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent) - Specified by:
setItemInMainHand
in interfaceorg.bukkit.inventory.EntityEquipment
-
getItemInOffHand
@NotNull public @NotNull org.bukkit.inventory.ItemStack getItemInOffHand()- Specified by:
getItemInOffHand
in interfaceorg.bukkit.inventory.EntityEquipment
- Specified by:
getItemInOffHand
in interfaceorg.bukkit.inventory.PlayerInventory
-
setItemInOffHand
public void setItemInOffHand(org.bukkit.inventory.ItemStack item) - Specified by:
setItemInOffHand
in interfaceorg.bukkit.inventory.EntityEquipment
- Specified by:
setItemInOffHand
in interfaceorg.bukkit.inventory.PlayerInventory
-
setItemInOffHand
public void setItemInOffHand(@Nullable @Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent) - Specified by:
setItemInOffHand
in interfaceorg.bukkit.inventory.EntityEquipment
-
getItemInHand
Deprecated.- Specified by:
getItemInHand
in interfaceorg.bukkit.inventory.EntityEquipment
- Specified by:
getItemInHand
in interfaceorg.bukkit.inventory.PlayerInventory
-
setItemInHand
Deprecated.- Specified by:
setItemInHand
in interfaceorg.bukkit.inventory.EntityEquipment
- Specified by:
setItemInHand
in interfaceorg.bukkit.inventory.PlayerInventory
-
setHeldItemSlot
public void setHeldItemSlot(int slot) - Specified by:
setHeldItemSlot
in interfaceorg.bukkit.inventory.PlayerInventory
-
getLocation
public org.bukkit.Location getLocation()- Specified by:
getLocation
in interfaceorg.bukkit.inventory.Inventory
- Overrides:
getLocation
in classGlowInventory
-
clear
public int clear(org.bukkit.Material type, org.bukkit.material.MaterialData data) Remove all matching items from the inventory.- Parameters:
type
- the item to remove, or null to remove everythingdata
- the data value to match on, or null to match all data values- Returns:
- the number of items (not stacks) removed
-
getItemInHandDropChance
public float getItemInHandDropChance()- Specified by:
getItemInHandDropChance
in interfaceorg.bukkit.inventory.EntityEquipment
-
setItemInHandDropChance
public void setItemInHandDropChance(float chance) - Specified by:
setItemInHandDropChance
in interfaceorg.bukkit.inventory.EntityEquipment
-
getItemInMainHandDropChance
public float getItemInMainHandDropChance()- Specified by:
getItemInMainHandDropChance
in interfaceorg.bukkit.inventory.EntityEquipment
-
setItemInMainHandDropChance
public void setItemInMainHandDropChance(float chance) - Specified by:
setItemInMainHandDropChance
in interfaceorg.bukkit.inventory.EntityEquipment
-
getItemInOffHandDropChance
public float getItemInOffHandDropChance()- Specified by:
getItemInOffHandDropChance
in interfaceorg.bukkit.inventory.EntityEquipment
-
setItemInOffHandDropChance
public void setItemInOffHandDropChance(float chance) - Specified by:
setItemInOffHandDropChance
in interfaceorg.bukkit.inventory.EntityEquipment
-
getHelmetDropChance
public float getHelmetDropChance()- Specified by:
getHelmetDropChance
in interfaceorg.bukkit.inventory.EntityEquipment
-
setHelmetDropChance
public void setHelmetDropChance(float chance) - Specified by:
setHelmetDropChance
in interfaceorg.bukkit.inventory.EntityEquipment
-
getChestplateDropChance
public float getChestplateDropChance()- Specified by:
getChestplateDropChance
in interfaceorg.bukkit.inventory.EntityEquipment
-
setChestplateDropChance
public void setChestplateDropChance(float chance) - Specified by:
setChestplateDropChance
in interfaceorg.bukkit.inventory.EntityEquipment
-
getLeggingsDropChance
public float getLeggingsDropChance()- Specified by:
getLeggingsDropChance
in interfaceorg.bukkit.inventory.EntityEquipment
-
setLeggingsDropChance
public void setLeggingsDropChance(float chance) - Specified by:
setLeggingsDropChance
in interfaceorg.bukkit.inventory.EntityEquipment
-
getBootsDropChance
public float getBootsDropChance()- Specified by:
getBootsDropChance
in interfaceorg.bukkit.inventory.EntityEquipment
-
setBootsDropChance
public void setBootsDropChance(float chance) - Specified by:
setBootsDropChance
in interfaceorg.bukkit.inventory.EntityEquipment
-
consumeItemInMainHand
public int consumeItemInMainHand(boolean wholeStack) Consumes an item or the full stack in the main hand slot.- Parameters:
wholeStack
- True if we should remove the complete stack.- Returns:
- The number of item really consumed.
-
consumeItemInMainHand
public int consumeItemInMainHand()Consumes an item in the main hand slot.- Returns:
- The number of item really consumed.
-
consumeItemInHand
public int consumeItemInHand(org.bukkit.inventory.EquipmentSlot slot) Consumes an item in a hand slot.- Parameters:
slot
- Thehand slot
to consume, which must be eitherEquipmentSlot.HAND
orEquipmentSlot.OFF_HAND
.- Returns:
- The number of item really consumed.
-
consumeItemInHand
public int consumeItemInHand(org.bukkit.inventory.EquipmentSlot slot, boolean wholeStack) Consumes an item in a hand slot.- Parameters:
slot
- Thehand slot
to consume, which must be eitherEquipmentSlot.HAND
orEquipmentSlot.OFF_HAND
.wholeStack
- True if we should remove the complete stack.- Returns:
- The number of item really consumed.
-
getCraftingInventory
The crafting inventory.- Returns:
- The GlowCraftingInventory attached to this player
-
getDragTracker
Tracker for inventory drags by this player.- Returns:
- The DragTracker.
-
getHeldItemSlot
public int getHeldItemSlot()The current held item slot.- Specified by:
getHeldItemSlot
in interfaceorg.bukkit.inventory.PlayerInventory
-