Java Code Examples for org.bukkit.inventory.PlayerInventory#remove()
The following examples show how to use
org.bukkit.inventory.PlayerInventory#remove() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShopMenuItem.java From AnnihilationPro with MIT License | 9 votes |
@Override public void onItemClick(ItemClickEvent event) { Player player = event.getPlayer(); PlayerInventory p = player.getInventory(); if(p.containsAtLeast(new ItemStack(Material.GOLD_INGOT), cost)) { int total = 0; for(ItemStack s : p.all(Material.GOLD_INGOT).values()) { total += s.getAmount(); } p.remove(Material.GOLD_INGOT); if(total-cost > 0) p.addItem(new ItemStack(Material.GOLD_INGOT,total-cost)); p.addItem(product); player.sendMessage(Lang.PURCHASEDITEM.toString()); } else player.sendMessage(Lang.COULDNOTPURCHASE.toString()); }
Example 2
Source File: BukkitPlayer.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public void giveItem(int type, int amt) { final PlayerInventory inv = player.getInventory(); final ItemStack newItem = new ItemStack(type, amt); if (type == WorldEdit.getInstance().getConfiguration().wandItem) { inv.remove(newItem); } final ItemStack item = player.getItemInHand(); player.setItemInHand(newItem); if (item != null) { HashMap<Integer, ItemStack> overflow = inv.addItem(item); if (overflow != null && !overflow.isEmpty()) { TaskManager.IMP.sync(new RunnableVal<Object>() { @Override public void run(Object value) { for (Map.Entry<Integer, ItemStack> entry : overflow.entrySet()) { ItemStack stack = entry.getValue(); if (stack.getType() != Material.AIR && stack.getAmount() > 0) { Item dropped = player.getWorld().dropItem(player.getLocation(), stack); PlayerDropItemEvent event = new PlayerDropItemEvent(player, dropped); if (event.isCancelled()) { dropped.remove(); } } } } }); } } player.updateInventory(); }
Example 3
Source File: Main.java From ArmorStandTools with MIT License | 4 votes |
private void removeAllTools(Player p) { PlayerInventory i = p.getInventory(); for(ArmorStandTool t : ArmorStandTool.values()) { i.remove(t.getItem()); } }