mirror of
https://gitlab.com/cable-mc/cobblemon.git
synced 2026-10-20 14:16:26 -04:00
Compare commits
3
Commits
issue-2075
...
item-2047
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
58d5478b30 | ||
|
|
2bde3058dc | ||
|
|
ffdbbe0e21 |
@@ -28,6 +28,8 @@
|
||||
- Fixed the Pokédex evolution tree crashing with a stack overflow on evolutions that loop back on themselves.
|
||||
- Fixed form-changing evolutions sometimes resolving to the source form in the Pokédex evolution tree.
|
||||
- Broken datapack evolutions are now logged and skipped in the Pokédex evolution tree instead of crashing.
|
||||
- Fixed `/spectatebattle` not starting the battle theme music, unlike spectating through the interaction wheel
|
||||
- Fixed spectating not being cancelled when a battle starts for the spectator, which merged the two battles into an unplayable state, and fixed spectating a second battle leaving the first one still sending updates
|
||||
|
||||
### Developer
|
||||
|
||||
|
||||
@@ -202,6 +202,7 @@ object BattleRegistry {
|
||||
): BattleStartResult {
|
||||
val battle = PokemonBattle(battleFormat, side1, side2)
|
||||
val start: () -> Unit = {
|
||||
battle.playerUUIDs.forEach { stopSpectating(it) }
|
||||
battleMap[battle.battleId] = battle
|
||||
startShowdown(battle)
|
||||
}
|
||||
@@ -224,6 +225,11 @@ object BattleRegistry {
|
||||
ShowdownService.service.endBattle(battle)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun stopSpectating(playerId: UUID) {
|
||||
battleMap.values.forEach { it.spectators.remove(playerId) }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getBattle(id: UUID): PokemonBattle? {
|
||||
return battleMap[id]
|
||||
|
||||
+6
-5
@@ -35,8 +35,6 @@ object SpectateBattleHandler : ServerNetworkPacketHandler<SpectateBattlePacket>
|
||||
) {
|
||||
val battle = BattleRegistry.getBattleByParticipatingPlayerId(packet.targetedEntityId)
|
||||
if (battle != null && Cobblemon.config.allowSpectating) {
|
||||
val target = battle.actors.filterIsInstance<PlayerBattleActor>().firstOrNull { it.uuid == packet.targetedEntityId }
|
||||
|
||||
// Check los and range
|
||||
val targetedPlayerEntity = packet.targetedEntityId.getPlayer() ?: return
|
||||
if (player.traceFirstEntityCollision(
|
||||
@@ -49,9 +47,6 @@ object SpectateBattleHandler : ServerNetworkPacketHandler<SpectateBattlePacket>
|
||||
}
|
||||
|
||||
this.spectateBattle(targetedPlayerEntity, player)
|
||||
|
||||
// Handle music
|
||||
target?.battleTheme?.let { player.sendPacket(BattleMusicPacket(it)) }
|
||||
}
|
||||
else {
|
||||
LOGGER.error("Battle of player id ${packet.targetedEntityId} not found (${player.uuid} tried spectating)")
|
||||
@@ -76,9 +71,15 @@ object SpectateBattleHandler : ServerNetworkPacketHandler<SpectateBattlePacket>
|
||||
|
||||
val battle = BattleRegistry.getBattleByParticipatingPlayer(target) ?: return
|
||||
|
||||
BattleRegistry.stopSpectating(player.uuid)
|
||||
battle.spectators.add(player.uuid)
|
||||
player.sendPacket(BattleInitializePacket(battle, null))
|
||||
player.sendPacket(BattleMessagePacket(battle.chatLog))
|
||||
|
||||
battle.actors.filterIsInstance<PlayerBattleActor>()
|
||||
.firstOrNull { it.uuid == target.uuid }
|
||||
?.battleTheme
|
||||
?.let { player.sendPacket(BattleMusicPacket(it)) }
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user