Class Config
java.lang.Object
org.polyfrost.oneconfig.api.config.v1.Config
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA category for the config, used for sorting in the UI. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConfig(@NotNull String id, @NotNull String title, @NotNull Config.Category category) Config(@NotNull String id, @Nullable String iconPath, @NotNull String title, @Nullable Config.Category category) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddAliases(String... aliases) final voidaddAliases(String option, String... aliases) protected voidaddCallback(String option, Runnable callback) Add a callback to the specified option path, which is dot-separated for sub-configs.protected <T> voidaddCallback(String option, Predicate<T> callback) Add a callback to the specified option path, which is dot-separated for sub-configs.protected voidaddDependency(String option, String condition) protected voidaddDependency(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.protected voidaddDependency(String option, String name, Supplier<org.polyfrost.oneconfig.api.config.v1.Property.Display> condition) protected voidaddMigrationEntries(String... entries) Add multiple migration entries to the config.protected voidaddMigrationEntry(String oldName, String newName) Add a migration entry to the config.protected voidprotected org.polyfrost.oneconfig.api.config.v1.Property<?> getProperty(String option) protected static org.polyfrost.oneconfig.api.config.v1.Property<?> getProperty(org.polyfrost.oneconfig.api.config.v1.Tree tree, String option) org.polyfrost.oneconfig.api.config.v1.TreegetTree()protected voidprotected voidhideIf(String option, BooleanSupplier condition) protected voidinitialize(boolean byConfigManager) Use this method to add any initialization logic to your config, for examplehideIf(String, String), etc.protected voidprotected voidprotected org.polyfrost.oneconfig.api.config.v1.TreemakeTree()voidpreload()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.protected voidprotected voidrestoreProperty(String option) voidsave()
-
Field Details
-
tree
protected org.polyfrost.oneconfig.api.config.v1.Tree tree -
id
-
title
-
iconPath
-
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
-
addAliases
-
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 examplehideIf(String, String), etc.
make sure to call super! -
addDependency
-
restoreDefaults
protected void restoreDefaults() -
restoreProperty
-
addDependency
-
hideIf
-
hideIf
-
addDependency
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 tocondition- the boolean option which provides the dependency
-
addCallback
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
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
Add a migration entry to the config. This should be in the format of oldName -> newName.
To be used in conjunction withloadFrom(String)orloadFrom(Path)to migrate old configs to new ones. -
addMigrationEntries
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 withloadFrom(String)orloadFrom(Path)to migrate old configs to new ones. -
loadFrom
-
loadFrom
-
getProperty
-
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.
-