getItem() and chenage his value

Discussion in 'Bukkit Discussion' started by blackshade, Jan 11, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    blackshade

    Hi,
    I am working on a plugin, but the plugin needs to check if you have the required items for something and then remove the required amount.
    but I get an error while using (i have put in 318 voor a test:
    Code:
                                    ItemStack item = inv.getItem(318);
                                    item.setAmount(item.getAmount()-1);
    The error is an arrayouofbounds error and the top "at ..." thing says it it whas this particular code.

    I hope someong can help me out,
    regards,
    Blackshade

    Well I got the value changed but now the inventory won't reload it self.. Is that part of the Inventory Instance still missing? I got:
    Code:
                                    int itemIndex = inv.first(Integer.parseInt(costs[i]));
                                    ItemStack item = inv.getItem(itemIndex);
                                    item.setAmount(item.getAmount()-1);
    But I see the new item amounts when I logout and Log in again. Not that instance that I click something (like I programmed)
    am I missing something?

    thank you,
    Blackshade

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jan 8, 2016
Thread Status:
Not open for further replies.

Share This Page