Skip to content

Commit

Permalink
Merge pull request #334 from AzureAaron/yacl3
Browse files Browse the repository at this point in the history
Config Tweaks
  • Loading branch information
AzureAaron authored Oct 3, 2023
2 parents 555161a + 80d2141 commit 88e2088
Show file tree
Hide file tree
Showing 14 changed files with 268 additions and 117 deletions.
18 changes: 14 additions & 4 deletions src/main/java/me/xmrvizzy/skyblocker/config/ConfigUtils.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
package me.xmrvizzy.skyblocker.config;

import dev.isxander.yacl3.api.Option;
import dev.isxander.yacl3.api.controller.BooleanControllerBuilder;
import dev.isxander.yacl3.api.controller.EnumControllerBuilder;
import me.xmrvizzy.skyblocker.config.controllers.EnumDropdownControllerBuilder;

public class ConfigUtils {
@SuppressWarnings("unchecked")
public static <E extends Enum<E>> EnumControllerBuilder<E> createEnumCyclingListController(Option<E> opt) {
return EnumControllerBuilder.create(opt).enumClass((Class<E>) opt.binding().defaultValue().getClass());
}
public static BooleanControllerBuilder createBooleanController(Option<Boolean> opt) {
return BooleanControllerBuilder.create(opt).yesNoFormatter().coloured(true);
}

@SuppressWarnings("unchecked")
public static <E extends Enum<E>> EnumControllerBuilder<E> createEnumCyclingListController(Option<E> opt) {
return EnumControllerBuilder.create(opt).enumClass((Class<E>) opt.binding().defaultValue().getClass());
}

public static <E extends Enum<E>> EnumDropdownControllerBuilder<E> createEnumDropdownController(Option<E> opt) {
return EnumDropdownControllerBuilder.create(opt);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import dev.isxander.yacl3.api.ConfigCategory;
import dev.isxander.yacl3.api.Option;
import dev.isxander.yacl3.api.OptionDescription;
import dev.isxander.yacl3.api.controller.BooleanControllerBuilder;
import dev.isxander.yacl3.api.controller.StringControllerBuilder;
import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
import me.xmrvizzy.skyblocker.config.ConfigUtils;
Expand All @@ -21,7 +20,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
.binding(defaults.richPresence.enableRichPresence,
() -> config.richPresence.enableRichPresence,
newValue -> config.richPresence.enableRichPresence = newValue)
.controller(BooleanControllerBuilder::create)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<SkyblockerConfig.Info>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.richPresence.info"))
Expand All @@ -36,7 +35,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
.binding(defaults.richPresence.cycleMode,
() -> config.richPresence.cycleMode,
newValue -> config.richPresence.cycleMode = newValue)
.controller(BooleanControllerBuilder::create)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<String>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.richPresence.customMessage"))
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import dev.isxander.yacl3.api.Option;
import dev.isxander.yacl3.api.OptionDescription;
import dev.isxander.yacl3.api.OptionGroup;
import dev.isxander.yacl3.api.controller.BooleanControllerBuilder;
import dev.isxander.yacl3.api.controller.IntegerFieldControllerBuilder;
import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
import me.xmrvizzy.skyblocker.config.ConfigUtils;
Expand All @@ -25,21 +24,21 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
.binding(defaults.locations.dwarvenMines.enableDrillFuel,
() -> config.locations.dwarvenMines.enableDrillFuel,
newValue -> config.locations.dwarvenMines.enableDrillFuel = newValue)
.controller(BooleanControllerBuilder::create)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.dwarvenMines.solveFetchur"))
.binding(defaults.locations.dwarvenMines.solveFetchur,
() -> config.locations.dwarvenMines.solveFetchur,
newValue -> config.locations.dwarvenMines.solveFetchur = newValue)
.controller(BooleanControllerBuilder::create)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.dwarvenMines.solvePuzzler"))
.binding(defaults.locations.dwarvenMines.solvePuzzler,
() -> config.locations.dwarvenMines.solvePuzzler,
newValue -> config.locations.dwarvenMines.solvePuzzler = newValue)
.controller(BooleanControllerBuilder::create)
.controller(ConfigUtils::createBooleanController)
.build())

//Dwarven HUD
Expand All @@ -51,13 +50,13 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
.binding(defaults.locations.dwarvenMines.dwarvenHud.enabled,
() -> config.locations.dwarvenMines.dwarvenHud.enabled,
newValue -> config.locations.dwarvenMines.dwarvenHud.enabled = newValue)
.controller(BooleanControllerBuilder::create)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<SkyblockerConfig.DwarvenHudStyle>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.style"))
.description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.style.@Tooltip[0]",
.description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.style.@Tooltip[0]"),
Text.translatable("text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.style.@Tooltip[1]"),
Text.translatable("text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.style.@Tooltip[2]"))))
Text.translatable("text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.style.@Tooltip[2]")))
.binding(defaults.locations.dwarvenMines.dwarvenHud.style,
() -> config.locations.dwarvenMines.dwarvenHud.style,
newValue -> config.locations.dwarvenMines.dwarvenHud.style = newValue)
Expand All @@ -73,7 +72,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
.binding(defaults.locations.dwarvenMines.dwarvenHud.enableBackground,
() -> config.locations.dwarvenMines.dwarvenHud.enableBackground,
newValue -> config.locations.dwarvenMines.dwarvenHud.enableBackground = newValue)
.controller(BooleanControllerBuilder::create)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Integer>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.x"))
Expand Down
Loading

0 comments on commit 88e2088

Please sign in to comment.