diff options
author | Erik Broes <erikbroes@ripe.net> | 2011-01-05 01:00:06 +0100 |
---|---|---|
committer | Erik Broes <erikbroes@ripe.net> | 2011-01-05 01:00:14 +0100 |
commit | 3fd9085ca7d16647bc485041c057f7c1567c5c45 (patch) | |
tree | 9201e2048ea17461f8fe7864dd647d02ca46dff1 | |
parent | 94ef32973d452ec5d8a6be9f49354ac0041d69bd (diff) | |
download | bukkit-3fd9085ca7d16647bc485041c057f7c1567c5c45.tar bukkit-3fd9085ca7d16647bc485041c057f7c1567c5c45.tar.gz bukkit-3fd9085ca7d16647bc485041c057f7c1567c5c45.tar.lz bukkit-3fd9085ca7d16647bc485041c057f7c1567c5c45.tar.xz bukkit-3fd9085ca7d16647bc485041c057f7c1567c5c45.zip |
Initial Inventory stuff, read only, no hooks. Only implemented for the StorageMinecart
-rw-r--r-- | src/main/java/org/bukkit/Inventory.java | 65 | ||||
-rw-r--r-- | src/main/java/org/bukkit/ItemStack.java | 2 | ||||
-rw-r--r-- | src/main/java/org/bukkit/Slot.java | 41 | ||||
-rw-r--r-- | src/main/java/org/bukkit/StorageMinecart.java | 2 |
4 files changed, 108 insertions, 2 deletions
diff --git a/src/main/java/org/bukkit/Inventory.java b/src/main/java/org/bukkit/Inventory.java new file mode 100644 index 00000000..7378903e --- /dev/null +++ b/src/main/java/org/bukkit/Inventory.java @@ -0,0 +1,65 @@ +package org.bukkit; + +import java.util.Collection; + +/** + * 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(); + + /** + * TODO Set the name of the inventory + * + * @param name The new name of the inventory + public void setName(String name); + */ + + /** TODO: Appears minecraft has different ideas for slots! + * Get the slot at a specific index of an inventory + * + * @param index The index of the slot to get + * @return The Slot found at the index + public Slot getSlot(int index); + */ + + /** + * 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); + + /** + * Get all ItemStacks from the inventory + * + * @return All the ItemStacks from all slots + */ + public Collection<ItemStack> getContents(); + + /* + * TODO public boolean contains(int materialId); public boolean + * contains(Material material); public boolean contains(ItemStack item); + * + * public Collection<Slot> all(int materialId); public Collection<Slot> + * all(Material material); public Collection<Slot> all(ItemStack item); + * + * public Slot first(int materialId); public Slot first(Material material); + * public Slot first(ItemStack item); + * + * public int firstEmptyIndex(); + */ +}
\ No newline at end of file diff --git a/src/main/java/org/bukkit/ItemStack.java b/src/main/java/org/bukkit/ItemStack.java index af176698..f2350621 100644 --- a/src/main/java/org/bukkit/ItemStack.java +++ b/src/main/java/org/bukkit/ItemStack.java @@ -51,7 +51,7 @@ public class ItemStack { * @param type New type to set the items in this stack to
*/
public void setType(Material type) {
- this.type = type.getID();
+ setTypeID(type.getID());
}
/**
diff --git a/src/main/java/org/bukkit/Slot.java b/src/main/java/org/bukkit/Slot.java new file mode 100644 index 00000000..3ead0399 --- /dev/null +++ b/src/main/java/org/bukkit/Slot.java @@ -0,0 +1,41 @@ +package org.bukkit; + +/** + * Represents a slot in an inventory + */ +public class Slot { + private Inventory inventory; + private int index; + + public Slot(Inventory inventory, int index) { + this.inventory = inventory; + this.index = index; + } + + /** + * Gets the inventory this slot belongs to + * + * @return The inventory + */ + public Inventory getInventory() { + return inventory; + } + + /** + * Get the index this slot belongs to + * + * @return Index of the slot + */ + public int getIndex() { + return index; + } + + /** + * Get the item from the slot. + * + * @return ItemStack in the slot. + */ + public ItemStack getItem() { + return inventory.getItem(index); + } +} diff --git a/src/main/java/org/bukkit/StorageMinecart.java b/src/main/java/org/bukkit/StorageMinecart.java index 2d4a4afb..bd7b1b02 100644 --- a/src/main/java/org/bukkit/StorageMinecart.java +++ b/src/main/java/org/bukkit/StorageMinecart.java @@ -5,5 +5,5 @@ package org.bukkit; *
* @author sk89q
*/
-public interface StorageMinecart extends Minecart {
+public interface StorageMinecart extends Minecart, Inventory {
}
|