aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt48
2 files changed, 54 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java
index 1464d35ad..f3b9ab16e 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java
@@ -317,6 +317,12 @@ public class MiscConfig {
public boolean maintainGameVolume = false;
@Expose
+ @ConfigOption(name = "GFS Piggy Bank", desc = "When your Piggy Bank breaks, send a chat warning to get enchanted pork from sacks.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean gfsPiggyBank = true;
+
+ @Expose
@ConfigOption(name = "SkyHanni User Luck", desc = "Shows SkyHanni User Luck in the SkyBlock Stats.")
@ConfigEditorBoolean
@FeatureToggle
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt
new file mode 100644
index 000000000..159383d8a
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt
@@ -0,0 +1,48 @@
+package at.hannibal2.skyhanni.features.misc
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.api.GetFromSackAPI
+import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
+import at.hannibal2.skyhanni.utils.PrimitiveItemStack.Companion.makePrimitiveStack
+import at.hannibal2.skyhanni.utils.RegexUtils.matchMatchers
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+@SkyHanniModule
+object GFSPiggyBank {
+
+ private val ENCHANTED_PORK by lazy { "ENCHANTED_PORK".asInternalName().makePrimitiveStack(8) }
+
+ private val group = RepoPattern.group("misc.piggybank")
+
+ /**
+ * REGEX-TEST: §cYou died and your piggy bank cracked!
+ */
+ private val crackedPattern by group.pattern(
+ "cracked",
+ "§cYou died and your piggy bank cracked!",
+ )
+
+ /**
+ * REGEX-TEST: §cYou died, lost 50,000 coins and your piggy bank broke!
+ */
+ private val brokePattern by group.pattern(
+ "broke",
+ "§cYou died, lost [\\d.,]* coins and your piggy bank broke!",
+ )
+
+ private val patternList = listOf(crackedPattern, brokePattern)
+
+ @SubscribeEvent
+ fun onChat(event: LorenzChatEvent) {
+ if (!isEnabled()) return
+ patternList.matchMatchers(event.message) {
+ GetFromSackAPI.getFromChatMessageSackItems(ENCHANTED_PORK)
+ }
+ }
+
+ private fun isEnabled() = LorenzUtils.inSkyBlock && SkyHanniMod.feature.misc.gfsPiggyBank
+}