mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-01-31 23:29:36 +01:00
Legger til sjekk for unikt spillernavn
This commit is contained in:
parent
13255218f0
commit
485d04eb5f
@ -88,7 +88,12 @@ class RoboRallyServerListener extends Listener {
|
||||
public void received (Connection connection, Object object) {
|
||||
if (object instanceof String) {
|
||||
String playerName = (String) object;
|
||||
playerNames.put(connection, playerName);
|
||||
if (playerNames.values().contains(playerName)) {
|
||||
String errorMessage = "The player name send is already taken.";
|
||||
connection.sendTCP(new ErrorResponse(errorMessage, new IllegalArgumentException(errorMessage)));
|
||||
} else {
|
||||
playerNames.put(connection, playerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user