help me with my config.yml file

Discussion in 'Plugin Development' started by Beno65Dev, May 18, 2014.

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


    can anyone help me with me config.yml file it's me all did manage to add the config but not to what to change, I want you the enchantment level can change the item myself but not good.Here is the code that it doesn't work:


    import java.util.Arrays;

    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.enchantments.Enchantment;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;

    public class Itemstacks {

    public static ItemStack troll(){

    ItemStack troll = new ItemStack(Material.STICK);
    ItemMeta meta = troll.getItemMeta();
    meta.setDisplayName(ChatColor.GOLD + "Troll" + ChatColor.RED + "stick!");
    meta.setLore(Arrays.asList(ChatColor.BLUE + "troll what people!"));
    troll.addUnsafeEnchantment(Enchantment.KNOCKBACK, Config.getEnchantLevel());
    return troll;
    There is a error on troll.addUnsafeEnchantment (Enchantment.KNOCKBACK, Config. getEnchantLevel ());

    This is my config class:


    import me.troll.stick.Main;

    import org.bukkit.configuration.file.FileConfiguration;

    public class Config {
    static FileConfiguration conf = Main.getInstance().getConfig();

    public static String getEnchantLevel(){
    return getFileConfiguration().getString("trollstick.enchant_level");

    public static FileConfiguration getFileConfiguration(){
    return conf;

    public static void initConfig() {
    if (!getFileConfiguration().contains("trollstick.enchant_level")){
    getFileConfiguration().addDefault("trollstick.enchant_level", "10");


    the Itemstack class say that it must be an int but at me config class a String

    i hope you can help me
  2. Beno65Dev Simply change it to this in your Config class.
    1. public static int getEnchantLevel() {
    2. return getFileConfiguration().getInt("trollstick.enchant_level");
    3. }
  3. Offline


    thanks for the help, but how do I get those dark pieces of code: java above it
  4. Offline


    1. [syntax=java][/syntax]
  5. Or, to input formatted code (assuming it's formatted in Eclipse or your IDE), you can press the code button
    which is next to the quote button, select the language (Java) and paste it there.
Thread Status:
Not open for further replies.

Share This Page