forked from kaboomserver/extras
Make the taken username check more accurate (#336)
Instead of using `Bukkit.getPlayer(name)`, now each player is manually iterated over to check if a username is taken. This fixes multiple problems, such as a player not being able to set their name to `a` because a player named `ab` is online, and a player not being able to set their username back to the one they joined with.
This commit is contained in:
parent
f6f5ae6efb
commit
820b105327
1 changed files with 3 additions and 1 deletions
|
@ -55,7 +55,9 @@ public final class CommandUsername implements CommandExecutor {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (Bukkit.getPlayer(name) != null) {
|
||||
for (Player other : Bukkit.getOnlinePlayers()) {
|
||||
if (!other.getName().equals(name)) continue;
|
||||
|
||||
player.sendMessage(Component
|
||||
.text("A player with that username is already logged in."));
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue