Advertisement
Guest User

Untitled

a guest
Nov 24th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.99 KB | None | 0 0
  1. if (clickEvent.getClickedInventory().getName().equalsIgnoreCase(InventoryEnchantPlugin.plugin.getConfig().getString("Item2GUI.name"))) {
  2. if (clickEvent.getCurrentItem().getType() == Material.STAINED_GLASS_PANE || clickEvent.getCurrentItem().getType() == Material.LEVER) {
  3. clickEvent.setCancelled(true);
  4. return;
  5. }
  6. if (player.getItemOnCursor().getType() == Material.AIR || player.getItemOnCursor() == null) {
  7. if (InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(17) != null && InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(17).getType() != Material.AIR){
  8. if (clickEvent.getSlot() == 13 && clickEvent.getCurrentItem().getType() == Material.ENCHANTED_BOOK && clickEvent.getCurrentItem().hasItemMeta() && clickEvent.getCurrentItem().getItemMeta().hasLore()) {
  9. player.getInventory().addItem(clickEvent.getCurrentItem());
  10. InventoryEnchantPlugin.plugin.getEnchantGUI().setItem(13, new ItemStack(Material.BOOK));
  11. InventoryEnchantPlugin.plugin.getEnchantGUI().setItem(17, new ItemStack(Material.AIR));
  12. }
  13. }
  14. }
  15. if (clickEvent.getCurrentItem().getType() == Material.BOOK && (!clickEvent.getCurrentItem().hasItemMeta()) && (!clickEvent.getCurrentItem().getItemMeta().hasLore())) {
  16. clickEvent.setCancelled(true);
  17. return;
  18. }
  19. if (clickEvent.getSlot() == 11 && (clickEvent.getCurrentItem().getType() == Material.DIAMOND_PICKAXE)) {
  20. if (clickEvent.getCursor().getType() == Material.DIAMOND_PICKAXE || clickEvent.getCursor().getType() == Material.IRON_PICKAXE || clickEvent.getCursor().getType() == Material.GOLD_PICKAXE || clickEvent.getCursor().getType() == Material.STONE_PICKAXE || clickEvent.getCursor().getType() == Material.WOOD_PICKAXE || clickEvent.getCursor() == null || clickEvent.getCursor().getType() == Material.AIR) {
  21. clickEvent.setCurrentItem(clickEvent.getCursor());
  22. clickEvent.setCursor(new ItemStack(Material.AIR));
  23. } else if (!(clickEvent.getCursor() == null) && !(clickEvent.getCursor().getType() == Material.AIR)) {
  24. clickEvent.setCancelled(true);
  25. return;
  26. }
  27. }
  28. if (clickEvent.getSlot() == 13 && clickEvent.getCurrentItem().getType() == Material.BOOK) {
  29. if ((clickEvent.getCursor().getType() == Material.ENCHANTED_BOOK)) {
  30. clickEvent.setCurrentItem(clickEvent.getCursor());
  31. clickEvent.setCursor(new ItemStack(Material.AIR));
  32. } else if (!(clickEvent.getCursor() == null) && !(clickEvent.getCursor().getType() == Material.AIR)) {
  33. clickEvent.setCancelled(true);
  34. return;
  35. }
  36. }
  37. if (clickEvent.getSlot() == 15 ) {
  38. if ((InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(11).getType() == Material.DIAMOND_PICKAXE || InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(11).getType() == Material.IRON_PICKAXE || InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(11).getType() == Material.GOLD_PICKAXE || InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(11).getType() == Material.WOOD_PICKAXE || InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(11).getType() == Material.STONE_PICKAXE) && InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(13).getType() == Material.ENCHANTED_BOOK && InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(13).hasItemMeta() && InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(13).getItemMeta().hasLore()) {
  39. if (containsWord("Success", InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(13).getItemMeta().getLore())){
  40. int random = new Random(100).nextInt();
  41. if (random > InventoryEnchantPlugin.plugin.getConfig().getInt("minSuccessRate") || random < InventoryEnchantPlugin.plugin.getConfig().getInt("maxSuccessRate")){
  42. InventoryEnchantPlugin.plugin.getEnchantGUI().setItem(11, new ItemStack(Material.DIAMOND_PICKAXE));
  43. InventoryEnchantPlugin.plugin.getEnchantGUI().setItem(13, new ItemStack(Material.BOOK));
  44. player.closeInventory();
  45. player.sendMessage(ChatColor.translateAlternateColorCodes('&', InventoryEnchantPlugin.plugin.getConfig().getString("breakItemWhenEnchantMsg")));
  46. return;
  47. }
  48. }
  49. if (containsWord("Destroy", InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(13).getItemMeta().getLore())){
  50. int random = new Random(100).nextInt();
  51. if (random > InventoryEnchantPlugin.plugin.getConfig().getInt("minDestroyRate") || random < InventoryEnchantPlugin.plugin.getConfig().getInt("maxDestroyRate")){
  52. InventoryEnchantPlugin.plugin.getEnchantGUI().setItem(11, new ItemStack(Material.DIAMOND_PICKAXE));
  53. InventoryEnchantPlugin.plugin.getEnchantGUI().setItem(13, new ItemStack(Material.BOOK));
  54. player.closeInventory();
  55. player.sendMessage(ChatColor.translateAlternateColorCodes('&', InventoryEnchantPlugin.plugin.getConfig().getString("breakItemWhenEnchantMsg")));
  56. return;
  57. }
  58. }
  59. if (InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(11).hasItemMeta() && InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(11).getItemMeta().hasLore()){
  60. if (InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(11).getItemMeta().getLore().get(3).isEmpty()){
  61. ItemStack result = InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(11);
  62. ItemMeta resultMeta = result.getItemMeta();
  63. resultMeta.getLore().set(3, InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(13).getItemMeta().getLore().get(2));
  64. result.setItemMeta(resultMeta);
  65. InventoryEnchantPlugin.plugin.getEnchantGUI().setItem(17, result);
  66. return;
  67. }
  68. if (InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(11).getItemMeta().getLore().get(4).isEmpty()){
  69. ItemStack result = InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(11);
  70. ItemMeta resultMeta = result.getItemMeta();
  71. resultMeta.getLore().set(4, InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(13).getItemMeta().getLore().get(2));
  72. result.setItemMeta(resultMeta);
  73. InventoryEnchantPlugin.plugin.getEnchantGUI().setItem(17, result);
  74. return;
  75. }
  76. if (InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(11).getItemMeta().getLore().get(5).isEmpty()){
  77. ItemStack result = InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(11);
  78. ItemMeta resultMeta = result.getItemMeta();
  79. resultMeta.getLore().set(5, InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(13).getItemMeta().getLore().get(2));
  80. result.setItemMeta(resultMeta);
  81. InventoryEnchantPlugin.plugin.getEnchantGUI().setItem(17, result);
  82. return;
  83. }
  84. if (InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(11).getItemMeta().getLore().get(6).isEmpty()){
  85. ItemStack result = InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(11);
  86. ItemMeta resultMeta = result.getItemMeta();
  87. resultMeta.getLore().set(6, InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(13).getItemMeta().getLore().get(2));
  88. result.setItemMeta(resultMeta);
  89. InventoryEnchantPlugin.plugin.getEnchantGUI().setItem(17, result);
  90. return;
  91. }
  92. }
  93. ItemStack result = InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(11);
  94. ItemMeta resultMeta = result.getItemMeta();
  95. resultMeta.setLore(InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(13).getItemMeta().getLore());
  96. result.setItemMeta(resultMeta);
  97. InventoryEnchantPlugin.plugin.getEnchantGUI().setItem(17, result);
  98.  
  99. } else {
  100. player.closeInventory();
  101. player.getInventory().addItem(InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(11));
  102. player.getInventory().addItem(InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(13));
  103. InventoryEnchantPlugin.plugin.getEnchantGUI().clear(11);
  104. InventoryEnchantPlugin.plugin.getEnchantGUI().clear(13);
  105. player.sendMessage(ChatColor.DARK_RED + "You can only enchant a pickaxe with a custom enchanted book!");
  106. return;
  107. }
  108. }
  109. if(clickEvent.getSlot() == 17 && clickEvent.getCurrentItem() == InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(17)){
  110. System.out.println("1");
  111. player.setLevel(player.getLevel() - InventoryEnchantPlugin.plugin.getConfig().getInt("mergeBookCost"));
  112. InventoryEnchantPlugin.plugin.getEnchantGUI().setItem(11, new ItemStack(Material.AIR));
  113. InventoryEnchantPlugin.plugin.getEnchantGUI().setItem(13, new ItemStack(Material.AIR));
  114. return;
  115. }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement