aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/dev/RepositoryConfig.java2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/event/GreatSpookConfig.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/event/PrimalFearSolverConfig.java22
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt89
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt7
5 files changed, 112 insertions, 13 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/dev/RepositoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/dev/RepositoryConfig.java
index 697cb3c91..33ff0f571 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/dev/RepositoryConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/dev/RepositoryConfig.java
@@ -37,7 +37,7 @@ public class RepositoryConfig {
public String user = "hannibal002";
@Expose
- @ConfigOption(name = "Repository Name", desc = "The Repository Name, default: SkyHanni-Repo")
+ @ConfigOption(name = "Repository Name", desc = "The Repository Name, default: SkyHanni-REPO")
@ConfigEditorText
public String name = "SkyHanni-REPO";
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/event/GreatSpookConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/event/GreatSpookConfig.java
index 9c6262e41..a2e57c440 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/event/GreatSpookConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/event/GreatSpookConfig.java
@@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.config.features.event;
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;
@@ -47,4 +48,8 @@ public class GreatSpookConfig {
@ConfigLink(owner = GreatSpookConfig.class, field = "greatSpookTimeLeft")
public Position positionTimeLeft = new Position(40, 40, false, true);
+ @ConfigOption(name = "Primal Fear Solvers", desc = "Solvers for the Primal Fears.")
+ @Accordion
+ @Expose
+ public PrimalFearSolverConfig primalFearSolver = new PrimalFearSolverConfig();
}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/event/PrimalFearSolverConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/event/PrimalFearSolverConfig.java
new file mode 100644
index 000000000..fe4e84c48
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/event/PrimalFearSolverConfig.java
@@ -0,0 +1,22 @@
+package at.hannibal2.skyhanni.config.features.event;
+
+import at.hannibal2.skyhanni.config.FeatureToggle;
+import com.google.gson.annotations.Expose;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorKeybind;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;
+import org.lwjgl.input.Keyboard;
+
+public class PrimalFearSolverConfig {
+ @Expose
+ @ConfigOption(name = "Math", desc = "Sends a clickable message with the solution in chat.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean math = false;
+
+ @Expose
+ @ConfigOption(name = "Public Speaking", desc = "Sends a clickable message with a random string in chat.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean publicSpeaking = false;
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt b/src/main/java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt
index 8d7a68ba5..0ada2ca8e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt
@@ -3,12 +3,20 @@ package at.hannibal2.skyhanni.features.event.spook
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.model.SkyblockStat
import at.hannibal2.skyhanni.events.GuiRenderEvent
+import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.SecondPassedEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
+import at.hannibal2.skyhanni.utils.ChatUtils
+import at.hannibal2.skyhanni.utils.DelayedRun
+import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.NEUCalculator
+import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
import at.hannibal2.skyhanni.utils.SoundUtils
+import at.hannibal2.skyhanni.utils.StringUtils
import at.hannibal2.skyhanni.utils.TabListData
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@SkyHanniModule
@@ -22,11 +30,11 @@ object TheGreatSpook {
@SubscribeEvent
fun onSecondPassed(event: SecondPassedEvent) {
- if (isAllDisabled()) return
+ if (!LorenzUtils.inSkyBlock) return
- if (isTimerEnabled() || isNotificationEnabled()) displayTimer = checkTabList(" §r§cPrimal Fears§r§7: ")
- if (isTimeLeftEnabled()) displayTimeLeft = checkTabList(" §r§dEnds In§r§7: ")
- if (isNotificationEnabled()) {
+ if (config.primalFearTimer || config.primalFearNotification) displayTimer = checkTabList(" §r§cPrimal Fears§r§7: ")
+ if (config.greatSpookTimeLeft) displayTimeLeft = checkTabList(" §r§dEnds In§r§7: ")
+ if (config.primalFearNotification) {
if (displayTimer.endsWith("READY!!")) {
if (notificationSeconds > 0) {
SoundUtils.playBeepSound()
@@ -44,20 +52,77 @@ object TheGreatSpook {
@SubscribeEvent
fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) {
- if (isTimerEnabled()) config.positionTimer.renderString(displayTimer, posLabel = "Primal Fear Timer")
- if (isFearStatEnabled()) {
+ if (!LorenzUtils.inSkyBlock) return
+
+ if (config.primalFearTimer) config.positionTimer.renderString(displayTimer, posLabel = "Primal Fear Timer")
+ if (config.fearStatDisplay) {
SkyblockStat.FEAR.displayValue?.let {
config.positionFear.renderString(it, posLabel = "Fear Stat Display")
}
}
- if (isTimeLeftEnabled()) config.positionTimeLeft.renderString(displayTimeLeft, posLabel = "Time Left Display")
+ if (config.greatSpookTimeLeft) config.positionTimeLeft.renderString(displayTimeLeft, posLabel = "Time Left Display")
+ }
+
+ /**
+ * REGEX-TEST: §d§lQUICK MATHS! §r§7Solve: §r§e(10*2)+12*5
+ */
+ private val mathFearMessagePattern by RepoPattern.pattern(
+ "chat.math",
+ "§d§lQUICK MATHS! §r§7Solve: §r§e(?<math>.*)",
+ )
+
+ /**
+ * REGEX-TEST: §4[FEAR] Public Speaking Demon§r§f: Speak PlasticEating!
+ */
+ private val speakingFearMessagePattern by RepoPattern.pattern(
+ "chat.speaking",
+ "§4\\[FEAR] Public Speaking Demon§r§f: (Speak|Say something interesting) (?<name>.*)!",
+ )
+
+ private fun mathSolver(query: String?) {
+ val answer = query?.let { NEUCalculator.calculateOrNull(it)?.toInt() } ?: run {
+ ChatUtils.userError("Failed to solve $query!")
+ return
+ }
+ ChatUtils.clickToActionOrDisable(
+ "The answer is: $answer",
+ config.primalFearSolver::math,
+ actionName = "Send the answer",
+ action = {
+ HypixelCommands.allChat(answer.toString())
+ },
+ )
+ }
+
+ private fun publicSpeakingSolver() {
+ ChatUtils.clickToActionOrDisable(
+ "Click to complete the Primal Fear",
+ config.primalFearSolver::publicSpeaking,
+ actionName = "send a random string.",
+ action = {
+ HypixelCommands.allChat("I looove SkyHanni! ${StringUtils.generateRandomString(4)}")
+ },
+ )
}
- private fun isTimerEnabled(): Boolean = LorenzUtils.inSkyBlock && config.primalFearTimer
+ @SubscribeEvent
+ fun onChat(event: LorenzChatEvent) {
+ if (!LorenzUtils.inSkyBlock) return
- private fun isNotificationEnabled(): Boolean = LorenzUtils.inSkyBlock && config.primalFearNotification
- private fun isFearStatEnabled(): Boolean = LorenzUtils.inSkyBlock && config.fearStatDisplay
- private fun isTimeLeftEnabled(): Boolean = LorenzUtils.inSkyBlock && config.greatSpookTimeLeft
+ if (config.primalFearSolver.math) {
+ mathFearMessagePattern.matchMatcher(event.message) {
+ DelayedRun.runNextTick {
+ mathSolver(group("math"))
+ }
+ }
+ }
- private fun isAllDisabled(): Boolean = !isTimeLeftEnabled() && !isTimerEnabled() && !isFearStatEnabled() && !isNotificationEnabled()
+ if (config.primalFearSolver.publicSpeaking) {
+ speakingFearMessagePattern.matchMatcher(event.message) {
+ DelayedRun.runNextTick {
+ publicSpeakingSolver()
+ }
+ }
+ }
+ }
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
index a2e32adaa..b6d38fd7f 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
@@ -334,6 +334,13 @@ object StringUtils {
fun generateRandomId() = UUID.randomUUID().toString()
+ private const val CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
+ fun generateRandomString(length: Int): String {
+ var res: String = ""
+ repeat(length) { res += CHARS.random() }
+ return res
+ }
+
fun String.insert(pos: Int, chars: CharSequence): String = this.substring(0, pos) + chars + this.substring(pos)
fun String.insert(pos: Int, char: Char): String = this.substring(0, pos) + char + this.substring(pos)