mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-30 06:24:06 +01:00
allowed partial name matching
This commit is contained in:
parent
ca9d523646
commit
42099e7379
@ -17,12 +17,12 @@ import org.bukkit.plugin.SimpleCommandManager;
|
|||||||
import org.bukkit.plugin.SimplePluginManager;
|
import org.bukkit.plugin.SimplePluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPluginLoader;
|
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 serverName = "Craftbukkit";
|
||||||
private final String serverVersion = "1.2_01";
|
private final String serverVersion = "1.2_01";
|
||||||
private final PluginManager pluginManager = new SimplePluginManager(this);
|
private final PluginManager pluginManager = new SimplePluginManager(this);
|
||||||
private final CommandManager commandManager = new SimpleCommandManager();
|
private final CommandManager commandManager = new SimpleCommandManager();
|
||||||
|
|
||||||
protected final MinecraftServer console;
|
protected final MinecraftServer console;
|
||||||
protected final ServerConfigurationManager server;
|
protected final ServerConfigurationManager server;
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ public final class CraftServer implements Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void loadPlugins() {
|
public void loadPlugins() {
|
||||||
File pluginFolder = (File)console.options.valueOf("plugins");
|
File pluginFolder = (File) console.options.valueOf("plugins");
|
||||||
|
|
||||||
if (pluginFolder.exists()) {
|
if (pluginFolder.exists()) {
|
||||||
try {
|
try {
|
||||||
@ -77,13 +77,20 @@ public final class CraftServer implements Server {
|
|||||||
public Player getPlayer(final String name) {
|
public Player getPlayer(final String name) {
|
||||||
Player[] players = getOnlinePlayers();
|
Player[] players = getOnlinePlayers();
|
||||||
|
|
||||||
|
Player found = null;
|
||||||
|
String lowerName = name.toLowerCase();
|
||||||
|
int delta = Integer.MAX_VALUE;
|
||||||
for (Player player : players) {
|
for (Player player : players) {
|
||||||
if (player.getName().equalsIgnoreCase(name)) {
|
if (player.getName().toLowerCase().startsWith(lowerName)) {
|
||||||
return player;
|
int curDelta = player.getName().length() - lowerName.length();
|
||||||
|
if(curDelta == 0) break;
|
||||||
|
if (curDelta < delta) {
|
||||||
|
found = player;
|
||||||
|
delta = curDelta;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return found;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int broadcastMessage(String message) {
|
public int broadcastMessage(String message) {
|
||||||
@ -126,7 +133,7 @@ public final class CraftServer implements Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public World[] getWorlds() {
|
public World[] getWorlds() {
|
||||||
return new World[] { console.e.getWorld() };
|
return new World[]{console.e.getWorld()};
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getTime() {
|
public long getTime() {
|
||||||
|
Loading…
Reference in New Issue
Block a user