java.lang.Object
org.polyfrost.oneconfig.api.config.v1.Config

public abstract class Config extends Object
  • Field Details

    • tree

      protected org.polyfrost.oneconfig.api.config.v1.Tree tree
    • id

      public final String id
    • title

      public final String title
    • iconPath

      public final String iconPath
    • category

      public final Config.Category category
  • Constructor Details

    • Config

      public Config(@NotNull @NotNull String id, @Nullable @Nullable String iconPath, @NotNull @NotNull String title, @Nullable @Nullable Config.Category category)
      Parameters:
      iconPath - the path to your mod's icon file, must be located within your mod-specific assets folder as to avoid conflicts.
    • Config

      public Config(@NotNull @NotNull String id, @NotNull @NotNull String title, @NotNull @NotNull Config.Category category)
  • Method Details

    • addAliases

      public final void addAliases(String... aliases)
    • addAliases

      public final void addAliases(String option, String... aliases)
    • makeTree

      @Internal protected org.polyfrost.oneconfig.api.config.v1.Tree makeTree()
    • addToInitQueue

      @Internal protected void addToInitQueue()
    • initialize

      @MustBeInvokedByOverriders protected void initialize(boolean byConfigManager)
      Use this method to add any initialization logic to your config, for example hideIf(String, String), etc.
      make sure to call super!
    • addDependency

      protected void addDependency(String option, String name, Supplier<org.polyfrost.oneconfig.api.config.v1.Property.Display> condition)
    • restoreDefaults

      protected void restoreDefaults()
    • restoreProperty

      protected void restoreProperty(String option)
    • addDependency

      protected void addDependency(String option, String condition)
    • hideIf

      protected void hideIf(String option, BooleanSupplier condition)
    • hideIf

      protected void hideIf(String option, String condition)
    • addDependency

      protected void addDependency(String option, String condition, boolean hide)
      Add a dependency on the given option, which will gray out or hide the option unless condition is true.
      Parameters:
      option - the option to add the dependency to
      condition - the boolean option which provides the dependency
    • addCallback

      protected <T> void addCallback(String option, Predicate<T> callback)
      Add a callback to the specified option path, which is dot-separated for sub-configs.
      The name of the option should be the name of the field.
    • addCallback

      protected void addCallback(String option, Runnable callback)
      Add a callback to the specified option path, which is dot-separated for sub-configs.
      The name of the option should be the name of the field.
    • getTree

      public org.polyfrost.oneconfig.api.config.v1.Tree getTree()
    • addMigrationEntry

      protected void addMigrationEntry(String oldName, String newName)
      Add a migration entry to the config. This should be in the format of oldName -> newName.
      To be used in conjunction with loadFrom(String) or loadFrom(Path) to migrate old configs to new ones.
    • addMigrationEntries

      protected void addMigrationEntries(String... entries)
      Add multiple migration entries to the config. This should be in the format of pairs, where the first element is the old name and the second element is the new name.
      To be used in conjunction with loadFrom(String) or loadFrom(Path) to migrate old configs to new ones.
    • loadFrom

      protected void loadFrom(String id)
    • loadFrom

      protected void loadFrom(Path p)
    • getProperty

      protected org.polyfrost.oneconfig.api.config.v1.Property<?> getProperty(String option)
    • getProperty

      protected static org.polyfrost.oneconfig.api.config.v1.Property<?> getProperty(org.polyfrost.oneconfig.api.config.v1.Tree tree, String option)
    • save

      public void save()
    • preload

      public void preload()
      If you intend for your Config to be its own self-contained class, you may need to call this method in your mod constructor to ensure that this class is initialized by Java.
      If you don't call this method, your config might not appear in the UI. It will still function correctly, and after some code that loads it is called, it will appear.