Cycling through ItemStacks whlie supplying data... LOST [on hold]
- by user3251606
Ok so i am working on a plugin for my server that will open and inventory and when closed it will pass items to this class... object of this class is to cycle through the inventory and use a cfg file to define items and prices and then grab that info in a for loop and add it all up... heres what i have thus far...
public void sell(Player p, Inventory inv) {
ListIterator<ItemStack> it = inv.iterator();
double total = 0;
for (ItemStack is : inv) {
is = it.next();
if (is.getType() != null) {
String type = is.getType().toString();
//short dur = is.getDurability();
String check = ChestSell.plugin.getConfig().getString(type);
p.sendMessage("Item Type: " + type);
if (check != null) {
int amou = is.getAmount();
double value = ChestSell.plugin.getConfig().getDouble(type + ".price");
double tv = amou * value;
p.sendMessage("Items in chest: Type " + type + " Ammount: " + amou + " Value: $" + tv);
}
//TODO Add return Items
}
}
p.sendMessage("You got paid $" + total + " for your items!");
inv.clear();
}