Skip to content

Commit

Permalink
changes so far
Browse files Browse the repository at this point in the history
  • Loading branch information
catgirlseraid committed May 19, 2024
1 parent 916ff22 commit b90974d
Show file tree
Hide file tree
Showing 16 changed files with 389 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import at.hannibal2.skyhanni.utils.StringUtils.matches
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.client.gui.inventory.GuiChest
import net.minecraft.inventory.ContainerChest
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

class AnvilCombineHelper {

private val patternGroup = RepoPattern.group("anvil.helper")
private val guiNamePattern by patternGroup.pattern(
"guiname",
"Anvil"
)

@SubscribeEvent
fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) {
if (!LorenzUtils.inSkyBlock) return
Expand All @@ -24,7 +32,7 @@ class AnvilCombineHelper {
val chest = event.gui.inventorySlots as ContainerChest
val chestName = chest.getInventoryName()

if (chestName != "Anvil") return
if (!guiNamePattern.matches(chestName)) return

val matchLore = mutableListOf<String>()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.matches
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
Expand Down Expand Up @@ -32,6 +33,51 @@ class CompactBingoChat {
"border",
"§[e3]§l▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬"
)
private val skillLevelUpPattern by patternGroup.pattern(
"levelup",
" {2}§r§b§lSKILL LEVEL UP.*"
)
private val skyblockLevelUpPattern by patternGroup.pattern(
"sblevelup",
" {2}§r§3§lSKYBLOCK LEVEL UP §bLevel.*"
)
private val rewardsPattern by patternGroup.pattern(
"rewards",
" {2}§r§a§lREWARDS"
)
private val accessToBazaarPattern by patternGroup.pattern(
"bazaar",
" {3}§r§7§6Access to Bazaar"
)
private val accessToCommunityShopPattern by patternGroup.pattern(
"communityshop",
" {3}§r§7§bAccess to Community Shop"
)
private val autoPickupPattern by patternGroup.pattern(
"pickup",
" {3}§r§7§8+§aAuto-pickup block and mob drops"
)
private val collectionLevelUpPattern by patternGroup.pattern(
"collectionlevelup",
" {2}§r§6§lCOLLECTION LEVEL UP.*"
)
private val newAreaPattern by patternGroup.pattern(
"newarea",
" §r§6§lNEW AREA DISCOVERED!"
)
private val newAreaStartsWithPattern by patternGroup.pattern(
"newareastartswith",
"^(§7 {3}■ §r| {5}§r| {3}§r).*"
)
private val containsTradeRecipePattern by patternGroup.pattern(
"containstraderecipe",
".*(Trade|Recipe).*"
)
private val exactTradeRecipePattern by patternGroup.pattern(
"exacttraderecipe",
"^(Trade|Recipe)$"
)


@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
Expand All @@ -57,55 +103,57 @@ class CompactBingoChat {

// TODO USE SH-REPO
private fun onSkillLevelUp(message: String): Boolean {
if (message.startsWith(" §r§b§lSKILL LEVEL UP ")) {
skillLevelUpPattern.matchMatcher(message) {
inSkillLevelUp = true
return false
}

if (inSkillLevelUp && !message.contains("Access to") && !message.endsWith(" Enchantment")) {
return true
}

return false
//TODO this doesn't seem to be the right message
return inSkillLevelUp && !message.contains("Access to") && !message.endsWith(" Enchantment")
}

private fun onSkyBlockLevelUp(message: String): Boolean {
if (message.startsWith(" §r§3§lSKYBLOCK LEVEL UP §bLevel ")) {
skyblockLevelUpPattern.matchMatcher(message) {
inSkyBlockLevelUp = true
return false
}

if (inSkyBlockLevelUp) {
if (message == " §r§a§lREWARDS") return true
rewardsPattern.matchMatcher(message) {
return true
}
// We don't care about extra health & strength
healthPattern.matchMatcher(message) {
return true
}
strengthPattern.matchMatcher(message) {
return true
}

// No Bazaar and Community Shop in bingo
if (message == " §r§7§6Access to Bazaar") return true
if (message == " §r§7§bAccess to Community Shop") return true

accessToBazaarPattern.matchMatcher(message) {
return true
}
accessToCommunityShopPattern.matchMatcher(message) {
return true
}
// Always enabled in bingo
if (message == " §r§7§8+§aAuto-pickup block and mob drops") return true
autoPickupPattern.matchMatcher(message) {
return true
}
}

return false
}

private fun onCollectionLevelUp(message: String): Boolean {
if (message.startsWith(" §r§6§lCOLLECTION LEVEL UP ")) {
collectionLevelUpPattern.matchMatcher(message) {
inCollectionLevelUp = true
return false
}

if (inCollectionLevelUp) {
if (message.contains("Trade") || message.contains("Recipe")) {
if (containsTradeRecipePattern.matches(message)) {
val text = message.removeColor().replace(" ", "")
if (text == "Trade" || text == "Recipe") {
if (exactTradeRecipePattern.matches(text)) {
collectionLevelUpLastLine?.let { ChatUtils.chat(it, false) }
}
} else {
Expand All @@ -118,7 +166,7 @@ class CompactBingoChat {
}

private fun onNewAreaDiscovered(message: String): Boolean {
if (message == " §r§6§lNEW AREA DISCOVERED!") {
newAreaPattern.matchMatcher(message) {
newArea = 1
return false
}
Expand All @@ -130,7 +178,7 @@ class CompactBingoChat {
}

if (newArea == 2) {
if (message.startsWith("§7 ■ §r") || message.startsWith(" §r") || message.startsWith(" §r")) {
if (newAreaStartsWithPattern.matches(message)) {
return true
} else {
newArea = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.matches
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import com.google.gson.JsonArray
Expand All @@ -33,10 +34,19 @@ class MinionCraftHelper {

private val config get() = SkyHanniMod.feature.event.bingo

private val minionNamePattern by RepoPattern.pattern(
"bingo.minion.name",
private val patternGroup = RepoPattern.group("bingo.minion")
private val minionNamePattern by patternGroup.pattern(
"name",
"(?<name>.*) Minion (?<number>.*)"
)
private val isMinionNamePattern by RepoPattern.pattern(
"isminionname",
".* Minion (?!Skin).*"
)
private val invNamePattern by RepoPattern.pattern(
"invname",
"Crafted Minions"
)

private var display = emptyList<String>()
private var hasMinionInInventory = false
Expand Down Expand Up @@ -258,12 +268,12 @@ class MinionCraftHelper {
return replace(lastText, "" + next)
}

private fun isMinionName(itemName: String) = itemName.contains(" Minion ") && !itemName.contains(" Minion Skin")
private fun isMinionName(itemName: String) = isMinionNamePattern.matches(itemName)

@SubscribeEvent
fun onInventoryOpen(event: InventoryFullyOpenedEvent) {
if (!LorenzUtils.isBingoProfile) return
if (event.inventoryName != "Crafted Minions") return
if (!invNamePattern.matches(event.inventoryName)) return

for ((_, b) in event.inventoryItems) {
val name = b.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
import at.hannibal2.skyhanni.utils.StringUtils
import at.hannibal2.skyhanni.utils.StringUtils.matches
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.TimeUtils.format
import at.hannibal2.skyhanni.utils.renderables.Renderable
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.GuiChat
import net.minecraft.client.gui.inventory.GuiInventory
Expand All @@ -32,6 +34,12 @@ class BingoCardDisplay {

private var hasHiddenPersonalGoals = false

private val patternGroup = RepoPattern.group("bingo.carddisplay")
private val invNamePattern by patternGroup.pattern(
"invname",
"Bingo Card"
)

companion object {

private const val MAX_PERSONAL_GOALS = 20
Expand Down Expand Up @@ -244,7 +252,7 @@ class BingoCardDisplay {
}

private fun canEditDisplay() =
Minecraft.getMinecraft().currentScreen is GuiInventory || InventoryUtils.openInventoryName() == "Bingo Card"
Minecraft.getMinecraft().currentScreen is GuiInventory || invNamePattern.matches(InventoryUtils.openInventoryName())

@SubscribeEvent
fun onBingoCardUpdate(event: BingoCardUpdateEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.matches
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.TimeUtils
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
Expand All @@ -38,17 +39,37 @@ class BingoCardReader {
"hiddengoal",
".*§7§eThe next hint will unlock in (?<time>.*)"
)
private val communityHiddenGoalPattern by patternGroup.pattern(
"hiddengoalcommunity",
"§7This goal will be revealed §7when it hits Tier IV."
)
private val invNamePattern by patternGroup.pattern(
"invname",
"Bingo Card"
)
private val goalPersonalPattern by patternGroup.pattern(
"personalgoal",
".*Personal Goal"
)
private val goalCommunityPattern by patternGroup.pattern(
"communitygoal",
".*Community Goal"
)
private val goalReachedPattern by patternGroup.pattern(
"goalreached",
"GOAL REACHED"
)

@SubscribeEvent
fun onInventoryUpdated(event: InventoryUpdatedEvent) {
if (!config.enabled) return
if (event.inventoryName != "Bingo Card") return
if (!invNamePattern.matches(event.inventoryName)) return

for ((slot, stack) in event.inventoryItems) {
val lore = stack.getLore()
val goalType = when {
lore.any { it.endsWith("Personal Goal") } -> GoalType.PERSONAL
lore.any { it.endsWith("Community Goal") } -> GoalType.COMMUNITY
lore.any { goalPersonalPattern.matches(it) } -> GoalType.PERSONAL
lore.any { goalCommunityPattern.matches(it) } -> GoalType.COMMUNITY
else -> continue
}
val name = stack.name.removeColor()
Expand All @@ -70,7 +91,7 @@ class BingoCardReader {
description = description.substring(2)
}

val done = lore.any { it.contains("GOAL REACHED") }
val done = lore.any { goalReachedPattern.matches(it) }
val communtyGoalPercentage = readCommuntyGoalPercentage(lore)
val hiddenGoalData = getHiddenGoalData(name, description, goalType)
val visualDescription = hiddenGoalData.tipNote
Expand Down Expand Up @@ -134,7 +155,7 @@ class BingoCardReader {
}

GoalType.COMMUNITY -> {
if (originalDescription == "§7This goal will be revealed §7when it hits Tier IV.") {
if (communityHiddenGoalPattern.matches(originalDescription)) {
unknownTip = true
}
null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.NumberUtil.formatInt
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.matches
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
Expand Down Expand Up @@ -55,6 +56,10 @@ class BingoNextStepHelper {
"crystal.found",
" *§r§5§l✦ CRYSTAL FOUND §r§7\\(.§r§7/5§r§7\\)"
)
private val npcMessagePattern by patternGroup.pattern(
"crystal.npcmessage",
"§e[NPC] §dRhys§f: §rThank you for the items!§r"
)

private val itemIslandRequired = mutableMapOf<String, IslandVisitStep>()
private val itemPreconditions = mutableMapOf<String, NextStep>()
Expand Down Expand Up @@ -168,7 +173,10 @@ class BingoNextStepHelper {
}
}
}
if (currentStep is PartialProgressItemsStep && currentStep.displayName == rhysTaskName && event.message == "§e[NPC] §dRhys§f: §rThank you for the items!§r") {
if (currentStep is PartialProgressItemsStep && currentStep.displayName == rhysTaskName && npcMessagePattern.matches(
event.message
)
) {
currentStep.amountHavingHidden -= 10
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class ArachneChatMessageHider {
"border",
"§a§l▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬"
)

private val arachneDownPattern by patternGroup.pattern(
"down",
" {30}§r§6§lARACHNE DOWN!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class ChatFilter {
private val dungeonConfig get() = SkyHanniMod.feature.dungeon.messageFilter

/// <editor-fold desc="Regex Patterns & Messages">
//TODO replace this with repo list patterns when added
// Lobby Messages
private val lobbyPatterns = listOf(
// player join
Expand Down
Loading

0 comments on commit b90974d

Please sign in to comment.