Paste #97685: code

Date: 2022/06/16 21:34:57 UTC-07:00
Type: Java

View Raw Paste Download This Paste
Copy Link


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18



    public static boolean removeInventoryItems(PlayerInventory inv, ItemStack item) {
        for (ItemStack is : inv.getContents()) {
            if (is != null && is.getItemMeta().equals(item.getItemMeta())) {
                int amount = item.getAmount();
                int newamount = is.getAmount() - amount;
                if (newamount > 0) {
                    is.setAmount(newamount);
                    return true;
                }
                if (newamount == 0) {
                    inv.removeItem(is);
                    return true;
                }
            }
        }
        return false;
    }

Highlighting for 'Other' types handled by Highlight.JS, which was released under the BSD 3-Clause License.