How to reload a custom YML File

Discussion in 'Plugin Development' started by bowlerguy66, Oct 29, 2015.

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

    bowlerguy66

    Is there a method where I can just put in my config and is reloads the config? (I would do reloadConfig(), but its a custom YML file)
     
  2. Offline

    Zombie_Striker

    @bowlerguy66
    You mean is there a way you can clear a config? You can treat the config as a file, delete it, and recreate it, which would leave it blank.
     
  3. Offline

    bowlerguy66

    @Zombie_Striker If a person changes the config file they can do /factory reload then the updated file will be used
     
  4. Offline

    Zombie_Striker

    @bowlerguy66
    I think I might have misunderstood you then.

    What you want is for you plugin to resign values in your plugin (such as if creating an array on start-up, editing the config, and then re-creating the array). Is this correct?
     
  5. Offline

    bowlerguy66

    @Zombie_Striker Jeez, this is a mess.

    So the player has his default values on startup, but when he changes one of the messages in the config, the change hasn't happened in the game. So he needs to do /factory reload to "refresh" the config and make the change take effect ingame
     
  6. Offline

    RoboticPlayer

    @bowlerguy66 reloadConfig() does not do what you think it does. The reloadConfig() method gets the DEFAULT config.yml file and sets the current config.yml values to those. So basically, when you call the reloadConfig method, you are resetting the config to the default.
     
  7. Offline

    teej107

    No. reloadConfig() simply loads the config from the file. That means any values changed in the file would be in effect.

    Here is the documentation for reloadConfig()

    @bowlerguy66 May we see your custom YML file so I can help your from there?
     
  8. Offline

    elian1203

    How do you get the effects from the config file?
    Ex:
    File file = new File("plugins/factory", "customconfig.yml";
    FileConfiguration data = YamlConfiguration.load(file);
    data.getBoolean("death-messages");
    ^ That way works without you having to reload anything.
     
Thread Status:
Not open for further replies.

Share This Page