2010-12-29 23:11:33 +01:00
|
|
|
|
|
|
|
package org.bukkit;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents a stack of items
|
|
|
|
*/
|
2010-12-30 00:07:15 +01:00
|
|
|
public class ItemStack {
|
|
|
|
private int type;
|
|
|
|
private int amount = 0;
|
|
|
|
|
|
|
|
public ItemStack(final int type) {
|
|
|
|
this.type = type;
|
|
|
|
}
|
|
|
|
|
2011-01-01 07:59:21 +01:00
|
|
|
public ItemStack(final Material type) {
|
2010-12-30 00:07:15 +01:00
|
|
|
this(type.getID());
|
|
|
|
}
|
|
|
|
|
|
|
|
public ItemStack(final int type, final int amount) {
|
|
|
|
this.type = type;
|
|
|
|
this.amount = amount;
|
|
|
|
}
|
|
|
|
|
2011-01-01 07:59:21 +01:00
|
|
|
public ItemStack(final Material type, final int amount) {
|
2010-12-30 00:07:15 +01:00
|
|
|
this(type.getID(), amount);
|
|
|
|
}
|
|
|
|
|
2010-12-29 23:11:33 +01:00
|
|
|
/**
|
|
|
|
* Gets the type of this item
|
|
|
|
*
|
|
|
|
* @return Type of the items in this stack
|
|
|
|
*/
|
2011-01-01 07:59:21 +01:00
|
|
|
public Material getType() {
|
|
|
|
return Material.getMaterial(type);
|
2010-12-30 00:07:15 +01:00
|
|
|
}
|
2010-12-29 23:11:33 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the type of this item
|
|
|
|
*
|
|
|
|
* @param type New type to set the items in this stack to
|
|
|
|
*/
|
2011-01-01 07:59:21 +01:00
|
|
|
public void setType(Material type) {
|
2010-12-30 00:07:15 +01:00
|
|
|
this.type = type.getID();
|
|
|
|
}
|
2010-12-29 23:11:33 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the type ID of this item
|
|
|
|
*
|
|
|
|
* @return Type ID of the items in this stack
|
|
|
|
*/
|
2010-12-30 00:07:15 +01:00
|
|
|
public int getTypeID() {
|
|
|
|
return type;
|
|
|
|
}
|
2010-12-29 23:11:33 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the type ID of this item
|
|
|
|
*
|
|
|
|
* @param type New type ID to set the items in this stack to
|
|
|
|
*/
|
2010-12-30 00:07:15 +01:00
|
|
|
public void setTypeID(int type) {
|
|
|
|
this.type = type;
|
|
|
|
}
|
2010-12-29 23:11:33 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the amount of items in this stack
|
|
|
|
*
|
|
|
|
* @return Amount of items in this stick
|
|
|
|
*/
|
2010-12-30 00:07:15 +01:00
|
|
|
public int getAmount() {
|
|
|
|
return amount;
|
|
|
|
}
|
2010-12-29 23:11:33 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the amount of items in this stack
|
|
|
|
*
|
|
|
|
* @param amount New amount of items in this stack
|
|
|
|
*/
|
2010-12-30 00:07:15 +01:00
|
|
|
public void setAmount(int amount) {
|
|
|
|
this.amount = amount;
|
|
|
|
}
|
2010-12-29 23:11:33 +01:00
|
|
|
}
|