Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/main/java/me/creepermaxcz/mcbots/NickGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,13 @@ public String nextRandom() {
return prefix + generateRandom(nickLen);
}

public String nextReal() {
String nick = prefix + lines.get(random.nextInt(linesSize));
return nick.length() <= 16 ? nick : nick.substring(0, 15);
public synchronized String nextReal() {

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);
}

/**
Expand Down