Skip to content

Commit c548859

Browse files
fix: DungeonListener adapts to Hypixel's latest changes regarding dcing
1 parent 5408e55 commit c548859

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/main/kotlin/gg/skytils/skytilsmod/listeners/DungeonListener.kt

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -227,17 +227,20 @@ object DungeonListener {
227227
if (Utils.inDungeons && mc.thePlayer != null && (DungeonTimer.scoreShownAt == -1L || System.currentTimeMillis() - DungeonTimer.scoreShownAt < 1500)) {
228228
val tabEntries = TabListUtils.tabEntries
229229
var partyCount: Int? = null
230+
var oldTeam: Map<String, DungeonTeammate>? = null
230231

231232
if (tabEntries.isNotEmpty() && tabEntries[0].second.contains("§r§b§lParty §r§f(")) {
232233
partyCount = partyCountPattern.find(tabEntries[0].second)?.groupValues?.get(1)?.toIntOrNull()
233234
if (partyCount != null) {
234235
// we can just keep disconnected players here i think
235-
if (team.size < partyCount) {
236+
if (team.size != partyCount) {
236237
println("Recomputing team as party size has changed ${team.size} -> $partyCount")
238+
oldTeam = team.clone() as Map<String, DungeonTeammate>
237239
team.clear()
238240
} else if (team.size > 5) {
239241
UChat.chat("$failPrefix §cSomething isn't right! I got more than 5 members. Expected $partyCount members but got ${team.size}")
240242
println("Got more than 5 players on the team??")
243+
oldTeam = team.clone() as Map<String, DungeonTeammate>
241244
team.clear()
242245
}
243246
} else {
@@ -279,12 +282,18 @@ object DungeonListener {
279282
)
280283
} else {
281284
println("Parsed teammate $name with value EMPTY, $text")
282-
team[name] = DungeonTeammate(
283-
name,
284-
DungeonClass.EMPTY, 0,
285-
pos,
286-
entry.locationSkin
287-
)
285+
if (oldTeam != null && name in oldTeam) {
286+
val old = oldTeam[name]!!
287+
team[name] = old.copy(tabEntryIndex = pos)
288+
println("Got old teammate $name with value EMPTY, using $old instead")
289+
} else {
290+
team[name] = DungeonTeammate(
291+
name,
292+
DungeonClass.EMPTY, 0,
293+
pos,
294+
entry.locationSkin
295+
)
296+
}
288297
}
289298

290299
team[name]?.mapPlayer?.icon = "icon-${(i + (partyCount-1)) % (partyCount)}}"
@@ -308,7 +317,7 @@ object DungeonListener {
308317
if (tabEntries.size <= teammate.tabEntryIndex) continue
309318
val entry = tabEntries[teammate.tabEntryIndex].second
310319
if (!entry.contains(teammate.playerName)) {
311-
println("Expected ${teammate.playerName} at ${teammate.tabEntryIndex}, got ${entry}")
320+
println("Expected ${teammate.playerName} at ${teammate.tabEntryIndex}, got $entry")
312321
continue
313322
}
314323
teammate.player = mc.theWorld.playerEntities.find {

0 commit comments

Comments
 (0)