Skip to content

Instantly share code, notes, and snippets.

@kgadberry
Created July 8, 2013 18:23
Show Gist options
  • Save kgadberry/5951198 to your computer and use it in GitHub Desktop.
Save kgadberry/5951198 to your computer and use it in GitHub Desktop.
public void removeItem(ItemStack item, Player player) {
Material m = item.getType();
int amount = item.getAmount();
for (int c = 0; c < 36; c++) {
ItemStack slot = player.getInventory().getItem(c);
if (slot.getType() != null) {
if (slot.getType() == m) {
if (slot.getAmount() > amount) {
slot.setAmount(slot.getAmount() - amount);
return;
} else {
amount -= slot.getAmount();
player.getInventory().clear(c);
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment