YAML Files

Discussion in 'Spigot Plugin Help' started by HatredPvP, May 4, 2017.

  1. Hi, I have been experimenting with config,data,language files. I was wondering how would I go about having them each in their own files, and getting/setting them in classes (I looked at the docs, still dont understand it)
     
  2. WAS

    WAS

    Code (Java):
    YamlConfiguration yml = new YamlConfiguration();
    // Load a YAML file...
    yml.load(plugin.getDataFolder().getPath()+"myLangFile.yml");
    // Get a "String"
    yml.getString("local.some-string", "Default Lang String");
    // Set a value
    yml.set("local.some-string", "Some new string");
    // Save yaml file
    yml.save();
    Maybe something like that?

    Woops, you'll need to supply a File

    Code (Java):
    //...
    File langConfig = new File(plugin.getDataFolder().getPath()+"myLangFile.yml");
    yml.load(langConfig);
    //...
    yml.save(langConfig);
     
    #2 WAS, May 4, 2017
    Last edited: May 4, 2017