Class YamlConfigurationManager

java.lang.Object
net.mathias2246.buildmc.util.config.YamlConfigurationManager

public abstract class YamlConfigurationManager extends Object
An abstract utility-class for managing a configuration
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final org.bukkit.configuration.file.FileConfiguration
    The configuration instance that is managed by this ConfigurationManager
  • Constructor Summary

    Constructors
    Constructor
    Description
    YamlConfigurationManager(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull String resourceName)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract void
    Executed before writing to disk
    void
     
    void
    Saves the configuration to the current config file.
    void
    Saves the default config from the plugins resources if the file doesn't exist
    void
    setConfigFile(@NotNull File file)
    Sets the file that this ConfigurationManager accesses.
    abstract void
    Executed when the config file gets loaded.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • configuration

      public final org.bukkit.configuration.file.FileConfiguration configuration
      The configuration instance that is managed by this ConfigurationManager
  • Constructor Details

    • YamlConfigurationManager

      public YamlConfigurationManager(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull String resourceName)
      Parameters:
      plugin - The plugin that owns this configuration
      resourceName - The name of the default configuration resource
  • Method Details

    • setConfigFile

      public void setConfigFile(@NotNull @NotNull File file)
      Sets the file that this ConfigurationManager accesses. This also executes the setupConfiguration method to set up all the data after loading from the disk
    • save

      public void save() throws IOException
      Saves the configuration to the current config file. Before saving, execute the preSave method with your logic of processing and formating the data that is saved.
      Throws:
      IOException
    • setupConfiguration

      public abstract void setupConfiguration()
      Executed when the config file gets loaded. Used to set up all information.
    • reload

      public void reload()
    • preSave

      protected abstract void preSave()
      Executed before writing to disk
    • saveFromResource

      public void saveFromResource()
      Saves the default config from the plugins resources if the file doesn't exist