Solved Giving players items with data and or enchantments from config

Discussion in 'Plugin Development' started by ItsOneAndTwo, Apr 10, 2014.

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

    ItsOneAndTwo

    Hello bukkit community!

    I've been trying to give players items with data and or enchantments from config.

    What I've tried:
    Code:java
    1. player.getInventory().setHelmet(new ItemStack (plugin.getConfig().getInt("Kits." + sign.getLine(1) + ".Helmet")));
    2. player.getInventory().setChestplate(new ItemStack (plugin.getConfig().getInt("Kits." + sign.getLine(1) + ".Chestplate")));
    3. player.getInventory().setLeggings(new ItemStack (plugin.getConfig().getInt("Kits." + sign.getLine(1) + ".Leggings")));
    4. player.getInventory().setBoots(new ItemStack (plugin.getConfig().getInt("Kits." + sign.getLine(1) + ".Boots")));
    5. for(String str : plugin.getConfig().getStringList("Kits." + sign.getLine(1) + ".Items")) {
    6. player.getInventory().addItem(new ItemStack(Integer.parseInt(str)));
    7. }
    8. player.updateInventory();

    but that obviously won't give items with data or enchantments, what i'm trying to accomplish:

    Config should look something like this:

    Kits:
    Warrior:
    Items: 276:0:1,322:1:1,35:14:1
    Armor: 310,311,312,313
    Enchantments:

    Now what I need is, give a player enchanted diamond sword with enchantments stated in the config. How should I attempt to do this?

    Nevermind, I took a look at the source of KingKits, and I learned how to do it, Cheers.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
Thread Status:
Not open for further replies.

Share This Page