Advertisement
Guest User

Untitled

a guest
Feb 25th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. public void sell()
  2. {
  3. double moneyToGive = 0.0D;
  4.  
  5. for (ItemStack item : this.GUI.getContents()) {
  6. if (item != null)
  7. {
  8. if (!Main.PRICES.containsKey(item.getData().getItemTypeId() + ":" + item.getData().getData())) {
  9. this.player.getInventory().addItem(new ItemStack[] { item });
  10. this.player.sendMessage(Utils.getPrefix() + Utils.getCantSell());
  11. }
  12. else
  13. {
  14. Double sellPrice = Double.valueOf(((Price)Main.PRICES.get(item.getTypeId() + ":" + item.getData().getData())).getSellPrice());
  15.  
  16. Integer quantity = ((Price)Main.PRICES.get(item.getTypeId() + ":" + item.getData().getData())).getQuantity();
  17.  
  18. Double perEach = Double.valueOf(sellPrice.doubleValue() / quantity.intValue());
  19.  
  20. moneyToGive += perEach.doubleValue() * item.getAmount();
  21. }
  22. }
  23. }
  24. Main.getEconomy().depositPlayer(this.player.getName(), moneyToGive);
  25.  
  26. if (moneyToGive > 0.0D) {
  27. this.player.sendMessage(Utils.getSold() + moneyToGive + Utils.getAdded());
  28. }
  29.  
  30. this.GUI.clear();
  31. }
  32.  
  33. public Inventory getGUI()
  34. {
  35. return this.GUI;
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement