Adddefaults and save them

Discussion in 'Plugin Development' started by ItzzAran, Jun 14, 2020.

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

    ItzzAran

    Main class:
    Code:
    package me.ItzzAran.mtwapen;
    
    import java.util.ArrayList;
    import java.util.List;
    
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class main extends JavaPlugin{
        List<String> wl = new ArrayList<>();
        @Override
        public void onEnable() {
            new wapens(this);
            getConfig().addDefault("Wapens", wl);
            saveDefaultConfig();
            saveConfig();
            getConfig().options().copyDefaults(true);
        }
    
    }
    
    Command class:
    Code:
    this.plugin.getConfig().set("Wapens", wl);
                        this.plugin.getConfig().addDefault("Wapen-info."+args[1]+".Naam", args[1]);
                        this.plugin.getConfig().addDefault("Wapen-info."+args[1]+".Item", Material.STONE_HOE);
                        this.plugin.getConfig().addDefault("Wapen-info."+args[1]+".Cooldown", 1);
                        this.plugin.getConfig().options().copyDefaults(true);
                        this.plugin.saveConfig();
    I want to create a weapon with a command. And if you create a weapon it will save all its information. Alls works fine, until i restart the server. It doesn't save the defaults. I have already made multiple other plugins with the config. But there i iniate the defaults in the onEnable. Does that make any difference? Or what did i do wrong? It should save it.
     
  2. Offline

    caderapee

    @ItzzAran don't use default. just use set if you want to override
     
Thread Status:
Not open for further replies.

Share This Page