Skip to content

Commit 11adc07

Browse files
fix: teammates in middle disconnecting on DungeonListener
1 parent 957b55a commit 11adc07

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,14 @@ object DungeonListener {
231231
if (tabEntries.isNotEmpty() && tabEntries[0].second.contains("§r§b§lParty §r§f(")) {
232232
partyCount = partyCountPattern.find(tabEntries[0].second)?.groupValues?.get(1)?.toIntOrNull()
233233
if (partyCount != null) {
234-
if (team.size != partyCount) {
234+
// we can just keep disconnected players here i think
235+
if (team.size < partyCount) {
235236
println("Recomputing team as party size has changed ${team.size} -> $partyCount")
236237
team.clear()
238+
} else if (team.size > 5) {
239+
UChat.chat("$failPrefix §cSomething isn't right! I got more than 5 members. Expected $partyCount members but got ${team.size}")
240+
println("Got more than 5 players on the team??")
241+
team.clear()
237242
}
238243
} else {
239244
println("Couldn't get party count")
@@ -245,7 +250,7 @@ object DungeonListener {
245250
if (partyCount != null && (team.isEmpty() || (DungeonTimer.dungeonStartTime != -1L && team.values.any { it.dungeonClass == DungeonClass.EMPTY }))) {
246251
printDevMessage("Parsing party", "dungeonlistener")
247252
println("There are $partyCount members in this party")
248-
for (i in 0..<partyCount) {
253+
for (i in 0..<5) {
249254
val pos = 1 + i * 4
250255
val (entry, text) = tabEntries[pos]
251256
val matcher = classPattern.find(text)
@@ -284,8 +289,9 @@ object DungeonListener {
284289

285290
team[name]?.mapPlayer?.icon = "icon-${(i + (partyCount-1)) % (partyCount)}}"
286291
}
292+
287293
if (partyCount != team.size) {
288-
UChat.chat("$failPrefix §cSomething isn't right! I expected $partyCount members but only got ${team.size}")
294+
UChat.chat("$failPrefix §cSomething isn't right! I expected $partyCount members but got ${team.size}")
289295
}
290296

291297
if (DungeonTimer.dungeonStartTime != -1L && System.currentTimeMillis() - DungeonTimer.dungeonStartTime >= 2000 && team.values.any { it.dungeonClass == DungeonClass.EMPTY }) {
@@ -301,7 +307,10 @@ object DungeonListener {
301307
for (teammate in team.values) {
302308
if (tabEntries.size <= teammate.tabEntryIndex) continue
303309
val entry = tabEntries[teammate.tabEntryIndex].second
304-
if (!entry.contains(teammate.playerName)) continue
310+
if (!entry.contains(teammate.playerName)) {
311+
println("Expected ${teammate.playerName} at ${teammate.tabEntryIndex}, got ${entry}")
312+
continue
313+
}
305314
teammate.player = mc.theWorld.playerEntities.find {
306315
it.name == teammate.playerName && it.uniqueID.version() == 4
307316
}

0 commit comments

Comments
 (0)