Solved YamlConfiguration for 1.5.2 MC

Discussion in 'Spigot Plugin Development' started by Kozs, Feb 15, 2017.

  1. Did anything essential change to the YamlConfiguration between current version and 1.5.2 MC? I can't seem to use my config I use for current MC on an older version. It appears to properly save but it doesn't write to the file.

    Code (Text):

    MineResetter.getInstance().getConfigManager().getConfig("mines.yml").set("mine-" + mineName + ".delay", mineDelay);
    MineResetter.getInstance().getConfigManager().getConfig("mines.yml").set("mine-" + mineName + ".corner1", loc1);
    MineResetter.getInstance().getConfigManager().getConfig("mines.yml").set("mine-" + mineName + ".corner2", loc2);
    Code (Text):

        public YamlConfiguration getConfig(String name) {
            File f = new File(plugin.getDataFolder() + "/" + name);
            return YamlConfiguration.loadConfiguration(f);
    The data is properly parsing and sending there is no errors being displayed. Just doesn't seem to work! It is LATE so perhaps I am missing something that I will notice in the morning.

    Thanks for the help regardless spigot! Great to have friends :D

    I know the saving works because it updates in the "Date Modified" whenever I run the command.

    Debugged the hell out of it and the path is correctly pointing to the proper path.

    - Zach
  2. @Kozs This part sketches me out:
    Code (Text):
    . It could be returning an entirely new instance, and none of those instances could relate to the one associated with saveMines(). We'd need the configmanager code to know.
  3. MiniDigger


    @Drkmaster83 is right, you are always loading a new instance of your config.
    in your config manager you should have a map with all loaded configs so you don't load new configs if you already have it loaded in your getConfig method. always loading a new config is not only slow (IO is always slow) but you also loose any modifications to your previously loaded configs.
  4. Ah yeah I used to hold it all in a map but I was having issues, I will go back to the map and make sure it's going through the same instance. Was late last night