Skip to content

Commit d68a741

Browse files
committed
feat(sdk): add data to TooManyPlayersException
1 parent 63a6eb7 commit d68a741

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Game(override val currentState: GameState = GameState()): AbstractGame<Pla
2323
private val availableTeams = mutableListOf(Team.ONE, Team.TWO)
2424
override fun onPlayerJoined(): Player {
2525
if (availableTeams.isEmpty())
26-
throw TooManyPlayersException()
26+
throw TooManyPlayersException(this)
2727
val player = currentState.getPlayer(availableTeams.removeAt(0))
2828

2929
players.add(player)
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
package sc.api.plugins.exceptions
22

3-
class TooManyPlayersException: IllegalStateException("Attempted to join an already full game")
3+
class TooManyPlayersException(game: Any? = null):
4+
IllegalStateException("Attempted to join an already full game${game?.let { ": $it" }}")

server/src/sc/server/gaming/GameRoom.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public List<PlayerSlot> getSlots() {
286286

287287
private PlayerSlot openSlot() {
288288
if (playerSlots.size() >= getMaximumPlayerCount())
289-
throw new TooManyPlayersException();
289+
throw new TooManyPlayersException(this);
290290
PlayerSlot slot = new PlayerSlot(this);
291291
Player player = game.onPlayerJoined();
292292
slot.setPlayer(player);

0 commit comments

Comments
 (0)