Class ConfigurationYAML

java.lang.Object
de.Keyle.MyPet.api.util.configuration.ConfigurationYAML

public class ConfigurationYAML extends Object
One YAML file on disk, with load, save and clear operations over its parsed contents.
  • Field Details

    • yamlFile

      public final File yamlFile
      The file this configuration reads from and writes to.
  • Constructor Details

    • ConfigurationYAML

      public ConfigurationYAML(String path)
      Opens the file at the given path, loading it immediately.
      Parameters:
      path - path to the YAML file
    • ConfigurationYAML

      public ConfigurationYAML(File file)
      Opens the given file, loading it immediately.
      Parameters:
      file - the YAML file
  • Method Details

    • saveConfig

      public boolean saveConfig()
      Writes the current contents back to disk.
      Returns:
      true if the write succeeded
    • loadConfig

      public boolean loadConfig()
      Re-reads the file from disk, replacing the current contents.
      Returns:
      true if the file was read successfully
    • clearConfig

      public void clearConfig()
      Discards the loaded contents, leaving an empty configuration.
    • getConfig

      public FileConfiguration getConfig()
      The parsed contents of yamlFile.
      Returns:
      the live configuration; edits are written out by saveConfig()