Custom Enchant Books Help

Discussion in 'Plugin Development' started by Keubix, Aug 13, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Keubix

    Hello! I am creating a custom enchants plugin for my server, and I am not sure how to create a book, that when picked up and placed on an item, it will add an enchant lore to that item. What I mean by this is, I pick up the book (I am now moving the book around in my inventory with my cursor,) I want to be able to get when that book is placed in a slot that has a armor/weapon item. I would like to be able to place a lore on that armor/weapon. Thanks in advance guys!
     
  2. Offline

    teej107

  3. Offline

    Chiller

    @Keubix More specifically this:
    Code:
    @EventHandler
    public void onInventoryMoveItem(InventoryClickEvent event)
    {
        if (event.getAction() == InventoryAction.SWAP_WITH_CURSOR)
        {
            if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR)
            {
                event.setCancelled(true);
               
                ItemStack cursor = event.getCursor();
                ItemStack droppedOn = event.getCurrentItem();
               
                ItemMeta cursorMeta = cursor.getItemMeta();
                ItemMeta droppedOnMeta = cursor.getItemMeta();
               
                cursorMeta.setDisplayName(ChatColor.AQUA + "Special Item");
               
                cursor.setItemMeta(cursorMeta);
                cursor.addEnchantment(Enchantment.SILK_TOUCH, 1);
            }
        }
    }
    
     
  4. Offline

    teej107

    @Chiller Since when was this a code handout club?
     
    Keubix and Synapz like this.
  5. Offline

    Keubix

    Thanks @Chiller. @teej107 welcome to the 21st century, where people are dumb, and need the code written for themselves xD. I am not one of those people though, I just did not know action for this scenario.
     
Thread Status:
Not open for further replies.

Share This Page