From ec69ae1033aa666a8c023681e3fc7da55ad5618b Mon Sep 17 00:00:00 2001 From: Dinnerbone Date: Sat, 15 Jan 2011 21:27:40 +0000 Subject: All inventory stuff in org.bukkit moved to org.bukkit.inventory --- src/main/java/org/bukkit/Inventory.java | 169 ------------------ src/main/java/org/bukkit/ItemStack.java | 196 -------------------- src/main/java/org/bukkit/PlayerInventory.java | 80 --------- src/main/java/org/bukkit/Slot.java | 27 --- src/main/java/org/bukkit/World.java | 1 + src/main/java/org/bukkit/entity/HumanEntity.java | 4 +- src/main/java/org/bukkit/entity/ItemDrop.java | 2 +- .../java/org/bukkit/entity/StorageMinecart.java | 2 +- .../org/bukkit/event/block/BlockPlaceEvent.java | 2 +- .../bukkit/event/block/BlockRightClickEvent.java | 2 +- .../org/bukkit/event/player/PlayerItemEvent.java | 2 +- src/main/java/org/bukkit/inventory/Inventory.java | 170 ++++++++++++++++++ src/main/java/org/bukkit/inventory/ItemStack.java | 197 +++++++++++++++++++++ .../java/org/bukkit/inventory/PlayerInventory.java | 80 +++++++++ src/main/java/org/bukkit/inventory/Slot.java | 27 +++ .../java/org/bukkit/material/MaterialData.java | 2 +- 16 files changed, 483 insertions(+), 480 deletions(-) delete mode 100644 src/main/java/org/bukkit/Inventory.java delete mode 100644 src/main/java/org/bukkit/ItemStack.java delete mode 100644 src/main/java/org/bukkit/PlayerInventory.java delete mode 100644 src/main/java/org/bukkit/Slot.java create mode 100644 src/main/java/org/bukkit/inventory/Inventory.java create mode 100644 src/main/java/org/bukkit/inventory/ItemStack.java create mode 100644 src/main/java/org/bukkit/inventory/PlayerInventory.java create mode 100644 src/main/java/org/bukkit/inventory/Slot.java (limited to 'src/main') diff --git a/src/main/java/org/bukkit/Inventory.java b/src/main/java/org/bukkit/Inventory.java deleted file mode 100644 index 6a51c6d2..00000000 --- a/src/main/java/org/bukkit/Inventory.java +++ /dev/null @@ -1,169 +0,0 @@ -package org.bukkit; - -import java.util.HashMap; - -/** - * Interface to the various inventories - */ -public interface Inventory { - /** - * Returns the size of the inventory - * - * @return The inventory size - */ - public int getSize(); - - /** - * Return the name of the inventory - * - * @return The inventory name - */ - public String getName(); - - /** - * Get the ItemStack found in the slot at the given index - * - * @param index The index of the Slot's ItemStack to return - * @return The ItemStack in the slot - */ - public ItemStack getItem(int index); - - /** - * Stores the ItemStack at the given index - * - * @param index The index where to put the ItemStack - * @param item The ItemStack to set - */ - public void setItem(int index, ItemStack item); - - /** - * Stores the given ItemStacks in the inventory - * - * @param items The ItemStacks to add - * @return - */ - public HashMap addItem(ItemStack... items); - - /** - * Get all ItemStacks from the inventory - * - * @return All the ItemStacks from all slots - */ - public ItemStack[] getContents(); - - /** - * Check if the inventory contains any ItemStacks with the given materialId - * - * @param materialId The materialId to check for - * @return If any ItemStacks were found - */ - public boolean contains(int materialId); - - /** - * Check if the inventory contains any ItemStacks with the given material - * - * @param material The material to check for - * @return If any ItemStacks were found - */ - public boolean contains(Material material); - - /** - * Check if the inventory contains any ItemStacks matching the given ItemStack - * This will only match if both the type and the amount of the stack match - * - * @param item The ItemStack to match against - * @return If any matching ItemStacks were found - */ - public boolean contains(ItemStack item); - - /** - * Find all slots in the inventory containing any ItemStacks with the given materialId - * - * @param materialId The materialId to look for - * @return The Slots found. - */ - public HashMap all(int materialId); - - /** - * Find all slots in the inventory containing any ItemStacks with the given material - * - * @param materialId The material to look for - * @return The Slots found. - */ - public HashMap all(Material material); - - /** - * Find all slots in the inventory containing any ItemStacks with the given ItemStack - * This will only match slots if both the type and the amount of the stack match - * - * @param item The ItemStack to match against - * @return The Slots found. - */ - public HashMap all(ItemStack item); - - /** - * Find the first slot in the inventory containing an ItemStack with the given materialId - * - * @param materialId The materialId to look for - * @return The Slot found. - */ - public int first(int materialId); - - /** - * Find the first slot in the inventory containing an ItemStack with the given material - * - * @param materialId The material to look for - * @return The Slot found. - */ - public int first(Material material); - - /** - * Find the first slot in the inventory containing an ItemStack with the given stack - * This will only match a slot if both the type and the amount of the stack match - * - * @param item The ItemStack to match against - * @return The Slot found. - */ - public int first(ItemStack item); - - /** - * Find the first empty Slot. - * - * @return The first empty Slot found. - */ - public int firstEmpty(); - - /** - * Remove all stacks in the inventory matching the given materialId. - * - * @param materialId The material to remove - */ - public void remove(int materialId); - - /** - * Remove all stacks in the inventory matching the given material. - * - * @param material The material to remove - */ - public void remove(Material material); - - /** - * Remove all stacks in the inventory matching the given stack. - * This will only match a slot if both the type and the amount of the stack match - * - * @param item The ItemStack to match against - */ - public void remove(ItemStack item); - - /** - * Clear out a particular slot in the index - * - * @param index The index to empty. - */ - public void clear(int index); - - /** - * Clear out the whole index - */ - public void clear(); -} diff --git a/src/main/java/org/bukkit/ItemStack.java b/src/main/java/org/bukkit/ItemStack.java deleted file mode 100644 index 8e4e04cb..00000000 --- a/src/main/java/org/bukkit/ItemStack.java +++ /dev/null @@ -1,196 +0,0 @@ - -package org.bukkit; - -import org.bukkit.material.MaterialData; - -/** - * Represents a stack of items - */ -public class ItemStack { - private int type; - private int amount = 0; - private MaterialData data = null; - private byte damage = 0; - - public ItemStack(final int type) { - this(type, 0); - } - - public ItemStack(final Material type) { - this(type, 0); - } - - public ItemStack(final int type, final int amount) { - this(type, amount, (byte) 0); - } - - public ItemStack(final Material type, final int amount) { - this(type.getId(), amount); - } - - public ItemStack(final int type, final int amount, final byte damage) { - this(type, amount, damage, (byte) 0); - } - - public ItemStack(final Material type, final int amount, final byte damage) { - this(type.getId(), amount, damage); - } - - public ItemStack(final int type, final int amount, final byte damage, final byte data) { - this.type = type; - this.amount = amount; - this.damage = damage; - createData(data); - } - - public ItemStack(final Material type, final int amount, final byte damage, final byte data) { - this(type.getId(), amount, damage, data); - } - - /** - * Gets the type of this item - * - * @return Type of the items in this stack - */ - public Material getType() { - return Material.getMaterial(type); - } - - /** - * Sets the type of this item
- *
- * Note that in doing so you will reset the MaterialData for this stack - * - * @param type New type to set the items in this stack to - */ - public void setType(Material type) { - setTypeId(type.getId()); - } - - /** - * Gets the type id of this item - * - * @return Type Id of the items in this stack - */ - public int getTypeId() { - return type; - } - - /** - * Sets the type id of this item
- *
- * Note that in doing so you will reset the MaterialData for this stack - * - * @param type New type id to set the items in this stack to - */ - public void setTypeId(int type) { - this.type = type; - createData((byte)0); - } - - /** - * Gets the amount of items in this stack - * - * @return Amount of items in this stick - */ - public int getAmount() { - return amount; - } - - /** - * Sets the amount of items in this stack - * - * @param amount New amount of items in this stack - */ - public void setAmount(int amount) { - this.amount = amount; - } - - /** - * Gets the MaterialData for this stack of items - * - * @return MaterialData for this item - */ - public MaterialData getData() { - return data; - } - - /** - * Sets the MaterialData for this stack of items - * - * @param amount New MaterialData for this item - */ - public void setData(MaterialData data) { - Material mat = getType(); - - if ((mat == null) || (mat.getData() == null)) { - this.data = data; - } else { - if ((data.getClass() == mat.getData()) || (data.getClass() == MaterialData.class)) { - this.data = data; - } else { - throw new IllegalArgumentException("Provided data is not of type " - + mat.getData().getName() + ", found " + data.getClass().getName()); - } - } - } - - /** - * Sets the damage of this item

- * - * 0x00 represents an item which cannot be damaged
- * 0x01 represents an item at maximum health
- * 0x32 represents an item with no health left - * - * @param damage Damage of this item - */ - public void setDamage(final byte damage) { - this.damage = damage; - } - - /** - * Gets the damage of this item

- * - * 0x00 represents an item which cannot be damaged
- * 0x01 represents an item at maximum health
- * 0x32 represents an item with no health left - * - * @return Damage of this item - */ - public byte getDamage() { - return damage; - } - - /** - * Get the maximum stacksize for the material hold in this ItemStack - * Returns -1 if it has no idea. - * - * @return The maximum you can stack this material to. - */ - public int getMaxStackSize() { - return -1; - } - - private void createData(final byte data) { - Material mat = Material.getMaterial(type); - if (mat == null) { - this.data = new MaterialData(type, data); - } else { - this.data = mat.getNewData(data); - } - } - - @Override - public String toString() { - return "ItemStack{"+getType().name()+" x "+getAmount()+"}"; - } - - @Override - public boolean equals(Object object) { - return false; - } - - public boolean equals(ItemStack item) { - return item.getAmount() == getAmount() && item.getTypeId() == getTypeId(); - } -} diff --git a/src/main/java/org/bukkit/PlayerInventory.java b/src/main/java/org/bukkit/PlayerInventory.java deleted file mode 100644 index 9dfffc6d..00000000 --- a/src/main/java/org/bukkit/PlayerInventory.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.bukkit; - -/** - * Includes interface to the 4 armor slots - */ -public interface PlayerInventory extends Inventory { - /** - * Get all ItemStacks from the armor slots - * - * @return All the ItemStacks from the armor slots - */ - public ItemStack[] getArmorContents(); - - /** - * Return the ItemStack from the helmet slot - * - * @return The ItemStack in the helmet slot - */ - public ItemStack getHelmet(); - - /** - * Return the ItemStack from the chestplate slot - * - * @return The ItemStack in the chestplate slot - */ - public ItemStack getChestplate(); - - /** - * Return the ItemStack from the leg slot - * - * @return The ItemStack in the leg slot - */ - public ItemStack getLeggings(); - - /** - * Return the ItemStack from the boots slot - * - * @return The ItemStack in the boots slot - */ - public ItemStack getBoots(); - - /** - * Put the given ItemStack into the helmet slot - * This does not check if the ItemStack is a helmet - * - * @param helmet The ItemStack to use as helmet - */ - public void setHelmet(ItemStack helmet); - - /** - * Put the given ItemStack into the chestplate slot - * This does not check if the ItemStack is a chestplate - * - * @param chestplate The ItemStack to use as chestplate - */ - public void setChestplate(ItemStack chestplate); - - /** - * Put the given ItemStack into the leg slot - * This does not check if the ItemStack is a pair of leggings - * - * @param leggings The ItemStack to use as leggings - */ - public void setLeggings(ItemStack leggings); - - /** - * Put the given ItemStack into the boots slot - * This does not check if the ItemStack is a boots - * - * @param boots The ItemStack to use as boots - */ - public void setBoots(ItemStack boots); - - /** - * Returns the ItemStack currently hold - * - * @return The currently holded ItemStack - */ - public ItemStack getItemInHand(); -} \ No newline at end of file diff --git a/src/main/java/org/bukkit/Slot.java b/src/main/java/org/bukkit/Slot.java deleted file mode 100644 index 008c464f..00000000 --- a/src/main/java/org/bukkit/Slot.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.bukkit; - -/** - * Represents a slot in an inventory - */ -public interface Slot { - /** - * Gets the inventory this slot belongs to - * - * @return The inventory - */ - public Inventory getInventory(); - - /** - * Get the index this slot belongs to - * - * @return Index of the slot - */ - public int getIndex(); - - /** - * Get the item from the slot. - * - * @return ItemStack in the slot. - */ - public ItemStack getItem(); -} diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java index c2d9432d..c2ec1b49 100644 --- a/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java @@ -1,6 +1,7 @@ package org.bukkit; +import org.bukkit.inventory.ItemStack; import org.bukkit.entity.ItemDrop; import org.bukkit.entity.PoweredMinecart; import org.bukkit.entity.Minecart; diff --git a/src/main/java/org/bukkit/entity/HumanEntity.java b/src/main/java/org/bukkit/entity/HumanEntity.java index 34ea3e8c..25f59c8c 100644 --- a/src/main/java/org/bukkit/entity/HumanEntity.java +++ b/src/main/java/org/bukkit/entity/HumanEntity.java @@ -1,8 +1,8 @@ package org.bukkit.entity; -import org.bukkit.ItemStack; -import org.bukkit.PlayerInventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; /** * Represents a human entity, such as an NPC or a player diff --git a/src/main/java/org/bukkit/entity/ItemDrop.java b/src/main/java/org/bukkit/entity/ItemDrop.java index 0ab8ab0a..b43159ee 100644 --- a/src/main/java/org/bukkit/entity/ItemDrop.java +++ b/src/main/java/org/bukkit/entity/ItemDrop.java @@ -1,6 +1,6 @@ package org.bukkit.entity; -import org.bukkit.ItemStack; +import org.bukkit.inventory.ItemStack; /** * Represents a dropped item. diff --git a/src/main/java/org/bukkit/entity/StorageMinecart.java b/src/main/java/org/bukkit/entity/StorageMinecart.java index 6b0f2e32..81b588ff 100644 --- a/src/main/java/org/bukkit/entity/StorageMinecart.java +++ b/src/main/java/org/bukkit/entity/StorageMinecart.java @@ -1,6 +1,6 @@ package org.bukkit.entity; -import org.bukkit.Inventory; +import org.bukkit.inventory.Inventory; /** * Represents a storage minecart. diff --git a/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java b/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java index 4074b338..023f0615 100644 --- a/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java +++ b/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java @@ -1,7 +1,7 @@ package org.bukkit.event.block; import org.bukkit.Block; -import org.bukkit.ItemStack; +import org.bukkit.inventory.ItemStack; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; diff --git a/src/main/java/org/bukkit/event/block/BlockRightClickEvent.java b/src/main/java/org/bukkit/event/block/BlockRightClickEvent.java index d0df4c1b..ae7c2891 100644 --- a/src/main/java/org/bukkit/event/block/BlockRightClickEvent.java +++ b/src/main/java/org/bukkit/event/block/BlockRightClickEvent.java @@ -2,7 +2,7 @@ package org.bukkit.event.block; import org.bukkit.Block; import org.bukkit.BlockFace; -import org.bukkit.ItemStack; +import org.bukkit.inventory.ItemStack; import org.bukkit.entity.Player; /** diff --git a/src/main/java/org/bukkit/event/player/PlayerItemEvent.java b/src/main/java/org/bukkit/event/player/PlayerItemEvent.java index af727972..ab53067a 100644 --- a/src/main/java/org/bukkit/event/player/PlayerItemEvent.java +++ b/src/main/java/org/bukkit/event/player/PlayerItemEvent.java @@ -2,7 +2,7 @@ package org.bukkit.event.player; import org.bukkit.Block; import org.bukkit.BlockFace; -import org.bukkit.ItemStack; +import org.bukkit.inventory.ItemStack; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; diff --git a/src/main/java/org/bukkit/inventory/Inventory.java b/src/main/java/org/bukkit/inventory/Inventory.java new file mode 100644 index 00000000..149f8185 --- /dev/null +++ b/src/main/java/org/bukkit/inventory/Inventory.java @@ -0,0 +1,170 @@ +package org.bukkit.inventory; + +import java.util.HashMap; +import org.bukkit.Material; + +/** + * Interface to the various inventories + */ +public interface Inventory { + /** + * Returns the size of the inventory + * + * @return The inventory size + */ + public int getSize(); + + /** + * Return the name of the inventory + * + * @return The inventory name + */ + public String getName(); + + /** + * Get the ItemStack found in the slot at the given index + * + * @param index The index of the Slot's ItemStack to return + * @return The ItemStack in the slot + */ + public ItemStack getItem(int index); + + /** + * Stores the ItemStack at the given index + * + * @param index The index where to put the ItemStack + * @param item The ItemStack to set + */ + public void setItem(int index, ItemStack item); + + /** + * Stores the given ItemStacks in the inventory + * + * @param items The ItemStacks to add + * @return + */ + public HashMap addItem(ItemStack... items); + + /** + * Get all ItemStacks from the inventory + * + * @return All the ItemStacks from all slots + */ + public ItemStack[] getContents(); + + /** + * Check if the inventory contains any ItemStacks with the given materialId + * + * @param materialId The materialId to check for + * @return If any ItemStacks were found + */ + public boolean contains(int materialId); + + /** + * Check if the inventory contains any ItemStacks with the given material + * + * @param material The material to check for + * @return If any ItemStacks were found + */ + public boolean contains(Material material); + + /** + * Check if the inventory contains any ItemStacks matching the given ItemStack + * This will only match if both the type and the amount of the stack match + * + * @param item The ItemStack to match against + * @return If any matching ItemStacks were found + */ + public boolean contains(ItemStack item); + + /** + * Find all slots in the inventory containing any ItemStacks with the given materialId + * + * @param materialId The materialId to look for + * @return The Slots found. + */ + public HashMap all(int materialId); + + /** + * Find all slots in the inventory containing any ItemStacks with the given material + * + * @param materialId The material to look for + * @return The Slots found. + */ + public HashMap all(Material material); + + /** + * Find all slots in the inventory containing any ItemStacks with the given ItemStack + * This will only match slots if both the type and the amount of the stack match + * + * @param item The ItemStack to match against + * @return The Slots found. + */ + public HashMap all(ItemStack item); + + /** + * Find the first slot in the inventory containing an ItemStack with the given materialId + * + * @param materialId The materialId to look for + * @return The Slot found. + */ + public int first(int materialId); + + /** + * Find the first slot in the inventory containing an ItemStack with the given material + * + * @param materialId The material to look for + * @return The Slot found. + */ + public int first(Material material); + + /** + * Find the first slot in the inventory containing an ItemStack with the given stack + * This will only match a slot if both the type and the amount of the stack match + * + * @param item The ItemStack to match against + * @return The Slot found. + */ + public int first(ItemStack item); + + /** + * Find the first empty Slot. + * + * @return The first empty Slot found. + */ + public int firstEmpty(); + + /** + * Remove all stacks in the inventory matching the given materialId. + * + * @param materialId The material to remove + */ + public void remove(int materialId); + + /** + * Remove all stacks in the inventory matching the given material. + * + * @param material The material to remove + */ + public void remove(Material material); + + /** + * Remove all stacks in the inventory matching the given stack. + * This will only match a slot if both the type and the amount of the stack match + * + * @param item The ItemStack to match against + */ + public void remove(ItemStack item); + + /** + * Clear out a particular slot in the index + * + * @param index The index to empty. + */ + public void clear(int index); + + /** + * Clear out the whole index + */ + public void clear(); +} diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java new file mode 100644 index 00000000..3d6df5d3 --- /dev/null +++ b/src/main/java/org/bukkit/inventory/ItemStack.java @@ -0,0 +1,197 @@ + +package org.bukkit.inventory; + +import org.bukkit.Material; +import org.bukkit.material.MaterialData; + +/** + * Represents a stack of items + */ +public class ItemStack { + private int type; + private int amount = 0; + private MaterialData data = null; + private byte damage = 0; + + public ItemStack(final int type) { + this(type, 0); + } + + public ItemStack(final Material type) { + this(type, 0); + } + + public ItemStack(final int type, final int amount) { + this(type, amount, (byte) 0); + } + + public ItemStack(final Material type, final int amount) { + this(type.getId(), amount); + } + + public ItemStack(final int type, final int amount, final byte damage) { + this(type, amount, damage, (byte) 0); + } + + public ItemStack(final Material type, final int amount, final byte damage) { + this(type.getId(), amount, damage); + } + + public ItemStack(final int type, final int amount, final byte damage, final byte data) { + this.type = type; + this.amount = amount; + this.damage = damage; + createData(data); + } + + public ItemStack(final Material type, final int amount, final byte damage, final byte data) { + this(type.getId(), amount, damage, data); + } + + /** + * Gets the type of this item + * + * @return Type of the items in this stack + */ + public Material getType() { + return Material.getMaterial(type); + } + + /** + * Sets the type of this item
+ *
+ * Note that in doing so you will reset the MaterialData for this stack + * + * @param type New type to set the items in this stack to + */ + public void setType(Material type) { + setTypeId(type.getId()); + } + + /** + * Gets the type id of this item + * + * @return Type Id of the items in this stack + */ + public int getTypeId() { + return type; + } + + /** + * Sets the type id of this item
+ *
+ * Note that in doing so you will reset the MaterialData for this stack + * + * @param type New type id to set the items in this stack to + */ + public void setTypeId(int type) { + this.type = type; + createData((byte)0); + } + + /** + * Gets the amount of items in this stack + * + * @return Amount of items in this stick + */ + public int getAmount() { + return amount; + } + + /** + * Sets the amount of items in this stack + * + * @param amount New amount of items in this stack + */ + public void setAmount(int amount) { + this.amount = amount; + } + + /** + * Gets the MaterialData for this stack of items + * + * @return MaterialData for this item + */ + public MaterialData getData() { + return data; + } + + /** + * Sets the MaterialData for this stack of items + * + * @param amount New MaterialData for this item + */ + public void setData(MaterialData data) { + Material mat = getType(); + + if ((mat == null) || (mat.getData() == null)) { + this.data = data; + } else { + if ((data.getClass() == mat.getData()) || (data.getClass() == MaterialData.class)) { + this.data = data; + } else { + throw new IllegalArgumentException("Provided data is not of type " + + mat.getData().getName() + ", found " + data.getClass().getName()); + } + } + } + + /** + * Sets the damage of this item

+ * + * 0x00 represents an item which cannot be damaged
+ * 0x01 represents an item at maximum health
+ * 0x32 represents an item with no health left + * + * @param damage Damage of this item + */ + public void setDamage(final byte damage) { + this.damage = damage; + } + + /** + * Gets the damage of this item

+ * + * 0x00 represents an item which cannot be damaged
+ * 0x01 represents an item at maximum health
+ * 0x32 represents an item with no health left + * + * @return Damage of this item + */ + public byte getDamage() { + return damage; + } + + /** + * Get the maximum stacksize for the material hold in this ItemStack + * Returns -1 if it has no idea. + * + * @return The maximum you can stack this material to. + */ + public int getMaxStackSize() { + return -1; + } + + private void createData(final byte data) { + Material mat = Material.getMaterial(type); + if (mat == null) { + this.data = new MaterialData(type, data); + } else { + this.data = mat.getNewData(data); + } + } + + @Override + public String toString() { + return "ItemStack{"+getType().name()+" x "+getAmount()+"}"; + } + + @Override + public boolean equals(Object object) { + return false; + } + + public boolean equals(ItemStack item) { + return item.getAmount() == getAmount() && item.getTypeId() == getTypeId(); + } +} diff --git a/src/main/java/org/bukkit/inventory/PlayerInventory.java b/src/main/java/org/bukkit/inventory/PlayerInventory.java new file mode 100644 index 00000000..13bff851 --- /dev/null +++ b/src/main/java/org/bukkit/inventory/PlayerInventory.java @@ -0,0 +1,80 @@ +package org.bukkit.inventory; + +/** + * Includes interface to the 4 armor slots + */ +public interface PlayerInventory extends Inventory { + /** + * Get all ItemStacks from the armor slots + * + * @return All the ItemStacks from the armor slots + */ + public ItemStack[] getArmorContents(); + + /** + * Return the ItemStack from the helmet slot + * + * @return The ItemStack in the helmet slot + */ + public ItemStack getHelmet(); + + /** + * Return the ItemStack from the chestplate slot + * + * @return The ItemStack in the chestplate slot + */ + public ItemStack getChestplate(); + + /** + * Return the ItemStack from the leg slot + * + * @return The ItemStack in the leg slot + */ + public ItemStack getLeggings(); + + /** + * Return the ItemStack from the boots slot + * + * @return The ItemStack in the boots slot + */ + public ItemStack getBoots(); + + /** + * Put the given ItemStack into the helmet slot + * This does not check if the ItemStack is a helmet + * + * @param helmet The ItemStack to use as helmet + */ + public void setHelmet(ItemStack helmet); + + /** + * Put the given ItemStack into the chestplate slot + * This does not check if the ItemStack is a chestplate + * + * @param chestplate The ItemStack to use as chestplate + */ + public void setChestplate(ItemStack chestplate); + + /** + * Put the given ItemStack into the leg slot + * This does not check if the ItemStack is a pair of leggings + * + * @param leggings The ItemStack to use as leggings + */ + public void setLeggings(ItemStack leggings); + + /** + * Put the given ItemStack into the boots slot + * This does not check if the ItemStack is a boots + * + * @param boots The ItemStack to use as boots + */ + public void setBoots(ItemStack boots); + + /** + * Returns the ItemStack currently hold + * + * @return The currently holded ItemStack + */ + public ItemStack getItemInHand(); +} \ No newline at end of file diff --git a/src/main/java/org/bukkit/inventory/Slot.java b/src/main/java/org/bukkit/inventory/Slot.java new file mode 100644 index 00000000..ff6121cc --- /dev/null +++ b/src/main/java/org/bukkit/inventory/Slot.java @@ -0,0 +1,27 @@ +package org.bukkit.inventory; + +/** + * Represents a slot in an inventory + */ +public interface Slot { + /** + * Gets the inventory this slot belongs to + * + * @return The inventory + */ + public Inventory getInventory(); + + /** + * Get the index this slot belongs to + * + * @return Index of the slot + */ + public int getIndex(); + + /** + * Get the item from the slot. + * + * @return ItemStack in the slot. + */ + public ItemStack getItem(); +} diff --git a/src/main/java/org/bukkit/material/MaterialData.java b/src/main/java/org/bukkit/material/MaterialData.java index e5a5b085..4ccea609 100644 --- a/src/main/java/org/bukkit/material/MaterialData.java +++ b/src/main/java/org/bukkit/material/MaterialData.java @@ -1,7 +1,7 @@ package org.bukkit.material; -import org.bukkit.ItemStack; +import org.bukkit.inventory.ItemStack; import org.bukkit.Material; /** -- cgit v1.2.3