Plugin Help Values don't get saved in config.yml file

Discussion in 'Plugin Help/Development/Requests' started by xImCadium, Apr 24, 2016.

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

    xImCadium

    Hey guys,
    I wanted to write a plugin, thats takes my position when I type the command and writes the value of if to the config.yml file, but that doesn't work. I made a second command to write the Location into the config.yml file, that works, I can also access that value, but when I reload the server, the config file is empty, also when I open the config file in my plugin, the file is empty.
    Here's my code of the command which should write the x-position of the player to the config:

    Code:
    @Override
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            if(label.equalsIgnoreCase("config")){
                this.getConfig().addDefault("Config.x1", Manager.getLocation1().getX());
                int configx = this.getConfig().getInt("Config.x1");
               
                sender.sendMessage("config: " + configx);
               
                return true;
            }
    Here my loadConfig method:
    Code:
        public void loadConfig(){
            getConfig().options().copyDefaults(true);
            saveConfig();
           
        }
    Hope you could help me, thank you :D
     
  2. Please don't mark this as 'Plugin Help', mark it as 'Plugin Development' and to get a quick response, move this to the 'Plugin Development' thread.

    And why didn't you put your "loadConfig" method in your onEnable? When the plugin enables, so should the config.

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

Share This Page