Solved Dropped items enchanting different items?

Discussion in 'Plugin Development' started by iClipse, Oct 7, 2016.

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

    iClipse

    So I have an idea for a plugin I wanna work on, but there are afew problems. What I want to do is make it so that when you drop lets say a diamond sword onto an enchantment table with a wither skull it gets Lifesteal I added to the lore. So can someone show me how to do it? Thanks.
     
  2. Offline

    Zombie_Striker

    @iClipse
    1. Create a List of "Items". This will contain all dropped swords.
    2. Go into the onEnable. Inside here create a Repeating task
    3. Inside the task, loop through all the items in the list. Use an Iterator object for this.
    4. Add an if statement to check if the item is on the ground.
    5. If the block the item is located on is equal to an enchantment table, add the lifesteal enchantment
    6. If the item is not on an enchantment table, remove it from the list. this is why you have to use an iterator object
    7. Listen to ItemDropEvent.
    8. If the dropped item is equal to a sword, put it into the list.
     
    iClipse likes this.
  3. Offline

    iClipse

    om my goodness. thankyou. I didnt even know itemdropevent existed (im abit new)!
     
Thread Status:
Not open for further replies.

Share This Page