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