aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
authorJ10a1n15 <45315647+j10a1n15@users.noreply.github.com>2024-09-12 10:25:09 +0200
committerGitHub <noreply@github.com>2024-09-12 10:25:09 +0200
commitb99310be47d5caeb6de8832ce9e2b10c423f77ce (patch)
treee8bbdab5f75c24e6e83f31c1c45a3362e3f7599e /src/main/java/at/hannibal2/skyhanni
parent4e23db746f35965b84f8dd5be19b9883c67d8add (diff)
downloadskyhanni-b99310be47d5caeb6de8832ce9e2b10c423f77ce.tar.gz
skyhanni-b99310be47d5caeb6de8832ce9e2b10c423f77ce.tar.bz2
skyhanni-b99310be47d5caeb6de8832ce9e2b10c423f77ce.zip
Feature: GetFromSack Piggy Bank (#2150)
Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-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
+}