diff --git a/paper-api/src/main/java/org/bukkit/Inventory.java b/paper-api/src/main/java/org/bukkit/Inventory.java new file mode 100644 index 0000000000..7378903e57 --- /dev/null +++ b/paper-api/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 getContents(); + + /* + * TODO public boolean contains(int materialId); public boolean + * contains(Material material); public boolean contains(ItemStack item); + * + * public Collection all(int materialId); public Collection + * all(Material material); public Collection 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/paper-api/src/main/java/org/bukkit/ItemStack.java b/paper-api/src/main/java/org/bukkit/ItemStack.java index af17669835..f235062134 100644 --- a/paper-api/src/main/java/org/bukkit/ItemStack.java +++ b/paper-api/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/paper-api/src/main/java/org/bukkit/Slot.java b/paper-api/src/main/java/org/bukkit/Slot.java new file mode 100644 index 0000000000..3ead03998f --- /dev/null +++ b/paper-api/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/paper-api/src/main/java/org/bukkit/StorageMinecart.java b/paper-api/src/main/java/org/bukkit/StorageMinecart.java index 2d4a4afbdd..bd7b1b02e0 100644 --- a/paper-api/src/main/java/org/bukkit/StorageMinecart.java +++ b/paper-api/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 { }