mirror of
https://github.com/ayunami2000/ayungee.git
synced 2024-12-21 22:34:12 -08:00
disallow duplicate usernames lol
This commit is contained in:
parent
9d45885acb
commit
36bfd5469e
|
@ -111,6 +111,10 @@ public class WebSocketProxy extends WebSocketServer {
|
||||||
byte[] uname = new byte[unameLen];
|
byte[] uname = new byte[unameLen];
|
||||||
for (int i = 0; i < uname.length; i++) uname[i] = msg[5 + i * 2];
|
for (int i = 0; i < uname.length; i++) uname[i] = msg[5 + i * 2];
|
||||||
String username = new String(uname);
|
String username = new String(uname);
|
||||||
|
if (Main.clients.values().stream().anyMatch(client -> client.username.equals(username))) {
|
||||||
|
conn.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
Client selfClient = new Client(username);
|
Client selfClient = new Client(username);
|
||||||
Main.clients.put(conn, selfClient);
|
Main.clients.put(conn, selfClient);
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user