diff options
author | xander <xander@isxander.dev> | 2022-09-01 11:58:49 +0100 |
---|---|---|
committer | xander <xander@isxander.dev> | 2022-09-01 11:58:49 +0100 |
commit | 4d977cc9764ecf0073650f126700f6ff638fa06b (patch) | |
tree | 883e68bbd80874c048b3e34db59bf0aa926b489b /src/main/java/dev/isxander/yacl/api/YetAnotherConfigLib.java | |
parent | e63a3c989e3a899bdc81558dd2e4c5cc2c659bde (diff) | |
download | YetAnotherConfigLib-4d977cc9764ecf0073650f126700f6ff638fa06b.tar.gz YetAnotherConfigLib-4d977cc9764ecf0073650f126700f6ff638fa06b.tar.bz2 YetAnotherConfigLib-4d977cc9764ecf0073650f126700f6ff638fa06b.zip |
javadoc!
added LongSliderController
renamed Control -> Controller
add minecraft simple option binding constructor
Diffstat (limited to 'src/main/java/dev/isxander/yacl/api/YetAnotherConfigLib.java')
-rw-r--r-- | src/main/java/dev/isxander/yacl/api/YetAnotherConfigLib.java | 60 |
1 files changed, 59 insertions, 1 deletions
diff --git a/src/main/java/dev/isxander/yacl/api/YetAnotherConfigLib.java b/src/main/java/dev/isxander/yacl/api/YetAnotherConfigLib.java index a31a4fb..34ccc6a 100644 --- a/src/main/java/dev/isxander/yacl/api/YetAnotherConfigLib.java +++ b/src/main/java/dev/isxander/yacl/api/YetAnotherConfigLib.java @@ -10,21 +10,45 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.function.Consumer; +/** + * Main class of the mod. + * Contains all data and used to provide a {@link Screen} + */ public interface YetAnotherConfigLib { - + /** + * Title of the GUI. Only used for Minecraft narration. + */ Text title(); + /** + * Gets all config categories. + */ ImmutableList<ConfigCategory> categories(); + /** + * Ran when changes are saved. Can be used to save config to a file etc. + */ Runnable saveFunction(); + /** + * Ran every time the YACL screen initialises. Can be paired with FAPI to add custom widgets. + */ Consumer<YACLScreen> initConsumer(); + /** + * Generates a Screen to display based on this instance. + * + * @param parent parent screen to open once closed + */ Screen generateScreen(@Nullable Screen parent); + /** + * Creates a builder to construct YACL + */ static Builder createBuilder() { return new Builder(); } @@ -39,6 +63,11 @@ public interface YetAnotherConfigLib { } + /** + * Sets title of GUI for Minecraft narration + * + * @see YetAnotherConfigLib#title() + */ public Builder title(@NotNull Text title) { Validate.notNull(title, "`title` cannot be null"); @@ -46,6 +75,12 @@ public interface YetAnotherConfigLib { return this; } + /** + * Adds a new category. + * To create a category you need to use {@link ConfigCategory#createBuilder()} + * + * @see YetAnotherConfigLib#categories() + */ public Builder category(@NotNull ConfigCategory category) { Validate.notNull(category, "`category` cannot be null"); @@ -53,6 +88,24 @@ public interface YetAnotherConfigLib { return this; } + /** + * Adds multiple categories at once. + * To create a category you need to use {@link ConfigCategory#createBuilder()} + * + * @see YetAnotherConfigLib#categories() + */ + public Builder categories(@NotNull Collection<ConfigCategory> categories) { + Validate.notEmpty(categories, "`categories` cannot be empty"); + + this.categories.addAll(categories); + return this; + } + + /** + * Used to define a save function for when user clicks the Save Changes button + * + * @see YetAnotherConfigLib#saveFunction() + */ public Builder save(@NotNull Runnable saveFunction) { Validate.notNull(saveFunction, "`saveFunction` cannot be null"); @@ -60,6 +113,11 @@ public interface YetAnotherConfigLib { return this; } + /** + * Defines a consumer that is accepted every time the YACL screen initialises + * + * @see YetAnotherConfigLib#initConsumer() + */ public Builder screenInit(@NotNull Consumer<YACLScreen> initConsumer) { Validate.notNull(initConsumer, "`initConsumer` cannot be null"); |