Enforced duplication check on nickname change
This commit is contained in:
@@ -7,7 +7,7 @@ public class MessageFormatter {
|
||||
* handle it. May need to be redesigned one the games uses a GUI
|
||||
*
|
||||
* @param msg the Messaged to be reformatted
|
||||
* @return the reformatted message
|
||||
* @return the reformatted message in the form HEADR$msg
|
||||
*/
|
||||
|
||||
public static String formatMsg(String msg) {
|
||||
|
||||
@@ -99,9 +99,12 @@ public class ClientHandler implements Runnable {
|
||||
}
|
||||
|
||||
public void changeUsername(String newName) {
|
||||
|
||||
if (AllClientNames.allNames("").contains(newName)) {
|
||||
newName = NameGenerator.randomName(newName);
|
||||
}
|
||||
String h = this.clientUserName; //just a friendly little helper
|
||||
this.clientUserName = newName;
|
||||
AllClientNames.allNames(newName);
|
||||
broadcastMessage(h +" have changed their nickname to " + clientUserName);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user