Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (clickEvent.getClickedInventory().getName().equalsIgnoreCase(InventoryEnchantPlugin.plugin.getConfig().getString("Item2GUI.name"))) {
- if (clickEvent.getCurrentItem().getType() == Material.STAINED_GLASS_PANE || clickEvent.getCurrentItem().getType() == Material.LEVER) {
- clickEvent.setCancelled(true);
- return;
- }
- if (player.getItemOnCursor().getType() == Material.AIR || player.getItemOnCursor() == null) {
- if (InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(17) != null && InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(17).getType() != Material.AIR){
- if (clickEvent.getSlot() == 13 && clickEvent.getCurrentItem().getType() == Material.ENCHANTED_BOOK && clickEvent.getCurrentItem().hasItemMeta() && clickEvent.getCurrentItem().getItemMeta().hasLore()) {
- player.getInventory().addItem(clickEvent.getCurrentItem());
- InventoryEnchantPlugin.plugin.getEnchantGUI().setItem(13, new ItemStack(Material.BOOK));
- InventoryEnchantPlugin.plugin.getEnchantGUI().setItem(17, new ItemStack(Material.AIR));
- }
- }
- }
- if (clickEvent.getCurrentItem().getType() == Material.BOOK && (!clickEvent.getCurrentItem().hasItemMeta()) && (!clickEvent.getCurrentItem().getItemMeta().hasLore())) {
- clickEvent.setCancelled(true);
- return;
- }
- if (clickEvent.getSlot() == 11 && (clickEvent.getCurrentItem().getType() == Material.DIAMOND_PICKAXE)) {
- 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) {
- clickEvent.setCurrentItem(clickEvent.getCursor());
- clickEvent.setCursor(new ItemStack(Material.AIR));
- } else if (!(clickEvent.getCursor() == null) && !(clickEvent.getCursor().getType() == Material.AIR)) {
- clickEvent.setCancelled(true);
- return;
- }
- }
- if (clickEvent.getSlot() == 13 && clickEvent.getCurrentItem().getType() == Material.BOOK) {
- if ((clickEvent.getCursor().getType() == Material.ENCHANTED_BOOK)) {
- clickEvent.setCurrentItem(clickEvent.getCursor());
- clickEvent.setCursor(new ItemStack(Material.AIR));
- } else if (!(clickEvent.getCursor() == null) && !(clickEvent.getCursor().getType() == Material.AIR)) {
- clickEvent.setCancelled(true);
- return;
- }
- }
- if (clickEvent.getSlot() == 15 ) {
- 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()) {
- if (containsWord("Success", InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(13).getItemMeta().getLore())){
- int random = new Random(100).nextInt();
- if (random > InventoryEnchantPlugin.plugin.getConfig().getInt("minSuccessRate") || random < InventoryEnchantPlugin.plugin.getConfig().getInt("maxSuccessRate")){
- InventoryEnchantPlugin.plugin.getEnchantGUI().setItem(11, new ItemStack(Material.DIAMOND_PICKAXE));
- InventoryEnchantPlugin.plugin.getEnchantGUI().setItem(13, new ItemStack(Material.BOOK));
- player.closeInventory();
- player.sendMessage(ChatColor.translateAlternateColorCodes('&', InventoryEnchantPlugin.plugin.getConfig().getString("breakItemWhenEnchantMsg")));
- return;
- }
- }
- if (containsWord("Destroy", InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(13).getItemMeta().getLore())){
- int random = new Random(100).nextInt();
- if (random > InventoryEnchantPlugin.plugin.getConfig().getInt("minDestroyRate") || random < InventoryEnchantPlugin.plugin.getConfig().getInt("maxDestroyRate")){
- InventoryEnchantPlugin.plugin.getEnchantGUI().setItem(11, new ItemStack(Material.DIAMOND_PICKAXE));
- InventoryEnchantPlugin.plugin.getEnchantGUI().setItem(13, new ItemStack(Material.BOOK));
- player.closeInventory();
- player.sendMessage(ChatColor.translateAlternateColorCodes('&', InventoryEnchantPlugin.plugin.getConfig().getString("breakItemWhenEnchantMsg")));
- return;
- }
- }
- if (InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(11).hasItemMeta() && InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(11).getItemMeta().hasLore()){
- if (InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(11).getItemMeta().getLore().get(3).isEmpty()){
- ItemStack result = InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(11);
- ItemMeta resultMeta = result.getItemMeta();
- resultMeta.getLore().set(3, InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(13).getItemMeta().getLore().get(2));
- result.setItemMeta(resultMeta);
- InventoryEnchantPlugin.plugin.getEnchantGUI().setItem(17, result);
- return;
- }
- if (InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(11).getItemMeta().getLore().get(4).isEmpty()){
- ItemStack result = InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(11);
- ItemMeta resultMeta = result.getItemMeta();
- resultMeta.getLore().set(4, InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(13).getItemMeta().getLore().get(2));
- result.setItemMeta(resultMeta);
- InventoryEnchantPlugin.plugin.getEnchantGUI().setItem(17, result);
- return;
- }
- if (InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(11).getItemMeta().getLore().get(5).isEmpty()){
- ItemStack result = InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(11);
- ItemMeta resultMeta = result.getItemMeta();
- resultMeta.getLore().set(5, InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(13).getItemMeta().getLore().get(2));
- result.setItemMeta(resultMeta);
- InventoryEnchantPlugin.plugin.getEnchantGUI().setItem(17, result);
- return;
- }
- if (InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(11).getItemMeta().getLore().get(6).isEmpty()){
- ItemStack result = InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(11);
- ItemMeta resultMeta = result.getItemMeta();
- resultMeta.getLore().set(6, InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(13).getItemMeta().getLore().get(2));
- result.setItemMeta(resultMeta);
- InventoryEnchantPlugin.plugin.getEnchantGUI().setItem(17, result);
- return;
- }
- }
- ItemStack result = InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(11);
- ItemMeta resultMeta = result.getItemMeta();
- resultMeta.setLore(InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(13).getItemMeta().getLore());
- result.setItemMeta(resultMeta);
- InventoryEnchantPlugin.plugin.getEnchantGUI().setItem(17, result);
- } else {
- player.closeInventory();
- player.getInventory().addItem(InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(11));
- player.getInventory().addItem(InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(13));
- InventoryEnchantPlugin.plugin.getEnchantGUI().clear(11);
- InventoryEnchantPlugin.plugin.getEnchantGUI().clear(13);
- player.sendMessage(ChatColor.DARK_RED + "You can only enchant a pickaxe with a custom enchanted book!");
- return;
- }
- }
- if(clickEvent.getSlot() == 17 && clickEvent.getCurrentItem() == InventoryEnchantPlugin.plugin.getEnchantGUI().getItem(17)){
- System.out.println("1");
- player.setLevel(player.getLevel() - InventoryEnchantPlugin.plugin.getConfig().getInt("mergeBookCost"));
- InventoryEnchantPlugin.plugin.getEnchantGUI().setItem(11, new ItemStack(Material.AIR));
- InventoryEnchantPlugin.plugin.getEnchantGUI().setItem(13, new ItemStack(Material.AIR));
- return;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement