Class BaseOptions<T>

java.lang.Object
net.dillon.dillonlib.util.BaseOptions<T>
Direct Known Subclasses:
DillonLibOptions.DillonLibOptionsHandler

public abstract class BaseOptions<T> extends Object
A base class for registering options on different multiple environment sides. You can customize this however you'd like, by setting instances of options, a custom Gson setup, config directory, and a update function to directly update your options.
Since:
1.0
See Also:
  • Field Details

    • instance

      protected T instance
  • Constructor Details

    • BaseOptions

      public BaseOptions(String fileName)
      Constructor which initializes the file id and the instance of the options.
  • Method Details

    • createDefault

      protected abstract T createDefault()
      Returns the type to get the options from.
    • getConfigClass

      protected abstract Class<T> getConfigClass()
      Returns the class to get the options from.
    • createGson

      public com.google.gson.Gson createGson()
      Creates the GSON reader, which reads options correctly.
    • configDir

      public String configDir()
      Returns the config directory to be resolved. Leave blank for default .minecraft/config directory.
    • safeCheck

      protected void safeCheck()
      Runs a safe check through all options to ensure no issues.

      Preforms a "safe check" on all options, and makes sure that they are valid and safe to run in-game.

    • getFileName

      public String getFileName()
      Returns:
      the file name.
    • getFile

      public File getFile()
      Returns:
      the file.
    • getCustomDir

      public File getCustomDir()
      Returns:
      the custom directory.
    • getInstance

      public T getInstance()
      Gets the instance of options.
    • setInstance

      public void setInstance(T instance)
      Sets current instance to a new option instance.
    • setFileName

      public void setFileName(String fileName)
      Sets and creates a new file.
    • setCustomDirectory

      public void setCustomDirectory(File dir)
      Creates a new custom directory for the server file.
    • clearCustomDirectory

      public void clearCustomDirectory()
      Clears custom directory.
    • update

      public void update(Consumer<T> options)
      Updates a config option and saves it.
    • save

      public void save()
      Saves this config.
    • load

      public void load()
      Loads this config.
    • getConfigFile

      public File getConfigFile()
      Gets this config file.