Example of object orientation...Instead of using itemId and itemAmount like PI does make an Item object that will hold both...
Code:
package org.niobe.model;
import org.niobe.model.definitions.ItemDefinition;
/**
* Represents an item which is owned by a player.
*
* @author relex lawl
*/
public class Item {
/**
* An Item object constructor.
* @param id Item id.
* @param amount Item amount.
*/
public Item(int id, int amount) {
this.id = id;
this.amount = amount;
this.definition = ItemDefinition.forId(id);
}
/**
* An Item object constructor.
* @param id Item id.
*/
public Item(int id) {
this(id, 1);
}
/**
* The item id.
*/
private int id;
/**
* Gets the item's id.
*/
public int getId() {
return id;
}
/**
* Sets the item's id.
* @param id New item id.
*/
public Item setId(int id) {
this.id = id;
return this;
}
/**
* Amount of the item.
*/
private int amount;
/**
* Gets the amount of the item.
*/
public int getAmount() {
return amount;
}
/**
* Sets the amount of the item.
*/
public Item setAmount(int amount) {
this.amount = amount;
return this;
}
/**
* The item's definition, checks things like value, is stackable, is noted, etc.
*/
private ItemDefinition definition;
/**
* Gets item's definition.
*/
public ItemDefinition getDefinition() {
return definition;
}
/**
* Copying the item by making a new item with same values.
*/
public Item copy() {
return new Item(id, amount);
}
}