Error with Enchantments.

Discussion in 'Plugin Development' started by TilzyCodes, Oct 27, 2014.

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

    TilzyCodes

    Hello yes, I need abit of help of with my code. I don't know what to replace the ??? with
    Code:java
    1. public ItemStack make() {
    2. ItemStack item = new ItemStack(this.material, this.amount, this.data);
    3. ItemMeta meta = item.getItemMeta();
    4. if (this.name != "") meta.setDisplayName(this.name);
    5. if (this.owner != "") {
    6. SkullMeta smeta = (SkullMeta)item.getItemMeta();
    7. if (this.name != "") smeta.setDisplayName(this.name);
    8. smeta.setOwner(this.owner);
    9. smeta.setLore(this.lore);
    10. item.setItemMeta(smeta);
    11. for (Enchantment enchant : this.enchantments.keySet()) {
    12. item.addEnchantment(enchant, ((Integer)this.enchantments.get(enchant)).intValue());
    13. }
    14. return item;
    15. }
    16. Enchantment enchant;
    17. if (this.enchant != null) {
    18. EnchantmentStorageMeta smeta = (EnchantmentStorageMeta)item.getItemMeta();
    19. smeta.addEnchant(this.enchant, this.level, false);
    20. smeta.setLore(this.lore);
    21. item.setItemMeta(smeta);
    22. for (??? = this.enchantments.keySet().iterator(); ???.hasNext(); ) { enchant = (Enchantment)???.next();
    23. item.addEnchantment(enchant, ((Integer)this.enchantments.get(enchant)).intValue());
    24. }
    25. return item;
    26. }
    27. meta.setLore(this.lore);
    28. item.setItemMeta(meta);
    29. for (Enchantment enchant : this.enchantments.keySet()) {
    30. item.addEnchantment(enchant, ((Integer)this.enchantments.get(enchant)).intValue());
    31. }
    32. return item;
    33. }


    Help me please? its this part for (??? = this.enchantments.keySet().iterator(); ???.hasNext(); ) { enchant = (Enchantment)???.next();
    item.addEnchantment(enchant, ((Integer)this.enchantments.get(enchant)).intValue());
    }
     
  2. TilzyCodes a Set is an interface which makes an object able to iterate through in java. The method "keySet()" should return a Set<Object>. I don't know what you've put in your set, but lets imagine the keySet is made of Enchant's. Then it would look like this:
    Code:java
    1. Set<Enchantment> keySet = enchantments.keySet();
    2. for(Enchantment key : keySet){
    3. // execute your stuff, this loop repeats for every key in your keyset
    4. }

    If your Set is made of Integer, String etc you've to change it. would look like Set<Integer> or Set<String> etc....

    Hope i could help you :)
     
  3. Offline

    TilzyCodes

    I'm new to bukkit coding I don't understand this :(
     
  4. Offline

    CraftCreeper6

  5. Offline

    TilzyCodes

    Can anyone help me then?
     
Thread Status:
Not open for further replies.

Share This Page