Ok so my SellItem command,
syntax: :ellitem ID AMOUNT
Problem: If the item is not stacked it only removes one,
for example, 10 furys UNNOTED - :ellitem 6585 10 - gives cash amount for 10, but removes one fury,
If they furys were noted, it would remove all 10.
Not sure if I am missing something very obvious here, or if I am just having an enormous brain fart.
Code:
if (playerCommand.startsWith("sellitem")) {
Item item = new Item();
try {
String[] args = playerCommand.split(" ");
if (args.length == 3) {
int newItemID = Integer.parseInt(args[1]);
int newItemAmount = Integer.parseInt(args[2]);
int req = item.getPrice(newItemID) * newItemAmount;
boolean exists = (item.getPrice(newItemID) != -1);
if(!exists) {
c.sendMessage("The item you are trying to sell cannot be sold with this command.");
return;
}
if (req < 0) {
c.sendMessage("The amount you trying to sell is too low, please try selling more.");
return;
}
if (c.getItems().playerHasItem(995,2000000000)) {
c.sendMessage("You cannot sell items when you have 2b in your inventory.");
return;
}
if (c.getItems().playerHasItem(newItemID, newItemAmount)) {
c.getItems().deleteItem(newItemID, newItemAmount);
c.getItems().addItem(995, (int) (req / 1.12));
c.sendMessage("You have successfully sold "+newItemAmount+"x "+server.model.items.Item.getItemName(newItemID)+" for "+(int) (req / 1.12)+".");
} else {
c.sendMessage("Check again to make sure this item is in your inventory.");
}
} else {
c.sendMessage("Use as ::sell 995 200 for example 200 gp");
}
} catch(Exception e) {
e.printStackTrace();
}
}