From a822c839c8766c9121bb7dabc6bd9ddb8ab7ecb2 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Tue, 25 Jun 2024 20:45:25 +0200 Subject: [PATCH 1/7] init Signed-off-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> --- .../core/config/gui/GuiPositionEditor.kt | 3 -- .../config/features/misc/MiscConfig.java | 6 +++ .../skyhanni/features/misc/GFSPiggyBank.kt | 42 +++++++++++++++++++ 3 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt diff --git a/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt b/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt index e0e8c28a5d60..c6eda42faee3 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt @@ -136,16 +136,13 @@ class GuiPositionEditor( drawRect(x - border, y - border, x + elementWidth + border * 2, y + elementHeight + border * 2, -0x7fbfbfc0) if (GuiRenderUtils.isPointInRect( - mouseX, mouseY, x - border, y - border, elementWidth + border * 2, elementHeight + border * 2 - ) - ) { hoveredPos = index } 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 cc606e7aaa1c..3de23af9b9fb 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 @@ -282,4 +282,10 @@ public class MiscConfig { @ConfigEditorBoolean @FeatureToggle 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; } 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 000000000000..50f76bbec7d0 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt @@ -0,0 +1,42 @@ +package at.hannibal2.skyhanni.features.misc + +import at.hannibal2.skyhanni.api.GetFromSackAPI +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +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!", + ) + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + val message = event.message + listOf(crackedPattern, brokePattern).matchMatchers(message) { + GetFromSackAPI.getFromChatMessageSackItems(ENCHANTED_PORK) + } + } +} From 3f9f0424ec08eeff0e5c5db1b54936f658cb0d71 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Thu, 27 Jun 2024 15:14:57 +0200 Subject: [PATCH 2/7] i love not using the config Signed-off-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> --- .../java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt index 50f76bbec7d0..75fdd48f38dc 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt @@ -1,8 +1,10 @@ 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 @@ -34,9 +36,12 @@ object GFSPiggyBank { @SubscribeEvent fun onChat(event: LorenzChatEvent) { + if (!isEnabled()) return val message = event.message listOf(crackedPattern, brokePattern).matchMatchers(message) { GetFromSackAPI.getFromChatMessageSackItems(ENCHANTED_PORK) } } + + fun isEnabled() = LorenzUtils.inSkyBlock && SkyHanniMod.feature.misc.gfsPiggyBank } From ee62d49b039b518ed7571b524fde5b2349949cae Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Sun, 30 Jun 2024 21:19:00 +0200 Subject: [PATCH 3/7] funny change Signed-off-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> --- .../java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt index 75fdd48f38dc..fbca0325c9d5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt @@ -34,11 +34,12 @@ object GFSPiggyBank { "§cYou died, lost [\\d.,]* coins and your piggy bank broke!", ) + private val patternList = listOf(crackedPattern, brokePattern) + @SubscribeEvent fun onChat(event: LorenzChatEvent) { if (!isEnabled()) return - val message = event.message - listOf(crackedPattern, brokePattern).matchMatchers(message) { + patternList.matchMatchers(event.message) { GetFromSackAPI.getFromChatMessageSackItems(ENCHANTED_PORK) } } From 5676ed07127fa608413d4cb37393cf92f436c460 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Sun, 30 Jun 2024 21:21:59 +0200 Subject: [PATCH 4/7] added todo Signed-off-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> --- .../java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt index fbca0325c9d5..86d1c53818d1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt @@ -39,6 +39,7 @@ object GFSPiggyBank { @SubscribeEvent fun onChat(event: LorenzChatEvent) { if (!isEnabled()) return + // TODO: change once regexutils pr (empa) is merged patternList.matchMatchers(event.message) { GetFromSackAPI.getFromChatMessageSackItems(ENCHANTED_PORK) } From 9d7cea9e2fb1ada660fafb03dca21207702b298a Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Sat, 3 Aug 2024 22:45:00 +0200 Subject: [PATCH 5/7] no idea what that meant :3 Signed-off-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> --- .../java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt index 86d1c53818d1..fbca0325c9d5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt @@ -39,7 +39,6 @@ object GFSPiggyBank { @SubscribeEvent fun onChat(event: LorenzChatEvent) { if (!isEnabled()) return - // TODO: change once regexutils pr (empa) is merged patternList.matchMatchers(event.message) { GetFromSackAPI.getFromChatMessageSackItems(ENCHANTED_PORK) } From ea7a4cb04669306f30b61c8abb0ab6b6c285e138 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Sat, 3 Aug 2024 22:45:26 +0200 Subject: [PATCH 6/7] made private Signed-off-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> --- .../java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt index fbca0325c9d5..159383d8a6ac 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt @@ -44,5 +44,5 @@ object GFSPiggyBank { } } - fun isEnabled() = LorenzUtils.inSkyBlock && SkyHanniMod.feature.misc.gfsPiggyBank + private fun isEnabled() = LorenzUtils.inSkyBlock && SkyHanniMod.feature.misc.gfsPiggyBank } From 230679391943131193d5b4c15afaf60a6c592c30 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Mon, 26 Aug 2024 21:24:19 +0200 Subject: [PATCH 7/7] how did this happen Signed-off-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> --- .../skyhanni/config/core/config/gui/GuiPositionEditor.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt b/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt index 37e97d34457d..3e64d5f5abff 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt @@ -138,7 +138,7 @@ class GuiPositionEditor( x - border, y - border, elementWidth + border * 2, - elementHeight + border * 2 + elementHeight + border * 2, ) ) { hoveredPos = index