Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.62 KB | None | 0 0
  1.  
  2.     private void removeItems(Player player, Material material, int _price){
  3.  
  4.         int price = _price;
  5.  
  6.         for(ItemStack is : player.getInventory().getContents()){
  7.             if(is.getType() != material){
  8.                 continue;
  9.             }
  10.             if(is.getAmount() - price >= 0){
  11.                 player.getInventory().remove(is);
  12.                 price -= is.getAmount();
  13.             }else{
  14.                 price -= is.getAmount() - price;
  15.                 is.setAmount(is.getAmount() - price);
  16.             }
  17.             if(price <= 0){
  18.                 break;
  19.             }
  20.  
  21.         }
  22.  
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement