diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt index 4f41a6ae47a5..1cfb6b9e6436 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt @@ -24,6 +24,8 @@ import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.LorenzLogger import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.inAnyIsland +import at.hannibal2.skyhanni.utils.RegexUtils.allMatches import at.hannibal2.skyhanni.utils.RegexUtils.firstMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matches @@ -89,11 +91,11 @@ object HypixelData { ) /** - * REGEX-TEST: §r§b§lCoop §r§f(4) + * REGEX-TEST: §8[§r§a§r§8] §r§bBpoth §r§6§l℻ */ - private val playerAmountCoopPattern by patternGroup.pattern( - "playeramount.coop", - "^\\s*(?:§.)*Coop (?:§.)*\\((?\\d+)\\)\\s*$", + private val playerAmountOnIslandPattern by patternGroup.pattern( + "playeramount.onisland", + "^§.\\[[§\\w]{6,11}] §r.*", ) /** @@ -112,14 +114,6 @@ object HypixelData { "^\\s*(?:§.)+Party (?:§.)+\\((?\\d+)\\)\\s*$", ) - /** - * REGEX-TEST: §r§b§lIsland - */ - private val soloProfileAmountPattern by patternGroup.pattern( - "solo.profile.amount", - "^\\s*(?:§.)*Island\\s*$", - ) - /** * REGEX-TEST: §a✌ §7(§a11§7/20) */ @@ -178,6 +172,8 @@ object HypixelData { var skyBlockArea: String? = null var skyBlockAreaWithSymbol: String? = null + var playerAmountOnIsland = 0 + // Data from locraw var locrawData: JsonObject? = null private val locraw: MutableMap = listOf( @@ -263,7 +259,6 @@ object HypixelData { var amount = 0 val playerPatternList = mutableListOf( playerAmountPattern, - playerAmountCoopPattern, playerAmountGuestingPattern, ) if (DungeonAPI.inDungeon()) { @@ -278,14 +273,17 @@ object HypixelData { } } } - amount += TabListData.getTabList().count { soloProfileAmountPattern.matches(it) } - return amount + if (!inAnyIsland(IslandType.GARDEN, IslandType.GARDEN_GUEST, IslandType.PRIVATE_ISLAND, IslandType.PRIVATE_ISLAND_GUEST)) { + playerAmountOnIsland = 0 + } + + return amount + playerAmountOnIsland } fun getMaxPlayersForCurrentServer(): Int { scoreboardVisitingAmountPattern.firstMatcher(ScoreboardData.sidebarLinesFormatted) { - return group("maxamount").toInt() + return group("maxamount").toInt() + playerAmountOnIsland } return when (skyBlockIsland) { @@ -449,6 +447,8 @@ object HypixelData { when (event.widget) { TabWidget.AREA -> checkIsland(event) TabWidget.PROFILE -> checkProfile() + TabWidget.COOP -> countPlayersOnIsland(event) + TabWidget.ISLAND -> countPlayersOnIsland(event) else -> Unit } } @@ -570,4 +570,9 @@ object HypixelData { val scoreboardTitle = displayName.removeColor() return scoreboardTitlePattern.matches(scoreboardTitle) } + + private fun countPlayersOnIsland(event: WidgetUpdateEvent) { + if (event.isClear()) return + playerAmountOnIsland = playerAmountOnIslandPattern.allMatches(event.lines).size + } } diff --git a/src/main/java/at/hannibal2/skyhanni/data/model/TabWidget.kt b/src/main/java/at/hannibal2/skyhanni/data/model/TabWidget.kt index 40973b5898d5..43e9b699224f 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/model/TabWidget.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/model/TabWidget.kt @@ -119,6 +119,10 @@ enum class TabWidget( // language=RegExp "(?:§.)*Coop (?:§.)*.*", ), + ISLAND( + // language=RegExp + "(?:§.)*Island", + ), MINION( // language=RegExp "(?:§.)*Minions: (?:§.)*(?\\d+)(?:§.)*/(?:§.)*(?\\d+)",