diff --git a/blockball-core/src/main/java/com/github/shynixn/blockball/core/logic/business/service/GameExecutionServiceImpl.kt b/blockball-core/src/main/java/com/github/shynixn/blockball/core/logic/business/service/GameExecutionServiceImpl.kt index 9fca2ba16..da6ac19b9 100644 --- a/blockball-core/src/main/java/com/github/shynixn/blockball/core/logic/business/service/GameExecutionServiceImpl.kt +++ b/blockball-core/src/main/java/com/github/shynixn/blockball/core/logic/business/service/GameExecutionServiceImpl.kt @@ -38,7 +38,13 @@ class GameExecutionServiceImpl @Inject constructor(private val proxyService: Pro * Applies points to the belonging teams when the given [player] dies in the given [game]. */ override fun applyDeathPoints(game: G, player: P) { - val team = game.ingamePlayersStorage[player as Any]!!.team!! + require(player is Any) + + if (!game.ingamePlayersStorage.containsKey(player)) { + return + } + + val team = game.ingamePlayersStorage[player]!!.team if (team == Team.RED) { game.blueScore += game.arena.meta.blueTeamMeta.pointsPerEnemyDeath @@ -51,7 +57,13 @@ class GameExecutionServiceImpl @Inject constructor(private val proxyService: Pro * Lets the given [player] in the given [game] respawn at the specified spawnpoint. */ override fun respawn(game: G, player: P) { - val team = game.ingamePlayersStorage[player as Any]!!.goalTeam!! + require(player is Any) + + if (!game.ingamePlayersStorage.containsKey(player)) { + return + } + + val team = game.ingamePlayersStorage[player]!!.goalTeam val teamMeta = if (team == Team.RED) { game.arena.meta.redTeamMeta @@ -65,4 +77,4 @@ class GameExecutionServiceImpl @Inject constructor(private val proxyService: Pro proxyService.setPlayerLocation(player, teamMeta.spawnpoint!!) } } -} \ No newline at end of file +}