3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 12:30:06 +01:00

Simplify getPlayerExact / try for exact match first in getPlayer.

Dieser Commit ist enthalten in:
md_5 2015-07-13 19:00:33 +10:00
Ursprung 65cd4d79fd
Commit b105298f2e

Datei anzeigen

@ -386,7 +386,12 @@ public final class CraftServer implements Server {
public Player getPlayer(final String name) { public Player getPlayer(final String name) {
Validate.notNull(name, "Name cannot be null"); 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(); String lowerName = name.toLowerCase();
int delta = Integer.MAX_VALUE; int delta = Integer.MAX_VALUE;
for (Player player : getOnlinePlayers()) { for (Player player : getOnlinePlayers()) {
@ -407,15 +412,8 @@ public final class CraftServer implements Server {
public Player getPlayerExact(String name) { public Player getPlayerExact(String name) {
Validate.notNull(name, "Name cannot be null"); Validate.notNull(name, "Name cannot be null");
String lname = name.toLowerCase(); EntityPlayer player = playerList.getPlayer(name);
return (player != null) ? player.getBukkitEntity() : null;
for (Player player : getOnlinePlayers()) {
if (player.getName().equalsIgnoreCase(lname)) {
return player;
}
}
return null;
} }
@Override @Override