13
0
geforkt von Mirrors/Paper

Initial Inventory stuff, read only, no hooks. Only implemented for the StorageMinecart

By: Erik Broes <erikbroes@ripe.net>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2011-01-05 01:00:06 +01:00
Ursprung f7d795843a
Commit 2c72e8e9d5
4 geänderte Dateien mit 108 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -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();
*/
}

Datei anzeigen

@ -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());
}
/**

Datei anzeigen

@ -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);
}
}

Datei anzeigen

@ -5,5 +5,5 @@ package org.bukkit;
*
* @author sk89q
*/
public interface StorageMinecart extends Minecart {
public interface StorageMinecart extends Minecart, Inventory {
}