Class CommentedConfig

java.lang.Object
studio.magemonkey.codex.mccore.config.CommentedConfig
Direct Known Subclasses:
CommentedLanguageConfig

public class CommentedConfig extends Object
Handles configs with comment and UTF-8 support. Can be used to handle config.yml to preserve/manage comments as well.
  • Constructor Details

    • CommentedConfig

      public CommentedConfig(org.bukkit.plugin.java.JavaPlugin plugin, String name)
      Constructor
      Parameters:
      plugin - plugin reference
      name - file name
  • Method Details

    • getFileName

      public String getFileName()
      Returns:
      name of the file this config saves to
    • clear

      public void clear()

      Clears all of the data in the config

      This doesn't save the config so if you want the changes to be reflected in the actual file, call the save() method after doing this.

    • reload

      public void reload()
      Reloads the config data
    • getConfig

      public DataSection getConfig()
      Returns:
      config file
    • save

      public void save()
      Saves the config
    • saveDefaultConfig

      public void saveDefaultConfig()
      Saves the default config if no file exists yet
    • checkDefaults

      public void checkDefaults()

      Checks the configuration for default values, copying default values over if they are not set. Once finished, the config is saved so the user can see the changes.

      This acts differently than saveDefaultConfig() as the config can already exist for this method. This is more for making sure users do not erase needed values from settings configs.

    • trim

      public void trim()

      Trims excess (non-default) values from the configuration

      Any values that weren't in the default configuration are removed

      This is primarily used for settings configs

    • getPlugin

      public org.bukkit.plugin.java.JavaPlugin getPlugin()
      Returns:
      plugin owning this config file
    • getConfigFile

      public File getConfigFile()

      Retrieves the file of the configuration

      Returns:
      the file of the configuration