Mapped Config Enchantments

Discussion in 'Plugin Development' started by pablo67340, May 20, 2014.

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

    pablo67340

    Hi there,

    I am trying to make mapped enchantments. E.G

    Config:
    Code:java
    1. Misc:
    2. 17:
    3. - qty:64 #Quantity
    4. - name:'&eJungle Wood' #Name your item.
    5. - price:1000 #Price
    6. - sell:40 #How much you get for selling
    7. - slot:0 #Slot it goes in. Starts at 0
    8. - data:3 #The data id of the item id. e.g 1 oak log is 17. 1 Jungle log is 17:3. You can find these on google.
    9. - enchantments:'Durability:1 Sharpness:4 Unbreaking:3'
    10. 1:
    11. - qty:64
    12. - name:'&eSmooth Stone'
    13. - price:2000
    14. - sell:10
    15. - slot:1
    16. 4:
    17. - qty:64
    18. - name:'&eCobblestone'
    19. - price:2000
    20. - sell:10
    21. - slot:2
    22. Armour:
    23. 310:
    24. - qty:1
    25. - name:'&eDiamond Plate'
    26. - price:1000
    27. - sell:5
    28. - slot:0
    29. 312:
    30. - qty:4
    31. - name:'&eDiamond legs'
    32. - price:2000
    33. - sell:200
    34. - slot:1


    If you notice in the first item in the Misc area has the "enchantments" field. You will also notice i called the enchantments by their names which requires alias's. Thing is i have been researching for hours looking into essentials code because i know the kits config uses the same idea. I have no idea where to start on this one and im completely stumped. Could someone please help me!
     
  2. Offline

    CraftedShack

    Here is how you get enchantments using name:

    Code:java
    1. Enchantment encha = Enchantment.getByName("name");
    2. item.addEnchantment(encha, 1);
     
  3. Offline

    pablo67340

    Thank you good sir. Any more help would be great. Still need help putting that into the format i want in my config.
     
  4. Offline

    xTigerRebornx

  5. Offline

    pablo67340

    Yes i think i may be able to work with this.

    Okay using the class you gave me i was able to setup aliasing. I was also able to setup getting ONE enchantment from the config. But now i need it to get every enchantment. E.G

    Right now it can read:
    enchantments:'Durablilty'

    But i need it to read:
    enchantments:'Durability:1 Sharpness:4'

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  6. Offline

    xTigerRebornx

    pablo67340 Split the String at a space, causing you to get all the enchants in a String[], then loop through that, splitting at : and adding enchants accordingly?
     
Thread Status:
Not open for further replies.

Share This Page