mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-13 11:18:23 +01:00
Simplify getPlayerExact / try for exact match first in getPlayer.
By: md_5 <git@md-5.net>
This commit is contained in:
parent
e19d7d24a2
commit
3cb3a3bd2e
1 changed files with 8 additions and 10 deletions
|
@ -386,7 +386,12 @@ public final class CraftServer implements Server {
|
|||
public Player getPlayer(final String name) {
|
||||
Validate.notNull(name, "Name cannot be null");
|
||||
|
||||
Player found = null;
|
||||
Player found = getPlayerExact(name);
|
||||
// Try for an exact match first.
|
||||
if (found != null) {
|
||||
return found;
|
||||
}
|
||||
|
||||
String lowerName = name.toLowerCase();
|
||||
int delta = Integer.MAX_VALUE;
|
||||
for (Player player : getOnlinePlayers()) {
|
||||
|
@ -407,15 +412,8 @@ public final class CraftServer implements Server {
|
|||
public Player getPlayerExact(String name) {
|
||||
Validate.notNull(name, "Name cannot be null");
|
||||
|
||||
String lname = name.toLowerCase();
|
||||
|
||||
for (Player player : getOnlinePlayers()) {
|
||||
if (player.getName().equalsIgnoreCase(lname)) {
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
EntityPlayer player = playerList.getPlayer(name);
|
||||
return (player != null) ? player.getBukkitEntity() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Reference in a new issue