diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-05-12 00:53:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-12 00:53:09 +0200 |
commit | 3bb4b9b9826fadd8df3507ea86b6196b6487b981 (patch) | |
tree | 9876124908f9d0a9656b1ab9690a3c2211bc9435 /src/main/java/at | |
parent | b391c5d5c660436112da31d69e025bd6f4622a02 (diff) | |
download | skyhanni-3bb4b9b9826fadd8df3507ea86b6196b6487b981.tar.gz skyhanni-3bb4b9b9826fadd8df3507ea86b6196b6487b981.tar.bz2 skyhanni-3bb4b9b9826fadd8df3507ea86b6196b6487b981.zip |
Feature: Blaze Slayer Fire Pillar Display (#1766)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at')
5 files changed, 77 insertions, 6 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index e2dc9e1ea..ce273afd4 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -427,6 +427,7 @@ import at.hannibal2.skyhanni.features.slayer.VampireSlayerFeatures import at.hannibal2.skyhanni.features.slayer.blaze.BlazeSlayerClearView import at.hannibal2.skyhanni.features.slayer.blaze.BlazeSlayerDaggerHelper import at.hannibal2.skyhanni.features.slayer.blaze.BlazeSlayerFirePitsWarning +import at.hannibal2.skyhanni.features.slayer.blaze.FirePillarDisplay import at.hannibal2.skyhanni.features.slayer.blaze.HellionShieldHelper import at.hannibal2.skyhanni.features.slayer.enderman.EndermanSlayerFeatures import at.hannibal2.skyhanni.features.slayer.enderman.EndermanSlayerHideParticles @@ -689,6 +690,7 @@ class SkyHanniMod { loadModule(HellionShieldHelper()) loadModule(BlazeSlayerFirePitsWarning()) loadModule(BlazeSlayerClearView()) + loadModule(FirePillarDisplay()) loadModule(EndermanSlayerHideParticles()) loadModule(PlayerChatFilter()) loadModule(HideArmor()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/slayer/SlayerConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/slayer/SlayerConfig.java index 8edf7aa4a..d21fd1a9d 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/slayer/SlayerConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/slayer/SlayerConfig.java @@ -19,6 +19,7 @@ public class SlayerConfig { @Expose @Category(name = "Blaze", desc = "Blaze Slayer Features") + // TODO rename to "blaze" public BlazeConfig blazes = new BlazeConfig(); @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/slayer/blaze/BlazeConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/slayer/blaze/BlazeConfig.java index 99c4eb923..86d3e68f7 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/slayer/blaze/BlazeConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/slayer/blaze/BlazeConfig.java @@ -1,9 +1,11 @@ package at.hannibal2.skyhanni.config.features.slayer.blaze; import at.hannibal2.skyhanni.config.FeatureToggle; +import at.hannibal2.skyhanni.config.core.config.Position; import com.google.gson.annotations.Expose; import io.github.notenoughupdates.moulconfig.annotations.Accordion; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; +import io.github.notenoughupdates.moulconfig.annotations.ConfigLink; import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; public class BlazeConfig { @@ -12,7 +14,6 @@ public class BlazeConfig { @Accordion public BlazeHellionConfig hellion = new BlazeHellionConfig(); - @Expose @ConfigOption(name = "Fire Pits", desc = "Warning when the fire pit phase starts for the Blaze Slayer tier 3 and 4.") @ConfigEditorBoolean @@ -29,4 +30,18 @@ public class BlazeConfig { @ConfigEditorBoolean @FeatureToggle public boolean clearView = false; + + @Expose + @ConfigOption( + name = "Pillar Display", + desc = "Show a big display with a timer when the Fire Pillar is about to explode. " + + "Also shows for other player's bosses as well." + ) + @ConfigEditorBoolean + @FeatureToggle + public boolean firePillarDisplay = false; + + @Expose + @ConfigLink(owner = BlazeConfig.class, field = "firePillarDisplay") + public Position firePillarDisplayPosition = new Position(200, 120, false, true); } diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/FirePillarDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/FirePillarDisplay.kt new file mode 100644 index 000000000..4ffba9378 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/FirePillarDisplay.kt @@ -0,0 +1,51 @@ +package at.hannibal2.skyhanni.features.slayer.blaze + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.utils.EntityUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland +import at.hannibal2.skyhanni.utils.RenderUtils.renderString +import at.hannibal2.skyhanni.utils.StringUtils.matchFirst +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import net.minecraft.entity.item.EntityArmorStand +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class FirePillarDisplay { + private val config get() = SkyHanniMod.feature.slayer.blazes + + /** + * REGEX-TEST: §6§l2s §c§l8 hits + */ + private val entityNamePattern by RepoPattern.pattern( + "slayer.blaze.firepillar.entityname", + "§6§l(?<seconds>.*)s §c§l8 hits" + ) + + private var display = "" + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (!isEnabled()) return + + val seconds = EntityUtils.getEntities<EntityArmorStand>() + .map { it.name } + .matchFirst<String?>(entityNamePattern) { + group("seconds") + } + + display = seconds?.let { + "§cFire Pillar: §b${seconds}s" + } ?: "" + } + + @SubscribeEvent + fun onRenderOverlay(event: GuiRenderEvent) { + if (!isEnabled()) return + + config.firePillarDisplayPosition.renderString(display, posLabel = "Fire Pillar") + } + + fun isEnabled() = IslandType.CRIMSON_ISLE.isInIsland() && config.firePillarDisplay +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt index c048004f2..4e5bce010 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt @@ -106,6 +106,9 @@ object StringUtils { inline fun <T> Pattern.findMatcher(text: String, consumer: Matcher.() -> T) = matcher(text).let { if (it.find()) consumer(it) else null } + inline fun <T> Sequence<String>.matchFirst(pattern: Pattern, consumer: Matcher.() -> T): T? = + toList().matchFirst(pattern, consumer) + inline fun <T> List<String>.matchFirst(pattern: Pattern, consumer: Matcher.() -> T): T? { for (line in this) { pattern.matcher(line).let { if (it.matches()) return consumer(it) } @@ -309,8 +312,9 @@ object StringUtils { fun String.convertToFormatted(): String = this.replace("&&", "§") - fun Pattern.matches(string: String?) = string?.let { matcher(it).matches() } ?: false - fun Pattern.anyMatches(list: List<String>?) = list?.any { this.matches(it) } ?: false + fun Pattern.matches(string: String?): Boolean = string?.let { matcher(it).matches() } ?: false + fun Pattern.anyMatches(list: List<String>?): Boolean = list?.any { this.matches(it) } ?: false + fun Pattern.anyMatches(list: Sequence<String>?): Boolean = anyMatches(list?.toList()) fun Pattern.find(string: String?) = string?.let { matcher(it).find() } ?: false @@ -331,7 +335,6 @@ object StringUtils { return replaceIfNeeded(original, ChatComponentText(newText)) } - private val colorMap = EnumChatFormatting.entries.associateBy { it.toString()[1] } fun enumChatFormattingByCode(char: Char): EnumChatFormatting? { return colorMap[char] @@ -395,7 +398,6 @@ object StringUtils { } } - fun <T : IChatComponent> replaceIfNeeded( original: T, newText: T, @@ -435,7 +437,7 @@ object StringUtils { private fun IChatComponent.findAllEvents( clickEvents: MutableList<ClickEvent>, - hoverEvents: MutableList<HoverEvent> + hoverEvents: MutableList<HoverEvent>, ) { siblings.forEach { it.findAllEvents(clickEvents, hoverEvents) } |