Advertisement
Guest User

Untitled

a guest
Sep 20th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. public static void dropPlayerMoney(double amount, Location location) {
  2.  
  3. if (amount > 64) {
  4.  
  5. int stacks = (int) (amount / 64);
  6. int rest = (int) (amount % 64);
  7.  
  8. if (stacks <= 6) {
  9.  
  10. for (int i = 1; i <= stacks; i++) {
  11.  
  12. ItemStack itemStack = new ItemStack(Material.EMERALD, (int) 64);
  13.  
  14. ItemMeta itemMeta = itemStack.getItemMeta();
  15. itemMeta.setDisplayName("$$" + 64);
  16. itemStack.setItemMeta(itemMeta);
  17.  
  18. location.getWorld().dropItemNaturally(location, itemStack);
  19. }
  20.  
  21. if (rest != 0) {
  22.  
  23. ItemStack itemStack = new ItemStack(Material.EMERALD, (int) rest);
  24.  
  25. ItemMeta itemMeta = itemStack.getItemMeta();
  26. itemMeta.setDisplayName("$$" + rest);
  27. itemStack.setItemMeta(itemMeta);
  28.  
  29. location.getWorld().dropItemNaturally(location, itemStack);
  30. }
  31. } else {
  32.  
  33. int stackValue = (int) (amount / 6);
  34.  
  35. for (int i = 1; i <= 6; i++) {
  36.  
  37. ItemStack itemStack = new ItemStack(Material.EMERALD, (int) 64);
  38.  
  39. ItemMeta itemMeta = itemStack.getItemMeta();
  40. itemMeta.setDisplayName("$$" + stackValue);
  41. itemStack.setItemMeta(itemMeta);
  42.  
  43. location.getWorld().dropItemNaturally(location, itemStack);
  44. }
  45. }
  46.  
  47. } else {
  48.  
  49. ItemStack itemStack = new ItemStack(Material.EMERALD, (int) amount);
  50.  
  51. ItemMeta itemMeta = itemStack.getItemMeta();
  52. itemMeta.setDisplayName("$$" + amount);
  53. itemStack.setItemMeta(itemMeta);
  54.  
  55. location.getWorld().dropItemNaturally(location, itemStack);
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement