Advertisement
Guest User

Untitled

a guest
Sep 12th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.81 KB | None | 0 0
  1. if ((e.getAction() == InventoryAction.SWAP_WITH_CURSOR)) {
  2. if (e.getCursor().getType().equals(Material.ENCHANTED_BOOK)) {
  3. if (e.getCursor().getItemMeta().hasEnchant(Enchantment.PROTECTION_ENVIRONMENTAL)) {
  4. if (e.getCurrentItem().getType() == Material.DIAMOND_CHESTPLATE
  5. || e.getCurrentItem().getType() == Material.DIAMOND_BOOTS
  6. || e.getCurrentItem().getType() == Material.DIAMOND_HELMET
  7. || e.getCurrentItem().getType() == Material.DIAMOND_LEGGINGS) {
  8. e.setCancelled(true);
  9. if (e.getCursor().getItemMeta().getEnchantLevel(Enchantment.PROTECTION_ENVIRONMENTAL) <= e
  10. .getCurrentItem().getItemMeta().getEnchantLevel(Enchantment.PROTECTION_ENVIRONMENTAL)) {
  11. p.sendMessage("§cEste item já possui o encantamento.");
  12. e.setCancelled(true);
  13. return;
  14. }
  15. if (e.getCursor().getItemMeta().getEnchantLevel(Enchantment.PROTECTION_ENVIRONMENTAL) == 5) {
  16. Random rnd = new Random();
  17. int num = rnd.nextInt(100);
  18. if (num <= 85) {
  19. e.setCancelled(true);
  20. e.getCurrentItem().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL,
  21. e.getCursor().getItemMeta()
  22. .getEnchantLevel(Enchantment.PROTECTION_ENVIRONMENTAL));
  23. ItemMeta encanter = e.getCurrentItem().getItemMeta();
  24. e.getCurrentItem().setItemMeta(encanter);
  25. p.playSound(p.getLocation(), Sound.ANVIL_USE, 1, 1);
  26. p.sendMessage("§aEncantamento aplicado com sucesso!");
  27. ItemStack nada = new ItemStack(Material.AIR);
  28. p.setItemOnCursor(nada);
  29. } else {
  30. ItemStack nada = new ItemStack(Material.AIR);
  31. p.setItemOnCursor(nada);
  32. p.sendMessage("§cEncantamento não aplicado!");
  33. p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1, 1);
  34. e.setCancelled(true);
  35. }
  36. if (e.getCursor().getItemMeta().getEnchantLevel(Enchantment.PROTECTION_ENVIRONMENTAL) == 6) {
  37. if (num <= 62) {
  38. e.setCancelled(true);
  39. e.getCurrentItem().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL,
  40. e.getCursor().getItemMeta()
  41. .getEnchantLevel(Enchantment.PROTECTION_ENVIRONMENTAL));
  42. ItemMeta encanter = e.getCurrentItem().getItemMeta();
  43. e.getCurrentItem().setItemMeta(encanter);
  44. p.playSound(p.getLocation(), Sound.ANVIL_USE, 1, 1);
  45. p.sendMessage("§aEncantamento aplicado com sucesso!");
  46. ItemStack nada = new ItemStack(Material.AIR);
  47. p.setItemOnCursor(nada);
  48. } else {
  49. ItemStack nada = new ItemStack(Material.AIR);
  50. p.setItemOnCursor(nada);
  51. p.sendMessage("§cEncantamento não aplicado!");
  52. p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1, 1);
  53. e.setCancelled(true);
  54. }
  55. }
  56. if (e.getCursor().getItemMeta().getEnchantLevel(Enchantment.PROTECTION_ENVIRONMENTAL) == 7) {
  57. if (num <= 45) {
  58. e.setCancelled(true);
  59. e.getCurrentItem().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL,
  60. e.getCursor().getItemMeta()
  61. .getEnchantLevel(Enchantment.PROTECTION_ENVIRONMENTAL));
  62. ItemMeta encanter = e.getCurrentItem().getItemMeta();
  63. e.getCurrentItem().setItemMeta(encanter);
  64. p.playSound(p.getLocation(), Sound.ANVIL_USE, 1, 1);
  65. p.sendMessage("§aEncantamento aplicado com sucesso!");
  66. ItemStack nada = new ItemStack(Material.AIR);
  67. p.setItemOnCursor(nada);
  68. } else {
  69. ItemStack nada = new ItemStack(Material.AIR);
  70. p.setItemOnCursor(nada);
  71. p.sendMessage("§cEncantamento não aplicado!");
  72. p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1, 1);
  73. e.setCancelled(true);
  74. }
  75. }
  76. if (e.getCursor().getItemMeta().getEnchantLevel(Enchantment.PROTECTION_ENVIRONMENTAL) == 8) {
  77. if (num <= 33) {
  78. e.setCancelled(true);
  79. e.getCurrentItem().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL,
  80. e.getCursor().getItemMeta()
  81. .getEnchantLevel(Enchantment.PROTECTION_ENVIRONMENTAL));
  82. ItemMeta encanter = e.getCurrentItem().getItemMeta();
  83. e.getCurrentItem().setItemMeta(encanter);
  84. p.playSound(p.getLocation(), Sound.ANVIL_USE, 1, 1);
  85. p.sendMessage("§aEncantamento aplicado com sucesso!");
  86. ItemStack nada = new ItemStack(Material.AIR);
  87. p.setItemOnCursor(nada);
  88. } else {
  89. ItemStack nada = new ItemStack(Material.AIR);
  90. p.setItemOnCursor(nada);
  91. p.sendMessage("§cEncantamento não aplicado!");
  92. p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1, 1);
  93. e.setCancelled(true);
  94. }
  95. }
  96. if (e.getCursor().getItemMeta().getEnchantLevel(Enchantment.PROTECTION_ENVIRONMENTAL) == 9) {
  97. if (num <= 19) {
  98. e.setCancelled(true);
  99. e.getCurrentItem().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL,
  100. e.getCursor().getItemMeta()
  101. .getEnchantLevel(Enchantment.PROTECTION_ENVIRONMENTAL));
  102. ItemMeta encanter = e.getCurrentItem().getItemMeta();
  103. e.getCurrentItem().setItemMeta(encanter);
  104. p.playSound(p.getLocation(), Sound.ANVIL_USE, 1, 1);
  105. p.sendMessage("§aEncantamento aplicado com sucesso!");
  106. ItemStack nada = new ItemStack(Material.AIR);
  107. p.setItemOnCursor(nada);
  108. } else {
  109. ItemStack nada = new ItemStack(Material.AIR);
  110. p.setItemOnCursor(nada);
  111. p.sendMessage("§cEncantamento não aplicado!");
  112. p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1, 1);
  113. e.setCancelled(true);
  114. }
  115. }
  116. if (e.getCursor().getItemMeta().getEnchantLevel(Enchantment.PROTECTION_ENVIRONMENTAL) == 10) {
  117. if (num <= 8) {
  118. e.setCancelled(true);
  119. e.getCurrentItem().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL,
  120. e.getCursor().getItemMeta()
  121. .getEnchantLevel(Enchantment.PROTECTION_ENVIRONMENTAL));
  122. ItemMeta encanter = e.getCurrentItem().getItemMeta();
  123. e.getCurrentItem().setItemMeta(encanter);
  124. p.playSound(p.getLocation(), Sound.ANVIL_USE, 1, 1);
  125. p.sendMessage("§aEncantamento aplicado com sucesso!");
  126. ItemStack nada = new ItemStack(Material.AIR);
  127. p.setItemOnCursor(nada);
  128. } else {
  129. ItemStack nada = new ItemStack(Material.AIR);
  130. p.setItemOnCursor(nada);
  131. p.sendMessage("§cEncantamento não aplicado!");
  132. p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1, 1);
  133. e.setCancelled(true);
  134. }
  135. }
  136. } else {
  137. p.sendMessage("§cVocê não pode adicionar este encantamento neste item.");
  138. e.setCancelled(true);
  139. return;
  140. }
  141.  
  142. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement