forked from hannibal002/SkyHanni
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: GetFromSack Piggy Bank (hannibal002#2150)
Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com>
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/main/java/at/hannibal2/skyhanni/features/misc/GFSPiggyBank.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |