mirror of
				https://github.com/inf112-v20/Fiasko.git
				synced 2025-11-04 03:33:45 +01:00 
			
		
		
		
	Legger til sjekk for unikt spillernavn
This commit is contained in:
		@@ -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);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user