Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 12:30:06 +01:00
Added CraftServer.matchPlayer(String) - partial-name matching
Dieser Commit ist enthalten in:
Ursprung
6a786c1c21
Commit
1e3c5a393b
@ -81,6 +81,30 @@ public final class CraftServer implements Server {
|
||||
return entity.a.getPlayer();
|
||||
}
|
||||
|
||||
public Player matchPlayer(String wantedPlayerName) {
|
||||
Player wantedPlayer = null;
|
||||
|
||||
for (Player iterPlayer : this.getOnlinePlayers()) {
|
||||
String iterPlayerName = iterPlayer.getName();
|
||||
|
||||
if (wantedPlayerName.equalsIgnoreCase(iterPlayerName)) {
|
||||
// Exact match
|
||||
wantedPlayer = this.getPlayer(wantedPlayerName);
|
||||
break;
|
||||
}
|
||||
if (wantedPlayerName.toLowerCase().indexOf(iterPlayerName.toLowerCase()) != -1) {
|
||||
// Partial match
|
||||
if (wantedPlayer != null) {
|
||||
// Multiple matches
|
||||
return null;
|
||||
}
|
||||
wantedPlayer = iterPlayer;
|
||||
}
|
||||
}
|
||||
|
||||
return wantedPlayer;
|
||||
}
|
||||
|
||||
public PluginManager getPluginManager() {
|
||||
return pluginManager;
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren