No repeat nicknames #109

Open
bthemen wants to merge 1 commits from bthemen/no-repeat-nicks into main
pull from: bthemen/no-repeat-nicks
Showing only changes of commit 3811004fda - Show all commits
@@ -78,10 +78,13 @@ public class NickGenerator {
return prefix + generateRandom(nickLen); return prefix + generateRandom(nickLen);
} }
public String nextReal() { public synchronized String nextReal() {
String nick = prefix + lines.get(random.nextInt(linesSize));
return nick.length() <= 16 ? nick : nick.substring(0, 15);
int index = random.nextInt(linesSize);
String nick = prefix + lines.remove(index); // Remove chosen nicknames
linesSize = lines.size();
return nick.length() <= 16 ? nick : nick.substring(0, 15);
} }
/** /**