From 3fb2822af7b6a9362dac9994dd0b6a4390ce7d11 Mon Sep 17 00:00:00 2001 From: Chiss5618 Date: Fri, 6 Dec 2024 12:37:33 -0600 Subject: [PATCH 1/6] initial commit (doesn't work) --- .../at/hannibal2/skyhanni/data/HypixelData.kt | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt index 71e478d0609e..f2642fcb7d54 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt @@ -24,6 +24,7 @@ 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.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 +90,11 @@ object HypixelData { ) /** - * REGEX-TEST: §r§b§lCoop §r§f(4) + * REGEX-TEST: §8[§r§2168§r§8] §r§aMelonLordDe §r§6§l℻ */ private val playerAmountCoopPattern by patternGroup.pattern( "playeramount.coop", - "^\\s*(?:§.)*Coop (?:§.)*\\((?\\d+)\\)\\s*$", + "§.\\[(?: .*)?", ) /** @@ -178,6 +179,8 @@ object HypixelData { var skyBlockArea: String? = null var skyBlockAreaWithSymbol: String? = null + var coopOnIslandCount = 0 + // Data from locraw var locrawData: JsonObject? = null private val locraw: MutableMap = listOf( @@ -263,7 +266,6 @@ object HypixelData { var amount = 0 val playerPatternList = mutableListOf( playerAmountPattern, - playerAmountCoopPattern, playerAmountGuestingPattern, ) if (DungeonAPI.inDungeon()) { @@ -278,7 +280,7 @@ object HypixelData { } } } - amount += TabListData.getTabList().count { soloProfileAmountPattern.matches(it) } + amount += TabListData.getTabList().count { soloProfileAmountPattern.matches(it) } + coopOnIslandCount return amount } @@ -449,6 +451,7 @@ object HypixelData { when (event.widget) { TabWidget.AREA -> checkIsland(event) TabWidget.PROFILE -> checkProfile() + TabWidget.COOP -> countCoopOnline(event) else -> Unit } } @@ -570,4 +573,15 @@ object HypixelData { val scoreboardTitle = displayName.removeColor() return scoreboardTitlePattern.matches(scoreboardTitle) } + + + private fun countCoopOnline(event: WidgetUpdateEvent) { + var coopCount = 0 + for(line in event.lines) { + playerAmountPattern.matchMatcher(line) { + coopCount += 1 + } + } + coopOnIslandCount = coopCount + } } From 2b39af1e5f0690a3b651e268b06e088968bae668 Mon Sep 17 00:00:00 2001 From: Chiss5618 <78828070+Chiss5618@users.noreply.github.com> Date: Fri, 6 Dec 2024 14:40:20 -0600 Subject: [PATCH 2/6] fix --- .../at/hannibal2/skyhanni/data/HypixelData.kt | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt index e268a63c7158..459e8a5276a1 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt @@ -90,11 +90,19 @@ object HypixelData { ) /** - * REGEX-TEST: §8[§r§2168§r§8] §r§aMelonLordDe §r§6§l℻ + * REGEX-TEST: §r§b§lCoop §r§f(8) + * §8[§r§a§r§8] §r§bBpoth §r§6§l℻ + * §8[§r§2168§r§8] §r§aMelonLordDe §r§6§l℻ + * §aMulanLord + * §aOkuuUnyu + * §aImNotToph + * §aIdcDom + * §abToph + * §bChissl */ private val playerAmountCoopPattern by patternGroup.pattern( "playeramount.coop", - "§.\\[(?: .*)?", + "^§.\\[[§\\w]{6,11}] §r.*", ) /** @@ -280,14 +288,14 @@ object HypixelData { } } } - amount += TabListData.getTabList().count { soloProfileAmountPattern.matches(it) } + coopOnIslandCount + amount += TabListData.getTabList().count { soloProfileAmountPattern.matches(it) } - return amount + return amount + coopOnIslandCount } fun getMaxPlayersForCurrentServer(): Int { scoreboardVisitingAmountPattern.firstMatcher(ScoreboardData.sidebarLinesFormatted) { - return group("maxamount").toInt() + return group("maxamount").toInt() + coopOnIslandCount } return when (skyBlockIsland) { @@ -451,7 +459,7 @@ object HypixelData { when (event.widget) { TabWidget.AREA -> checkIsland(event) TabWidget.PROFILE -> checkProfile() - TabWidget.COOP -> countCoopOnline(event) + TabWidget.COOP -> countCoopOnIsland(event) else -> Unit } } @@ -574,14 +582,8 @@ object HypixelData { return scoreboardTitlePattern.matches(scoreboardTitle) } - - private fun countCoopOnline(event: WidgetUpdateEvent) { - var coopCount = 0 - for(line in event.lines) { - playerAmountPattern.matchMatcher(line) { - coopCount += 1 - } - } - coopOnIslandCount = coopCount + private fun countCoopOnIsland(event: WidgetUpdateEvent) { + if (!event.isWidget(TabWidget.COOP)) return + coopOnIslandCount = playerAmountCoopPattern.allMatches(event.lines).size } } From 2dcab21a38d16a190b342a0d757adc7fa7e57d88 Mon Sep 17 00:00:00 2001 From: Chiss5618 <78828070+Chiss5618@users.noreply.github.com> Date: Fri, 6 Dec 2024 17:18:21 -0600 Subject: [PATCH 3/6] fix guest/solo islands --- .../at/hannibal2/skyhanni/data/HypixelData.kt | 32 +++++++++++++------ .../skyhanni/data/model/TabWidget.kt | 4 +++ 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt index 459e8a5276a1..d990c4207560 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt @@ -24,6 +24,7 @@ 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.isAnyOf import at.hannibal2.skyhanni.utils.RegexUtils.allMatches import at.hannibal2.skyhanni.utils.RegexUtils.firstMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher @@ -100,7 +101,7 @@ object HypixelData { * §abToph * §bChissl */ - private val playerAmountCoopPattern by patternGroup.pattern( + private val playerAmountOnIslandPattern by patternGroup.pattern( "playeramount.coop", "^§.\\[[§\\w]{6,11}] §r.*", ) @@ -187,7 +188,7 @@ object HypixelData { var skyBlockArea: String? = null var skyBlockAreaWithSymbol: String? = null - var coopOnIslandCount = 0 + var playerAmountOnIsland = 0 // Data from locraw var locrawData: JsonObject? = null @@ -288,14 +289,17 @@ object HypixelData { } } } - amount += TabListData.getTabList().count { soloProfileAmountPattern.matches(it) } - return amount + coopOnIslandCount + if (!isPlayerIsland()) { + playerAmountOnIsland = 0 + } + + return amount + playerAmountOnIsland } fun getMaxPlayersForCurrentServer(): Int { scoreboardVisitingAmountPattern.firstMatcher(ScoreboardData.sidebarLinesFormatted) { - return group("maxamount").toInt() + coopOnIslandCount + return group("maxamount").toInt() + playerAmountOnIsland } return when (skyBlockIsland) { @@ -459,7 +463,8 @@ object HypixelData { when (event.widget) { TabWidget.AREA -> checkIsland(event) TabWidget.PROFILE -> checkProfile() - TabWidget.COOP -> countCoopOnIsland(event) + TabWidget.COOP -> countPlayersOnIsland(event) + TabWidget.ISLAND -> countPlayersOnIsland(event) else -> Unit } } @@ -582,8 +587,17 @@ object HypixelData { return scoreboardTitlePattern.matches(scoreboardTitle) } - private fun countCoopOnIsland(event: WidgetUpdateEvent) { - if (!event.isWidget(TabWidget.COOP)) return - coopOnIslandCount = playerAmountCoopPattern.allMatches(event.lines).size + private fun countPlayersOnIsland(event: WidgetUpdateEvent) { + if (event.isClear()) return + playerAmountOnIsland = playerAmountOnIslandPattern.allMatches(event.lines).size + } + + private fun isPlayerIsland(): Boolean { + return LorenzUtils.skyBlockIsland.isAnyOf( + IslandType.GARDEN, + IslandType.GARDEN_GUEST, + IslandType.PRIVATE_ISLAND, + IslandType.PRIVATE_ISLAND_GUEST, + ) } } 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 d93053d73fec..3641f8ade1da 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/model/TabWidget.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/model/TabWidget.kt @@ -118,6 +118,10 @@ enum class TabWidget( // language=RegExp "(?:§.)*Coop (?:§.)*.*", ), + ISLAND( + // language=RegExp + "(?:§.)*Island", + ), MINION( // language=RegExp "(?:§.)*Minions: (?:§.)*(?\\d+)(?:§.)*/(?:§.)*(?\\d+)", From fdd426e396b7651c1b12a237f3af2be912d2714f Mon Sep 17 00:00:00 2001 From: Chiss5618 <78828070+Chiss5618@users.noreply.github.com> Date: Fri, 6 Dec 2024 17:38:41 -0600 Subject: [PATCH 4/6] detekt fixes --- .../at/hannibal2/skyhanni/data/HypixelData.kt | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt index d990c4207560..ce1e12fc2163 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt @@ -91,15 +91,7 @@ object HypixelData { ) /** - * REGEX-TEST: §r§b§lCoop §r§f(8) - * §8[§r§a§r§8] §r§bBpoth §r§6§l℻ - * §8[§r§2168§r§8] §r§aMelonLordDe §r§6§l℻ - * §aMulanLord - * §aOkuuUnyu - * §aImNotToph - * §aIdcDom - * §abToph - * §bChissl + * REGEX-TEST: §8[§r§a§r§8] §r§bBpoth §r§6§l℻ */ private val playerAmountOnIslandPattern by patternGroup.pattern( "playeramount.coop", @@ -122,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) */ From 26b0088bae0d81e2bba321b3ebb892afe84299ea Mon Sep 17 00:00:00 2001 From: Chiss5618 <78828070+Chiss5618@users.noreply.github.com> Date: Fri, 6 Dec 2024 18:02:43 -0600 Subject: [PATCH 5/6] changed function used for island detection --- .../java/at/hannibal2/skyhanni/data/HypixelData.kt | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt index ce1e12fc2163..80e342b6eed4 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt @@ -24,7 +24,7 @@ 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.isAnyOf +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 @@ -274,7 +274,7 @@ object HypixelData { } } - if (!isPlayerIsland()) { + if (!inAnyIsland(IslandType.GARDEN, IslandType.GARDEN_GUEST, IslandType.PRIVATE_ISLAND, IslandType.PRIVATE_ISLAND_GUEST)) { playerAmountOnIsland = 0 } @@ -575,13 +575,4 @@ object HypixelData { if (event.isClear()) return playerAmountOnIsland = playerAmountOnIslandPattern.allMatches(event.lines).size } - - private fun isPlayerIsland(): Boolean { - return LorenzUtils.skyBlockIsland.isAnyOf( - IslandType.GARDEN, - IslandType.GARDEN_GUEST, - IslandType.PRIVATE_ISLAND, - IslandType.PRIVATE_ISLAND_GUEST, - ) - } } From e98522ece796590c858eb627cafce700fac0cc50 Mon Sep 17 00:00:00 2001 From: Chiss5618 <78828070+Chiss5618@users.noreply.github.com> Date: Fri, 6 Dec 2024 20:50:19 -0600 Subject: [PATCH 6/6] changed playerAmountOnIslandPattern pattern key --- src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt index 80e342b6eed4..79b7328a18c3 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt @@ -94,7 +94,7 @@ object HypixelData { * REGEX-TEST: §8[§r§a§r§8] §r§bBpoth §r§6§l℻ */ private val playerAmountOnIslandPattern by patternGroup.pattern( - "playeramount.coop", + "playeramount.onisland", "^§.\\[[§\\w]{6,11}] §r.*", )