Editable Custom Config

Discussion in 'Spigot Plugin Development' started by kinukin, Jun 4, 2017.

  1. Code (Text):
    public static File customFile = new File(Main.plugin.getDataFolder() , "Weapons.yml");
        public static FileConfiguration customConfig = YamlConfiguration.loadConfiguration(customFile);
        public static void createConfig() {
            if(!customFile.exists())
                try {
                    customFile.createNewFile();
                } catch (IOException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }


        Items.customConfig.addDefault("Name", ""); //How can I make these editable in the config?
            Items.customConfig.addDefault("Cost", ""); //How can I make these editable in the config?
            Items.customConfig.addDefault("Trap", ""); //How can I make these editable in the config?
            Items.customConfig.addDefault("Type", ""); //How can I make these editable in the config?

        try {
               
                Items.customConfig.save(Items.customFile);
            } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
     
    I'm trying to make a editable config and write values into them manually.

    Thanks!
     
  2. Can you explain a bit more please?
     
  3. More Info is nice..
     
    • Agree Agree x 1