diff options
author | Kevin <92656833+kevinthegreat1@users.noreply.github.com> | 2024-01-11 04:25:32 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-10 15:25:32 -0500 |
commit | ffab9576c0f7534195f276b677bd5bdeac5e8a3a (patch) | |
tree | d562a9a817ae874e7b607523cd2ba6345af63aa3 /src/main | |
parent | 52e4ce7fe81bb2af8af102b0270c0eac12a34f48 (diff) | |
download | Skyblocker-ffab9576c0f7534195f276b677bd5bdeac5e8a3a.tar.gz Skyblocker-ffab9576c0f7534195f276b677bd5bdeac5e8a3a.tar.bz2 Skyblocker-ffab9576c0f7534195f276b677bd5bdeac5e8a3a.zip |
Add livid color title (#482)
Diffstat (limited to 'src/main')
4 files changed, 34 insertions, 8 deletions
diff --git a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java index 83c69d2c..609e7c2f 100644 --- a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java @@ -787,6 +787,9 @@ public class SkyblockerConfig { public boolean enableLividColorText = true; @SerialEntry + public boolean enableLividColorTitle = true; + + @SerialEntry public String lividColorText = "The livid color is [color]"; } diff --git a/src/main/java/de/hysky/skyblocker/config/categories/DungeonsCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/DungeonsCategory.java index 8872953e..ad64e2e4 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/DungeonsCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/DungeonsCategory.java @@ -431,6 +431,14 @@ public class DungeonsCategory { newValue -> config.locations.dungeons.lividColor.enableLividColorText = newValue) .controller(ConfigUtils::createBooleanController) .build()) + .option(Option.<Boolean>createBuilder() + .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColorTitle")) + .description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColorTitle.@Tooltip"))) + .binding(defaults.locations.dungeons.lividColor.enableLividColorTitle, + () -> config.locations.dungeons.lividColor.enableLividColorTitle, + newValue -> config.locations.dungeons.lividColor.enableLividColorTitle = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) .option(Option.<String>createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.lividColor.lividColorText")) .description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.lividColor.lividColorText.@Tooltip"))) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java index 472c9d95..b1ed5a22 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java @@ -10,6 +10,8 @@ import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.client.MinecraftClient; import net.minecraft.registry.Registries; +import net.minecraft.text.MutableText; +import net.minecraft.text.Text; import net.minecraft.util.Formatting; import net.minecraft.util.math.BlockPos; @@ -38,13 +40,14 @@ public class LividColor { "Doctor Livid", Formatting.GRAY, "Vendetta Livid", Formatting.WHITE ); + public static final SkyblockerConfig.LividColor CONFIG = SkyblockerConfigManager.get().locations.dungeons.lividColor; private static int tenTicks = 0; private static Formatting color; public static void init() { ClientReceiveMessageEvents.GAME.register((message, overlay) -> { SkyblockerConfig.LividColor config = SkyblockerConfigManager.get().locations.dungeons.lividColor; - if ((config.enableLividColorText || config.enableLividColorGlow) && message.getString().equals("[BOSS] Livid: I respect you for making it to here, but I'll be your undoing.")) { + if ((config.enableLividColorText || config.enableLividColorTitle || config.enableLividColorGlow) && message.getString().equals("[BOSS] Livid: I respect you for making it to here, but I'll be your undoing.")) { tenTicks = 8; } }); @@ -54,14 +57,14 @@ public class LividColor { MinecraftClient client = MinecraftClient.getInstance(); if (tenTicks != 0) { SkyblockerConfig.LividColor config = SkyblockerConfigManager.get().locations.dungeons.lividColor; - if ((config.enableLividColorText || config.enableLividColorGlow) && Utils.isInDungeons() && client.world != null) { + if ((config.enableLividColorText || config.enableLividColorTitle || config.enableLividColorGlow) && Utils.isInDungeons() && client.world != null) { if (tenTicks == 1) { - onLividColorFound(Blocks.RED_WOOL); + onLividColorFound(client, Blocks.RED_WOOL); return; } Block color = client.world.getBlockState(new BlockPos(5, 110, 42)).getBlock(); if (WOOL_TO_FORMATTING.containsKey(color) && !color.equals(Blocks.RED_WOOL)) { - onLividColorFound(color); + onLividColorFound(client, color); return; } tenTicks--; @@ -71,11 +74,21 @@ public class LividColor { } } - private static void onLividColorFound(Block color) { + private static void onLividColorFound(MinecraftClient client, Block color) { LividColor.color = WOOL_TO_FORMATTING.get(color); - if (SkyblockerConfigManager.get().locations.dungeons.lividColor.enableLividColorText) { - String colorString = Registries.BLOCK.getId(color).getPath(); - MessageScheduler.INSTANCE.sendMessageAfterCooldown(Constants.PREFIX.get().getString() + SkyblockerConfigManager.get().locations.dungeons.lividColor.lividColorText.replaceAll("\\[color]", colorString.substring(0, colorString.length() - 5))); + String colorString = Registries.BLOCK.getId(color).getPath(); + colorString = colorString.substring(0, colorString.length() - 5).toUpperCase(); + String[] messageParts = CONFIG.lividColorText.split("\\[color]"); + MutableText message = Constants.PREFIX.get().append(messageParts[0]); + for (int i = 1; i < messageParts.length; i++) { + message = message.append(Text.literal(colorString).formatted(LividColor.color)).append(Text.of(messageParts[i])); + } + if (CONFIG.enableLividColorText) { + MessageScheduler.INSTANCE.sendMessageAfterCooldown(message.getString()); + } + if (CONFIG.enableLividColorTitle) { + client.inGameHud.setDefaultTitleFade(); + client.inGameHud.setTitle(message); } tenTicks = 0; } diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 421d74bd..d6f09de9 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -235,6 +235,8 @@ "text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColorGlow.@Tooltip": "Applies the glowing effect to the correct Livid in F5/M5.", "text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColorText": "Enable Livid Color Text", "text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColorText.@Tooltip": "Send the livid color in the chat during the Livid boss fight.", + "text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColorTitle": "Enable Livid Color Title", + "text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColorTitle.@Tooltip": "Display the livid color in the title during the Livid boss fight.", "text.autoconfig.skyblocker.option.locations.dungeons.lividColor.lividColorText": "Livid Color Text", "text.autoconfig.skyblocker.option.locations.dungeons.lividColor.lividColorText.@Tooltip": "Text which will be sent in the chat during the Livid boss fight. The string \"[color]\" will be replaced with the livid color.", "text.autoconfig.skyblocker.option.locations.dungeons.terminals": "Terminal Solvers", |