diff --git a/src/main/java/me/xmrvizzy/skyblocker/config/ConfigUtils.java b/src/main/java/me/xmrvizzy/skyblocker/config/ConfigUtils.java index 4a615ecc54..28ed704bb5 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/config/ConfigUtils.java +++ b/src/main/java/me/xmrvizzy/skyblocker/config/ConfigUtils.java @@ -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 > EnumControllerBuilder createEnumCyclingListController(Option opt) { - return EnumControllerBuilder.create(opt).enumClass((Class) opt.binding().defaultValue().getClass()); - } + public static BooleanControllerBuilder createBooleanController(Option opt) { + return BooleanControllerBuilder.create(opt).yesNoFormatter().coloured(true); + } + + @SuppressWarnings("unchecked") + public static > EnumControllerBuilder createEnumCyclingListController(Option opt) { + return EnumControllerBuilder.create(opt).enumClass((Class) opt.binding().defaultValue().getClass()); + } + + public static > EnumDropdownControllerBuilder createEnumDropdownController(Option opt) { + return EnumDropdownControllerBuilder.create(opt); + } } diff --git a/src/main/java/me/xmrvizzy/skyblocker/config/categories/DiscordRPCCategory.java b/src/main/java/me/xmrvizzy/skyblocker/config/categories/DiscordRPCCategory.java index 2fe1f7757c..1e35bc32a9 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/config/categories/DiscordRPCCategory.java +++ b/src/main/java/me/xmrvizzy/skyblocker/config/categories/DiscordRPCCategory.java @@ -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; @@ -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.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.richPresence.info")) @@ -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.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.richPresence.customMessage")) diff --git a/src/main/java/me/xmrvizzy/skyblocker/config/categories/DungeonsCategory.java b/src/main/java/me/xmrvizzy/skyblocker/config/categories/DungeonsCategory.java index 92a7ddecfa..16439cb573 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/config/categories/DungeonsCategory.java +++ b/src/main/java/me/xmrvizzy/skyblocker/config/categories/DungeonsCategory.java @@ -6,7 +6,6 @@ import dev.isxander.yacl3.api.OptionDescription; import dev.isxander.yacl3.api.OptionFlag; import dev.isxander.yacl3.api.OptionGroup; -import dev.isxander.yacl3.api.controller.BooleanControllerBuilder; import dev.isxander.yacl3.api.controller.FloatFieldControllerBuilder; import dev.isxander.yacl3.api.controller.IntegerFieldControllerBuilder; import dev.isxander.yacl3.api.controller.StringControllerBuilder; @@ -32,7 +31,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.locations.dungeons.secretWaypoints.enableSecretWaypoints, () -> config.locations.dungeons.secretWaypoints.enableSecretWaypoints, newValue -> config.locations.dungeons.secretWaypoints.enableSecretWaypoints = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.noInitSecretWaypoints")) @@ -40,7 +39,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.locations.dungeons.secretWaypoints.noInitSecretWaypoints, () -> config.locations.dungeons.secretWaypoints.noInitSecretWaypoints, newValue -> config.locations.dungeons.secretWaypoints.noInitSecretWaypoints = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .flag(OptionFlag.GAME_RESTART) .build()) .option(Option.createBuilder() @@ -48,63 +47,63 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.locations.dungeons.secretWaypoints.enableEntranceWaypoints, () -> config.locations.dungeons.secretWaypoints.enableEntranceWaypoints, newValue -> config.locations.dungeons.secretWaypoints.enableEntranceWaypoints = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.enableSuperboomWaypoints")) .binding(defaults.locations.dungeons.secretWaypoints.enableSuperboomWaypoints, () -> config.locations.dungeons.secretWaypoints.enableSuperboomWaypoints, newValue -> config.locations.dungeons.secretWaypoints.enableSuperboomWaypoints = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.enableChestWaypoints")) .binding(defaults.locations.dungeons.secretWaypoints.enableChestWaypoints, () -> config.locations.dungeons.secretWaypoints.enableChestWaypoints, newValue -> config.locations.dungeons.secretWaypoints.enableChestWaypoints = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.enableItemWaypoints")) .binding(defaults.locations.dungeons.secretWaypoints.enableItemWaypoints, () -> config.locations.dungeons.secretWaypoints.enableItemWaypoints, newValue -> config.locations.dungeons.secretWaypoints.enableItemWaypoints = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.enableBatWaypoints")) .binding(defaults.locations.dungeons.secretWaypoints.enableBatWaypoints, () -> config.locations.dungeons.secretWaypoints.enableBatWaypoints, newValue -> config.locations.dungeons.secretWaypoints.enableBatWaypoints = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.enableWitherWaypoints")) .binding(defaults.locations.dungeons.secretWaypoints.enableWitherWaypoints, () -> config.locations.dungeons.secretWaypoints.enableWitherWaypoints, newValue -> config.locations.dungeons.secretWaypoints.enableWitherWaypoints = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.enableLeverWaypoints")) .binding(defaults.locations.dungeons.secretWaypoints.enableLeverWaypoints, () -> config.locations.dungeons.secretWaypoints.enableLeverWaypoints, newValue -> config.locations.dungeons.secretWaypoints.enableLeverWaypoints = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.enableFairySoulWaypoints")) .binding(defaults.locations.dungeons.secretWaypoints.enableFairySoulWaypoints, () -> config.locations.dungeons.secretWaypoints.enableFairySoulWaypoints, newValue -> config.locations.dungeons.secretWaypoints.enableFairySoulWaypoints = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.enableStonkWaypoints")) .binding(defaults.locations.dungeons.secretWaypoints.enableStonkWaypoints, () -> config.locations.dungeons.secretWaypoints.enableStonkWaypoints, newValue -> config.locations.dungeons.secretWaypoints.enableStonkWaypoints = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.enableDefaultWaypoints")) @@ -112,7 +111,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.locations.dungeons.secretWaypoints.enableDefaultWaypoints, () -> config.locations.dungeons.secretWaypoints.enableDefaultWaypoints, newValue -> config.locations.dungeons.secretWaypoints.enableDefaultWaypoints = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .build()) @@ -125,7 +124,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.locations.dungeons.dungeonChestProfit.enableProfitCalculator, () -> config.locations.dungeons.dungeonChestProfit.enableProfitCalculator, newValue -> config.locations.dungeons.dungeonChestProfit.enableProfitCalculator = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.dungeonChestProfit.includeKismet")) @@ -133,7 +132,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.locations.dungeons.dungeonChestProfit.includeKismet, () -> config.locations.dungeons.dungeonChestProfit.includeKismet, newValue -> config.locations.dungeons.dungeonChestProfit.includeKismet = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.dungeonChestProfit.includeEssence")) @@ -141,7 +140,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.locations.dungeons.dungeonChestProfit.includeEssence, () -> config.locations.dungeons.dungeonChestProfit.includeEssence, newValue -> config.locations.dungeons.dungeonChestProfit.includeEssence = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.dungeonChestProfit.neutralThreshold")) @@ -156,21 +155,21 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.locations.dungeons.dungeonChestProfit.neutralColor, () -> config.locations.dungeons.dungeonChestProfit.neutralColor, newValue -> config.locations.dungeons.dungeonChestProfit.neutralColor = newValue) - .controller(ConfigUtils::createEnumCyclingListController) + .controller(ConfigUtils::createEnumDropdownController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.dungeonChestProfit.profitColor")) .binding(defaults.locations.dungeons.dungeonChestProfit.profitColor, () -> config.locations.dungeons.dungeonChestProfit.profitColor, newValue -> config.locations.dungeons.dungeonChestProfit.profitColor = newValue) - .controller(ConfigUtils::createEnumCyclingListController) + .controller(ConfigUtils::createEnumDropdownController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.dungeonChestProfit.lossColor")) .binding(defaults.locations.dungeons.dungeonChestProfit.lossColor, () -> config.locations.dungeons.dungeonChestProfit.lossColor, newValue -> config.locations.dungeons.dungeonChestProfit.lossColor = newValue) - .controller(ConfigUtils::createEnumCyclingListController) + .controller(ConfigUtils::createEnumDropdownController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.dungeonChestProfit.incompleteColor")) @@ -178,7 +177,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.locations.dungeons.dungeonChestProfit.incompleteColor, () -> config.locations.dungeons.dungeonChestProfit.incompleteColor, newValue -> config.locations.dungeons.dungeonChestProfit.incompleteColor = newValue) - .controller(ConfigUtils::createEnumCyclingListController) + .controller(ConfigUtils::createEnumDropdownController) .build()) .build()) @@ -189,14 +188,14 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.locations.dungeons.croesusHelper, () -> config.locations.dungeons.croesusHelper, newValue -> config.locations.dungeons.croesusHelper = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.enableMap")) .binding(defaults.locations.dungeons.enableMap, () -> config.locations.dungeons.enableMap, newValue -> config.locations.dungeons.enableMap = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(ButtonOption.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.mapScreen")) @@ -230,14 +229,14 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.locations.dungeons.starredMobGlow, () -> config.locations.dungeons.starredMobGlow, newValue -> config.locations.dungeons.starredMobGlow = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.solveThreeWeirdos")) .binding(defaults.locations.dungeons.solveThreeWeirdos, () -> config.locations.dungeons.solveThreeWeirdos, newValue -> config.locations.dungeons.solveThreeWeirdos = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.blazesolver")) @@ -245,14 +244,14 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.locations.dungeons.blazesolver, () -> config.locations.dungeons.blazesolver, newValue -> config.locations.dungeons.blazesolver = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.solveTrivia")) .binding(defaults.locations.dungeons.solveTrivia, () -> config.locations.dungeons.solveTrivia, newValue -> config.locations.dungeons.solveTrivia = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.solveTicTacToe")) @@ -260,7 +259,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.locations.dungeons.solveTicTacToe, () -> config.locations.dungeons.solveTicTacToe, newValue -> config.locations.dungeons.solveTicTacToe = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) //Livid Color @@ -273,7 +272,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.locations.dungeons.lividColor.enableLividColor, () -> config.locations.dungeons.lividColor.enableLividColor, newValue -> config.locations.dungeons.lividColor.enableLividColor = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.lividColor.lividColorText")) @@ -294,21 +293,21 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.locations.dungeons.terminals.solveColor, () -> config.locations.dungeons.terminals.solveColor, newValue -> config.locations.dungeons.terminals.solveColor = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.terminals.solveOrder")) .binding(defaults.locations.dungeons.terminals.solveOrder, () -> config.locations.dungeons.terminals.solveOrder, newValue -> config.locations.dungeons.terminals.solveOrder = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.terminals.solveStartsWith")) .binding(defaults.locations.dungeons.terminals.solveStartsWith, () -> config.locations.dungeons.terminals.solveStartsWith, newValue -> config.locations.dungeons.terminals.solveStartsWith = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .build()) .build(); diff --git a/src/main/java/me/xmrvizzy/skyblocker/config/categories/DwarvenMinesCategory.java b/src/main/java/me/xmrvizzy/skyblocker/config/categories/DwarvenMinesCategory.java index 42d623acbb..8330ba2aba 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/config/categories/DwarvenMinesCategory.java +++ b/src/main/java/me/xmrvizzy/skyblocker/config/categories/DwarvenMinesCategory.java @@ -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; @@ -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.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.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 @@ -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.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) @@ -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.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.x")) diff --git a/src/main/java/me/xmrvizzy/skyblocker/config/categories/GeneralCategory.java b/src/main/java/me/xmrvizzy/skyblocker/config/categories/GeneralCategory.java index 95b01dfd00..c5e2d34c68 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/config/categories/GeneralCategory.java +++ b/src/main/java/me/xmrvizzy/skyblocker/config/categories/GeneralCategory.java @@ -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.FloatFieldControllerBuilder; import dev.isxander.yacl3.api.controller.IntegerFieldControllerBuilder; import dev.isxander.yacl3.api.controller.IntegerSliderControllerBuilder; @@ -28,35 +27,35 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.general.acceptReparty, () -> config.general.acceptReparty, newValue -> config.general.acceptReparty = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.backpackPreviewWithoutShift")) .binding(defaults.general.backpackPreviewWithoutShift, () -> config.general.backpackPreviewWithoutShift, newValue -> config.general.backpackPreviewWithoutShift = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.compactorDeletorPreview")) .binding(defaults.general.compactorDeletorPreview, () -> config.general.compactorDeletorPreview, newValue -> config.general.compactorDeletorPreview = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.hideEmptyTooltips")) .binding(defaults.general.hideEmptyTooltips, () -> config.general.hideEmptyTooltips, newValue -> config.general.hideEmptyTooltips = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.hideStatusEffectOverlay")) .binding(defaults.general.hideStatusEffectOverlay, () -> config.general.hideStatusEffectOverlay, newValue -> config.general.hideStatusEffectOverlay = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) //Tab Hud @@ -68,7 +67,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.general.tabHud.tabHudEnabled, () -> config.general.tabHud.tabHudEnabled, newValue -> config.general.tabHud.tabHudEnabled = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.tabHud.tabHudScale")) @@ -84,7 +83,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.general.tabHud.plainPlayerNames, () -> config.general.tabHud.plainPlayerNames, newValue -> config.general.tabHud.plainPlayerNames = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.tabHud.nameSorting")) @@ -105,7 +104,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.general.bars.enableBars, () -> config.general.bars.enableBars, newValue -> config.general.bars.enableBars = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.bars.barpositions.healthBarPosition")) @@ -146,21 +145,21 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.general.experiments.enableChronomatronSolver, () -> config.general.experiments.enableChronomatronSolver, newValue -> config.general.experiments.enableChronomatronSolver = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.experiments.enableSuperpairsSolver")) .binding(defaults.general.experiments.enableSuperpairsSolver, () -> config.general.experiments.enableSuperpairsSolver, newValue -> config.general.experiments.enableSuperpairsSolver = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.experiments.enableUltrasequencerSolver")) .binding(defaults.general.experiments.enableUltrasequencerSolver, () -> config.general.experiments.enableUltrasequencerSolver, newValue -> config.general.experiments.enableUltrasequencerSolver = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .build()) @@ -173,7 +172,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.general.fishing.enableFishingHelper, () -> config.general.fishing.enableFishingHelper, newValue -> config.general.fishing.enableFishingHelper = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .build()) @@ -186,14 +185,14 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.general.fairySouls.enableFairySoulsHelper, () -> config.general.fairySouls.enableFairySoulsHelper, newValue -> config.general.fairySouls.enableFairySoulsHelper = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.fairySouls.highlightFoundSouls")) .binding(defaults.general.fairySouls.highlightFoundSouls, () -> config.general.fairySouls.highlightFoundSouls, newValue -> config.general.fairySouls.highlightFoundSouls = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.fairySouls.highlightOnlyNearbySouls")) @@ -201,7 +200,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.general.fairySouls.highlightOnlyNearbySouls, () -> config.general.fairySouls.highlightOnlyNearbySouls, newValue -> config.general.fairySouls.highlightOnlyNearbySouls = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .build()) @@ -215,7 +214,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.general.shortcuts.enableShortcuts, () -> config.general.shortcuts.enableShortcuts, newValue -> config.general.shortcuts.enableShortcuts = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.shortcuts.enableCommandShortcuts")) @@ -223,7 +222,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.general.shortcuts.enableCommandShortcuts, () -> config.general.shortcuts.enableCommandShortcuts, newValue -> config.general.shortcuts.enableCommandShortcuts = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.shortcuts.enableCommandArgShortcuts")) @@ -231,7 +230,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.general.shortcuts.enableCommandArgShortcuts, () -> config.general.shortcuts.enableCommandArgShortcuts, newValue -> config.general.shortcuts.enableCommandArgShortcuts = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(ButtonOption.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.shortcuts.config")) @@ -249,21 +248,21 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.general.quiverWarning.enableQuiverWarning, () -> config.general.quiverWarning.enableQuiverWarning, newValue -> config.general.quiverWarning.enableQuiverWarning = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.quiverWarning.enableQuiverWarningInDungeons")) .binding(defaults.general.quiverWarning.enableQuiverWarningInDungeons, () -> config.general.quiverWarning.enableQuiverWarningInDungeons, newValue -> config.general.quiverWarning.enableQuiverWarningInDungeons = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.quiverWarning.enableQuiverWarningAfterDungeon")) .binding(defaults.general.quiverWarning.enableQuiverWarningAfterDungeon, () -> config.general.quiverWarning.enableQuiverWarningAfterDungeon, newValue -> config.general.quiverWarning.enableQuiverWarningAfterDungeon = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .build()) @@ -276,7 +275,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.general.itemList.enableItemList, () -> config.general.itemList.enableItemList, newValue -> config.general.itemList.enableItemList = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .build()) @@ -289,7 +288,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.general.itemTooltip.enableNPCPrice, () -> config.general.itemTooltip.enableNPCPrice, newValue -> config.general.itemTooltip.enableNPCPrice = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.itemTooltip.enableMotesPrice")) @@ -297,14 +296,14 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.general.itemTooltip.enableMotesPrice, () -> config.general.itemTooltip.enableMotesPrice, newValue -> config.general.itemTooltip.enableMotesPrice = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.itemTooltip.enableAvgBIN")) .binding(defaults.general.itemTooltip.enableAvgBIN, () -> config.general.itemTooltip.enableAvgBIN, newValue -> config.general.itemTooltip.enableAvgBIN = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.itemTooltip.avg")) @@ -319,21 +318,21 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.general.itemTooltip.enableLowestBIN, () -> config.general.itemTooltip.enableLowestBIN, newValue -> config.general.itemTooltip.enableLowestBIN = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.itemTooltip.enableBazaarPrice")) .binding(defaults.general.itemTooltip.enableBazaarPrice, () -> config.general.itemTooltip.enableBazaarPrice, newValue -> config.general.itemTooltip.enableBazaarPrice = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.itemTooltip.enableMuseumDate")) .binding(defaults.general.itemTooltip.enableMuseumDate, () -> config.general.itemTooltip.enableMuseumDate, newValue -> config.general.itemTooltip.enableMuseumDate = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .build()) @@ -347,7 +346,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.general.itemInfoDisplay.attributeShardInfo, () -> config.general.itemInfoDisplay.attributeShardInfo, newValue -> config.general.itemInfoDisplay.attributeShardInfo = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .build()) @@ -361,7 +360,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.general.specialEffects.rareDungeonDropEffects, () -> config.general.specialEffects.rareDungeonDropEffects, newValue -> config.general.specialEffects.rareDungeonDropEffects = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .build()) @@ -374,14 +373,14 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.general.hitbox.oldFarmlandHitbox, () -> config.general.hitbox.oldFarmlandHitbox, newValue -> config.general.hitbox.oldFarmlandHitbox = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.hitbox.oldLeverHitbox")) .binding(defaults.general.hitbox.oldLeverHitbox, () -> config.general.hitbox.oldLeverHitbox, newValue -> config.general.hitbox.oldLeverHitbox = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .build()) @@ -441,42 +440,42 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.general.teleportOverlay.enableTeleportOverlays, () -> config.general.teleportOverlay.enableTeleportOverlays, newValue -> config.general.teleportOverlay.enableTeleportOverlays = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.teleportOverlay.enableWeirdTransmission")) .binding(defaults.general.teleportOverlay.enableWeirdTransmission, () -> config.general.teleportOverlay.enableWeirdTransmission, newValue -> config.general.teleportOverlay.enableWeirdTransmission = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.teleportOverlay.enableInstantTransmission")) .binding(defaults.general.teleportOverlay.enableInstantTransmission, () -> config.general.teleportOverlay.enableInstantTransmission, newValue -> config.general.teleportOverlay.enableInstantTransmission = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.teleportOverlay.enableEtherTransmission")) .binding(defaults.general.teleportOverlay.enableEtherTransmission, () -> config.general.teleportOverlay.enableEtherTransmission, newValue -> config.general.teleportOverlay.enableEtherTransmission = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.teleportOverlay.enableSinrecallTransmission")) .binding(defaults.general.teleportOverlay.enableSinrecallTransmission, () -> config.general.teleportOverlay.enableSinrecallTransmission, newValue -> config.general.teleportOverlay.enableSinrecallTransmission = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.teleportOverlay.enableWitherImpact")) .binding(defaults.general.teleportOverlay.enableWitherImpact, () -> config.general.teleportOverlay.enableWitherImpact, newValue -> config.general.teleportOverlay.enableWitherImpact = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .build()) .build(); diff --git a/src/main/java/me/xmrvizzy/skyblocker/config/categories/LocationsCategory.java b/src/main/java/me/xmrvizzy/skyblocker/config/categories/LocationsCategory.java index 8c3189ee5d..099c917c94 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/config/categories/LocationsCategory.java +++ b/src/main/java/me/xmrvizzy/skyblocker/config/categories/LocationsCategory.java @@ -4,8 +4,8 @@ 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.IntegerSliderControllerBuilder; +import me.xmrvizzy.skyblocker.config.ConfigUtils; import me.xmrvizzy.skyblocker.config.SkyblockerConfig; import net.minecraft.text.Text; @@ -24,14 +24,14 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.locations.barn.solveHungryHiker, () -> config.locations.barn.solveHungryHiker, newValue -> config.locations.barn.solveHungryHiker = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.barn.solveTreasureHunter")) .binding(defaults.locations.barn.solveTreasureHunter, () -> config.locations.barn.solveTreasureHunter, newValue -> config.locations.barn.solveTreasureHunter = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .build()) @@ -44,7 +44,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.locations.rift.mirrorverseWaypoints, () -> config.locations.rift.mirrorverseWaypoints, newValue -> config.locations.rift.mirrorverseWaypoints = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.rift.mcGrubberStacks")) @@ -65,14 +65,14 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.locations.spidersDen.relics.enableRelicsHelper, () -> config.locations.spidersDen.relics.enableRelicsHelper, newValue -> config.locations.spidersDen.relics.enableRelicsHelper = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.spidersDen.relics.highlightFoundRelics")) .binding(defaults.locations.spidersDen.relics.highlightFoundRelics, () -> config.locations.spidersDen.relics.highlightFoundRelics, newValue -> config.locations.spidersDen.relics.highlightFoundRelics = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .build()) .build(); diff --git a/src/main/java/me/xmrvizzy/skyblocker/config/categories/MessageFilterCategory.java b/src/main/java/me/xmrvizzy/skyblocker/config/categories/MessageFilterCategory.java index 5adec834e4..268dc9b944 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/config/categories/MessageFilterCategory.java +++ b/src/main/java/me/xmrvizzy/skyblocker/config/categories/MessageFilterCategory.java @@ -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 me.xmrvizzy.skyblocker.utils.chat.ChatFilterResult; import me.xmrvizzy.skyblocker.config.SkyblockerConfig; import me.xmrvizzy.skyblocker.config.ConfigUtils; @@ -92,7 +91,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.messages.hideMana, () -> config.messages.hideMana, newValue -> config.messages.hideMana = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .build(); } diff --git a/src/main/java/me/xmrvizzy/skyblocker/config/categories/QuickNavigationCategory.java b/src/main/java/me/xmrvizzy/skyblocker/config/categories/QuickNavigationCategory.java index 4ca383756c..3189a1f391 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/config/categories/QuickNavigationCategory.java +++ b/src/main/java/me/xmrvizzy/skyblocker/config/categories/QuickNavigationCategory.java @@ -3,9 +3,9 @@ import dev.isxander.yacl3.api.ConfigCategory; import dev.isxander.yacl3.api.Option; import dev.isxander.yacl3.api.OptionGroup; -import dev.isxander.yacl3.api.controller.BooleanControllerBuilder; import dev.isxander.yacl3.api.controller.IntegerFieldControllerBuilder; import dev.isxander.yacl3.api.controller.StringControllerBuilder; +import me.xmrvizzy.skyblocker.config.ConfigUtils; import me.xmrvizzy.skyblocker.config.SkyblockerConfig; import net.minecraft.text.Text; @@ -15,6 +15,15 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig return ConfigCategory.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.category.quickNav")) + //Toggle + .option(Option.createBuilder() + .name(Text.translatable("text.autoconfig.skyblocker.option.quickNav.enableQuickNav")) + .binding(defaults.quickNav.enableQuickNav, + () -> config.quickNav.enableQuickNav, + newValue -> config.quickNav.enableQuickNav = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) + //Button 1 .group(OptionGroup.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button1")) @@ -24,7 +33,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.quickNav.button1.render, () -> config.quickNav.button1.render, newValue -> config.quickNav.button1.render = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button1.item.itemName")) @@ -72,7 +81,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.quickNav.button2.render, () -> config.quickNav.button2.render, newValue -> config.quickNav.button2.render = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button1.item.itemName")) @@ -120,7 +129,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.quickNav.button3.render, () -> config.quickNav.button3.render, newValue -> config.quickNav.button3.render = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button1.item.itemName")) @@ -168,7 +177,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.quickNav.button4.render, () -> config.quickNav.button4.render, newValue -> config.quickNav.button4.render = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button1.item.itemName")) @@ -216,7 +225,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.quickNav.button5.render, () -> config.quickNav.button5.render, newValue -> config.quickNav.button5.render = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button1.item.itemName")) @@ -264,7 +273,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.quickNav.button6.render, () -> config.quickNav.button6.render, newValue -> config.quickNav.button6.render = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button1.item.itemName")) @@ -312,7 +321,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.quickNav.button7.render, () -> config.quickNav.button7.render, newValue -> config.quickNav.button7.render = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button1.item.itemName")) @@ -360,7 +369,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.quickNav.button8.render, () -> config.quickNav.button8.render, newValue -> config.quickNav.button8.render = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button1.item.itemName")) @@ -408,7 +417,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.quickNav.button9.render, () -> config.quickNav.button9.render, newValue -> config.quickNav.button9.render = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button1.item.itemName")) @@ -456,7 +465,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.quickNav.button10.render, () -> config.quickNav.button10.render, newValue -> config.quickNav.button10.render = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button1.item.itemName")) @@ -504,7 +513,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.quickNav.button11.render, () -> config.quickNav.button11.render, newValue -> config.quickNav.button11.render = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button1.item.itemName")) @@ -552,7 +561,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.quickNav.button12.render, () -> config.quickNav.button12.render, newValue -> config.quickNav.button12.render = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button1.item.itemName")) diff --git a/src/main/java/me/xmrvizzy/skyblocker/config/categories/SlayersCategory.java b/src/main/java/me/xmrvizzy/skyblocker/config/categories/SlayersCategory.java index bfb3c6ad97..febca7203c 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/config/categories/SlayersCategory.java +++ b/src/main/java/me/xmrvizzy/skyblocker/config/categories/SlayersCategory.java @@ -4,10 +4,10 @@ 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.FloatFieldControllerBuilder; import dev.isxander.yacl3.api.controller.IntegerFieldControllerBuilder; import dev.isxander.yacl3.api.controller.IntegerSliderControllerBuilder; +import me.xmrvizzy.skyblocker.config.ConfigUtils; import me.xmrvizzy.skyblocker.config.SkyblockerConfig; import net.minecraft.text.Text; @@ -26,14 +26,14 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.slayer.vampireSlayer.enableEffigyWaypoints, () -> config.slayer.vampireSlayer.enableEffigyWaypoints, newValue -> config.slayer.vampireSlayer.enableEffigyWaypoints = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.slayer.vampireSlayer.compactEffigyWaypoints")) .binding(defaults.slayer.vampireSlayer.compactEffigyWaypoints, () -> config.slayer.vampireSlayer.compactEffigyWaypoints, newValue -> config.slayer.vampireSlayer.compactEffigyWaypoints = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.slayer.vampireSlayer.effigyUpdateFrequency")) @@ -48,7 +48,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.slayer.vampireSlayer.enableHolyIceIndicator, () -> config.slayer.vampireSlayer.enableHolyIceIndicator, newValue -> config.slayer.vampireSlayer.enableHolyIceIndicator = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.slayer.vampireSlayer.holyIceIndicatorTickDelay")) @@ -70,7 +70,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.slayer.vampireSlayer.enableHealingMelonIndicator, () -> config.slayer.vampireSlayer.enableHealingMelonIndicator, newValue -> config.slayer.vampireSlayer.enableHealingMelonIndicator = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.slayer.vampireSlayer.healingMelonHealthThreshold")) @@ -84,7 +84,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.slayer.vampireSlayer.enableSteakStakeIndicator, () -> config.slayer.vampireSlayer.enableSteakStakeIndicator, newValue -> config.slayer.vampireSlayer.enableSteakStakeIndicator = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.slayer.vampireSlayer.steakStakeUpdateFrequency")) @@ -99,7 +99,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.slayer.vampireSlayer.enableManiaIndicator, () -> config.slayer.vampireSlayer.enableManiaIndicator, newValue -> config.slayer.vampireSlayer.enableManiaIndicator = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.slayer.vampireSlayer.maniaUpdateFrequency")) diff --git a/src/main/java/me/xmrvizzy/skyblocker/config/controllers/EnumDropdownController.java b/src/main/java/me/xmrvizzy/skyblocker/config/controllers/EnumDropdownController.java new file mode 100644 index 0000000000..cf40c7d508 --- /dev/null +++ b/src/main/java/me/xmrvizzy/skyblocker/config/controllers/EnumDropdownController.java @@ -0,0 +1,86 @@ +package me.xmrvizzy.skyblocker.config.controllers; + +import dev.isxander.yacl3.api.Option; +import dev.isxander.yacl3.api.utils.Dimension; +import dev.isxander.yacl3.gui.AbstractWidget; +import dev.isxander.yacl3.gui.YACLScreen; +import dev.isxander.yacl3.gui.controllers.dropdown.AbstractDropdownController; +import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; +import java.util.stream.Stream; + +public class EnumDropdownController> extends AbstractDropdownController { + protected EnumDropdownController(Option option) { + super(option); + } + + @Override + public String getString() { + return option().pendingValue().toString(); + } + + @Override + public void setFromString(String value) { + option().requestSet(getEnumFromString(value)); + } + + /** + * Searches through enum constants for one whose {@link Enum#toString()} result equals {@code value} + * + * @return The enum constant associated with the {@code value} or the pending value if none are found + * @implNote The return value of {@link Enum#toString()} on each enum constant should be unique in order to ensure accuracy + */ + private E getEnumFromString(String value) { + value = value.toLowerCase(); + for (E constant : option().pendingValue().getDeclaringClass().getEnumConstants()) { + if (constant.toString().toLowerCase().equals(value)) return constant; + } + + return option().pendingValue(); + } + + @Override + public boolean isValueValid(String value) { + value = value.toLowerCase(); + for (E constant : option().pendingValue().getDeclaringClass().getEnumConstants()) { + if (constant.toString().equals(value)) return true; + } + + return false; + } + + @Override + protected String getValidValue(String value, int offset) { + return getValidEnumConstants(value) + .skip(offset) + .findFirst() + .orElseGet(this::getString); + } + + /** + * Filters and sorts through enum constants for those whose {@link Enum#toString()} result equals {@code value} + * + * @return a sorted stream containing enum constants associated with the {@code value} + * @implNote The return value of {@link Enum#toString()} on each enum constant should be unique in order to ensure accuracy + */ + @NotNull + protected Stream getValidEnumConstants(String value) { + String valueLowerCase = value.toLowerCase(); + return Arrays.stream(option().pendingValue().getDeclaringClass().getEnumConstants()) + .map(Enum::toString) + .filter(constant -> constant.toLowerCase().contains(valueLowerCase)) + .sorted((s1, s2) -> { + String s1LowerCase = s1.toLowerCase(); + String s2LowerCase = s2.toLowerCase(); + if (s1LowerCase.startsWith(valueLowerCase) && !s2LowerCase.startsWith(valueLowerCase)) return -1; + if (!s1LowerCase.startsWith(valueLowerCase) && s2LowerCase.startsWith(valueLowerCase)) return 1; + return s1.compareTo(s2); + }); + } + + @Override + public AbstractWidget provideWidget(YACLScreen screen, Dimension widgetDimension) { + return new EnumDropdownControllerElement<>(this, screen, widgetDimension); + } +} diff --git a/src/main/java/me/xmrvizzy/skyblocker/config/controllers/EnumDropdownControllerBuilder.java b/src/main/java/me/xmrvizzy/skyblocker/config/controllers/EnumDropdownControllerBuilder.java new file mode 100644 index 0000000000..baadb8b352 --- /dev/null +++ b/src/main/java/me/xmrvizzy/skyblocker/config/controllers/EnumDropdownControllerBuilder.java @@ -0,0 +1,10 @@ +package me.xmrvizzy.skyblocker.config.controllers; + +import dev.isxander.yacl3.api.Option; +import dev.isxander.yacl3.api.controller.ControllerBuilder; + +public interface EnumDropdownControllerBuilder> extends ControllerBuilder { + static > EnumDropdownControllerBuilder create(Option option) { + return new EnumDropdownControllerBuilderImpl<>(option); + } +} diff --git a/src/main/java/me/xmrvizzy/skyblocker/config/controllers/EnumDropdownControllerBuilderImpl.java b/src/main/java/me/xmrvizzy/skyblocker/config/controllers/EnumDropdownControllerBuilderImpl.java new file mode 100644 index 0000000000..ea30d1da54 --- /dev/null +++ b/src/main/java/me/xmrvizzy/skyblocker/config/controllers/EnumDropdownControllerBuilderImpl.java @@ -0,0 +1,17 @@ +package me.xmrvizzy.skyblocker.config.controllers; + +import dev.isxander.yacl3.api.Controller; +import dev.isxander.yacl3.api.Option; +import dev.isxander.yacl3.impl.controller.AbstractControllerBuilderImpl; + +public class EnumDropdownControllerBuilderImpl> extends AbstractControllerBuilderImpl implements EnumDropdownControllerBuilder { + public EnumDropdownControllerBuilderImpl(Option option) { + super(option); + } + + @SuppressWarnings("UnstableApiUsage") + @Override + public Controller build() { + return new EnumDropdownController<>(option); + } +} diff --git a/src/main/java/me/xmrvizzy/skyblocker/config/controllers/EnumDropdownControllerElement.java b/src/main/java/me/xmrvizzy/skyblocker/config/controllers/EnumDropdownControllerElement.java new file mode 100644 index 0000000000..6c5a00977e --- /dev/null +++ b/src/main/java/me/xmrvizzy/skyblocker/config/controllers/EnumDropdownControllerElement.java @@ -0,0 +1,26 @@ +package me.xmrvizzy.skyblocker.config.controllers; + +import dev.isxander.yacl3.api.utils.Dimension; +import dev.isxander.yacl3.gui.YACLScreen; +import dev.isxander.yacl3.gui.controllers.dropdown.AbstractDropdownControllerElement; + +import java.util.List; + +public class EnumDropdownControllerElement> extends AbstractDropdownControllerElement { + private final EnumDropdownController controller; + + public EnumDropdownControllerElement(EnumDropdownController control, YACLScreen screen, Dimension dim) { + super(control, screen, dim); + this.controller = control; + } + + @Override + public List computeMatchingValues() { + return controller.getValidEnumConstants(inputField).toList(); + } + + @Override + public String getString(String object) { + return object; + } +} diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index d4b6551a74..11a14d95d3 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -50,8 +50,6 @@ "text.autoconfig.skyblocker.option.general.quiverWarning.enableQuiverWarning": "Enable Quiver Warning", "text.autoconfig.skyblocker.option.general.quiverWarning.enableQuiverWarningInDungeons": "Enable Quiver Warning In Dungeons", "text.autoconfig.skyblocker.option.general.quiverWarning.enableQuiverWarningAfterDungeon": "Enable Quiver Warning After a Dungeon", - "text.autoconfig.skyblocker.option.general.quicknav": "Quicknav", - "text.autoconfig.skyblocker.option.general.quicknav.enableQuicknav": "Enable Quicknav", "text.autoconfig.skyblocker.option.general.backpackPreviewWithoutShift": "View backpack preview without holding Shift", "text.autoconfig.skyblocker.option.general.compactorDeletorPreview": "Enable Compactor/Deletor Preview", "text.autoconfig.skyblocker.option.general.tabHud": "Fancy tab HUD", @@ -284,8 +282,8 @@ "text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.enabled": "Enabled", "text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.style": "Style for HUD", "text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.style.@Tooltip[0]": "Simple: Shows name and percentage.", - "text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.style.@Tooltip[1]": "Fancy: Shows name, percentage, progress bar and an icon.", - "text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.style.@Tooltip[2]": "Classic: Shows name and percentage in a very simple box.", + "text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.style.@Tooltip[1]": "\nFancy: Shows name, percentage, progress bar and an icon.", + "text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.style.@Tooltip[2]": "\nClassic: Shows name and percentage in a very simple box.", "text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.screen": "Dwarven HUD Config...", "text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.enableBackground": "Enable Background", "text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.x": "X",