mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
allowed partial name matching
By: Tahg <tahgtahv@gmail.com>
This commit is contained in:
parent
49d67847a7
commit
9f88190ab1
@ -17,12 +17,12 @@ import org.bukkit.plugin.SimpleCommandManager;
|
||||
import org.bukkit.plugin.SimplePluginManager;
|
||||
import org.bukkit.plugin.java.JavaPluginLoader;
|
||||
|
||||
public final class CraftServer implements Server {
|
||||
public final class CraftServer implements Server
|
||||
{
|
||||
private final String serverName = "Craftbukkit";
|
||||
private final String serverVersion = "1.2_01";
|
||||
private final PluginManager pluginManager = new SimplePluginManager(this);
|
||||
private final CommandManager commandManager = new SimpleCommandManager();
|
||||
|
||||
protected final MinecraftServer console;
|
||||
protected final ServerConfigurationManager server;
|
||||
|
||||
@ -77,13 +77,20 @@ public final class CraftServer implements Server {
|
||||
public Player getPlayer(final String name) {
|
||||
Player[] players = getOnlinePlayers();
|
||||
|
||||
Player found = null;
|
||||
String lowerName = name.toLowerCase();
|
||||
int delta = Integer.MAX_VALUE;
|
||||
for (Player player : players) {
|
||||
if (player.getName().equalsIgnoreCase(name)) {
|
||||
return player;
|
||||
if (player.getName().toLowerCase().startsWith(lowerName)) {
|
||||
int curDelta = player.getName().length() - lowerName.length();
|
||||
if(curDelta == 0) break;
|
||||
if (curDelta < delta) {
|
||||
found = player;
|
||||
delta = curDelta;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
public int broadcastMessage(String message) {
|
||||
|
Loading…
Reference in New Issue
Block a user