Skip to content

Commit 602d1f3

Browse files
committed
fix(sdk): turn TooManyPlayersException into RuntimeException
1 parent b2c2db8 commit 602d1f3

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

plugin/src/server/sc/plugin2021/Game.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package sc.plugin2021
22

33
import org.slf4j.LoggerFactory
4+
import sc.api.plugins.exceptions.TooManyPlayersException
45
import sc.framework.plugins.AbstractGame
56
import sc.framework.plugins.ActionTimeout
67
import sc.framework.plugins.Player
@@ -22,7 +23,7 @@ class Game(override val currentState: GameState = GameState()): AbstractGame<Pla
2223
private val availableTeams = mutableListOf(Team.ONE, Team.TWO)
2324
override fun onPlayerJoined(): Player {
2425
if (availableTeams.isEmpty())
25-
throw IllegalStateException("Too many players joined the game!")
26+
throw TooManyPlayersException()
2627
val player = currentState.getPlayer(availableTeams.removeAt(0))
2728

2829
players.add(player)

sdk/src/server-api/sc/api/plugins/IGameInstance.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package sc.api.plugins
22

33
import sc.api.plugins.exceptions.GameLogicException
4-
import sc.api.plugins.exceptions.TooManyPlayersException
54
import sc.api.plugins.host.IGameListener
65
import sc.framework.plugins.Player
76
import sc.protocol.room.RoomMessage
@@ -11,12 +10,7 @@ import sc.shared.ScoreCause
1110
import kotlin.jvm.Throws
1211

1312
interface IGameInstance {
14-
/**
15-
* @return the player that joined
16-
*
17-
* @throws TooManyPlayersException when game is already full
18-
*/
19-
@Throws(TooManyPlayersException::class)
13+
/** @return the player that joined. */
2014
fun onPlayerJoined(): Player
2115
fun onPlayerLeft(player: Player, cause: ScoreCause? = null)
2216

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package sc.api.plugins.exceptions
22

3-
class TooManyPlayersException: GameRoomException("This game is full already.")
3+
class TooManyPlayersException: IllegalStateException("Attempted to join an already full game")

0 commit comments

Comments
 (0)