Skip to content

Commit

Permalink
Feature: GetFromSack Piggy Bank (hannibal002#2150)
Browse files Browse the repository at this point in the history
Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com>
  • Loading branch information
j10a1n15 and CalMWolfs authored Sep 12, 2024
1 parent 4e23db7 commit b99310b
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,12 @@ public class MiscConfig {
@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;

@Expose
@ConfigOption(name = "SkyHanni User Luck", desc = "Shows SkyHanni User Luck in the SkyBlock Stats.")
@ConfigEditorBoolean
Expand Down
48 changes: 48 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit b99310b

Please sign in to comment.