Solved Editing config in-game issue

Discussion in 'Plugin Development' started by GxG, Apr 15, 2016.

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

    GxG

    I am trying to edit the config.yml in-game and I have everything working but when I save/set the config it only adds the lines when I execute the command.

    Default Configuration file:
    Code:
    # Configure the repeating title #
    title-message: 'Change me in Config.yml!'
    
    # Configure the repeating subtitle #
    subtitle-message: 'Change me in Config.yml!'
    
    # Configure the repeated message in chat #
    repeated-chat: 'Change me in Config.yml!'
    
    # Configure the time (IN SECONDS) between each message #
    wait-time: 10
    Command:
    Code:
    if (args[0].equalsIgnoreCase("subtitle")) {
                    for (int i = 1; i < args.length; i++) {
                        str.append(args[i] + " ");
                    }
                    String subtitle = str.toString();
                    getConfig().set("subtitle-message", subtitle);
                    saveConfig();
                    reloadConfig();
                    sender.sendMessage(
                            ChatColor.GOLD + "CyotixBroadcast " + ChatColor.BLUE + ">> SubTitle been set: " + subtitle);
                    return true;
                }
    Config after the command:

    Code:
    # Configure the repeating title #
    title-message: 'Hello '
    
    It also removes only some of the comments but leaves first

    EDIT: I added the line and solved it
    Code:
    getConfig().options().copyDefaults(true);
     
    Last edited: Apr 15, 2016
  2. Offline

    timtower Moderator Moderator

    @GxG Remove all comments, try again.
     
  3. Offline

    GxG

    @timtower Still does the same thing, I even tried removing lines.
     
  4. Offline

    timtower Moderator Moderator

    @GxG The config.yml in the plugin itself and from the generated one?
    Server log?
     
  5. Offline

    GxG

    @timtower I edit it itself in the config.yml in eclipse.
    There is nothing in the server log, other than saying all my plugins have been enabled.
     
  6. Offline

    timtower Moderator Moderator

    @GxG Did you also remove the config.yml in your plugins folder?
     
  7. Offline

    GxG

    @timtower Yes I deleted the whole folder and have it regenerate itself before I test the command
     
  8. Offline

    timtower Moderator Moderator

    @GxG Updated config?
     
  9. Offline

    MasterDoctor

    Try saving the data to another config - I've had this before - by saving the data to the main config, the Configuration API recreates said config - and the Configuration API only knows how to save a comment on the first line!
    Edit: Updated wording
     
  10. Offline

    GxG

    @timtower Not sure what you mean? I made sure to remove all comments and made sure it updated without the comments then executed the command and reload the config and it only shows:
    Code:
    title-message: 'Hello '
     
  11. Offline

    timtower Moderator Moderator

    @GxG Could you post the config in your jar?
     
  12. Offline

    GxG

    @timtower I did in the OP but here is the update one in my jar
    Code:
    title-message: 'Change me in Config.yml!'
    subtitle-message: 'Change me in Config.yml!'
    repeated-chat: 'Change me in Config.yml!'
    wait-time: 10
     
Thread Status:
Not open for further replies.

Share This Page