Skip to content

Instantly share code, notes, and snippets.

View gshzn's full-sized avatar
🏠
Working from home

Guus H gshzn

🏠
Working from home
View GitHub Profile
@ChristianGaertner
ChristianGaertner / removeInventoryItems
Created April 22, 2013 10:32
Remove one single item from Players Inventory depends on the Bukkit API
public static void removeInventoryItems(PlayerInventory inv, Material type, int amount) {
for (ItemStack is : inv.getContents()) {
if (is != null && is.getType() == type) {
int newamount = is.getAmount() - amount;
if (newamount > 0) {
is.setAmount(newamount);
break;
} else {
inv.remove(is);
amount = -newamount;