Class Config

java.lang.Object
ch.njol.skript.config.Config
All Implemented Interfaces:
Comparable<Config>

public class Config extends Object implements Comparable<Config>
Represents a config file.
  • Constructor Details

  • Method Details

    • getMainNode

      public SectionNode getMainNode()
    • getFileName

      public String getFileName()
    • save

      public void save(File f) throws IOException
      Saves the config to a file.
      Parameters:
      f - The file to save to
      Throws:
      IOException - If the file could not be written to.
    • setValues

      public boolean setValues(Config other)
      Sets this config's values to those in the given config.

      Used by Skript to import old settings into the updated config. The return value is used to not modify the config if no new options were added.

      Parameters:
      other -
      Returns:
      Whether the configs' keys differ, i.e. false == configs only differ in values, not keys.
    • setValues

      public boolean setValues(Config other, String... excluded)
    • compareValues

      public boolean compareValues(Config other, String... excluded)
      Compares the keys and values of this Config and another.
      Parameters:
      other - The other Config.
      excluded - Keys to exclude from this comparison.
      Returns:
      True if there are differences in the keys and their values of this Config and the other Config.
    • getFile

      @Nullable public @Nullable File getFile()
    • getPath

      @Nullable public @Nullable Path getPath()
    • getSeparator

      public String getSeparator()
      Returns:
      The most recent separator. Only useful while the file is loading.
    • getSaveSeparator

      public String getSaveSeparator()
      Returns:
      A separator string useful for saving, e.g. ": " or " = ".
    • getByPath

      @Nullable public @Nullable String getByPath(String path)
      Splits the given path at the dot character and passes the result to get(String...).
      Parameters:
      path -
      Returns:
      get(path.split("\\."))
    • get

      @Nullable public @Nullable String get(String... path)
      Gets an entry node's value at the designated path
      Parameters:
      path -
      Returns:
      The entry node's value at the location defined by path or null if it either doesn't exist or is not an entry.
    • isEmpty

      public boolean isEmpty()
    • toMap

      public HashMap<String,String> toMap(String separator)
    • validate

      public boolean validate(SectionValidator validator)
    • load

      public void load(Object o)
      Sets all Option fields of the given object to the values from this config
    • load

      public void load(Class<?> c)
      Sets all static Option fields of the given class to the values from this config
    • compareTo

      public int compareTo(@Nullable @Nullable Config other)
      Specified by:
      compareTo in interface Comparable<Config>