Solved Config File Creation

Discussion in 'Spigot Plugin Development' started by swissrust, Jul 16, 2021.

  1. Hello,

    I have been trying to create a section with a name, then setting it's contents with data. Here is my code. There is no error but doesn't create anything.


    Bukkit.getPluginManager().getPlugin("StaffMode").getConfig().createSection("test");

    Bukkit.getPluginManager().getPlugin("StaffMode").getConfig().set(player.getUniqueId().toString() + ".items"+i, player.getInventory().getItem(i));

    These are the config related things, lmk if you need anything else and thank you!
     
  2. Code (Java):

    public void onEnable() {
        ...
        FileConfiguration config = this.getConfig();
        config.options().copyDefaults(true);
        saveDefaultConfig();
        ...
    }
     
     
  3. I want to create a section not the file. I found out how to create the section but don't know how to list unique id, it just doesn't create it.
     
  4. Heres a more detailed one,

    getConfig().createSection("inventory."+player.getUniqueId().toString());

    It is creating the "inventory." but not the player.getUniqueId().toString();
     
  5. Did you ever call Bukkit.getPluginManager().getPlugin("StaffMode").saveConfig() ?
     
  6. I will try now, thanks. It worked, thanks so much!