13
0
geforkt von Mirrors/Paper

Teach CraftServer.getOfflinePlayers to also give all online players.

This method is most useful when it gives all the players who have ever
logged on to the server. Previously, it was not distinguishing between
players who had previously logged on, and were currently logged in,
and those who had previously looged on and were not currently logged in.
A distinction was made, however, between those currently logged in,
but who had not logged in previously.

This commit ensures that all players who have ever logged in (and are
listed as either logged in, or they have a player .dat file) will be
returned by the mentioned method.

Fixes BUKKIT-404
Dieser Commit ist enthalten in:
Andrew Ardill 2011-12-27 16:48:09 +11:00
Ursprung 834c420257
Commit fb8a45b648

Datei anzeigen

@ -2,7 +2,6 @@ package org.bukkit.craftbukkit;
import java.io.FileNotFoundException;
import org.bukkit.craftbukkit.command.CraftConsoleCommandSender;
import org.bukkit.generator.ChunkGenerator;
import com.avaje.ebean.config.DataSourceConfig;
import com.avaje.ebean.config.ServerConfig;
@ -25,6 +24,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
@ -931,12 +931,13 @@ public final class CraftServer implements Server {
public OfflinePlayer[] getOfflinePlayers() {
WorldNBTStorage storage = (WorldNBTStorage) console.worlds.get(0).getDataManager();
String[] files = storage.getPlayerDir().list(new DatFileFilter());
OfflinePlayer[] players = new OfflinePlayer[files.length];
Set<OfflinePlayer> players = new HashSet<OfflinePlayer>();
for (int i = 0; i < files.length; i++) {
players[i] = getOfflinePlayer(files[i].substring(0, files[i].length() - 4));
players.add(getOfflinePlayer(files[i].substring(0, files[i].length() - 4)));
}
players.addAll(Arrays.asList(getOnlinePlayers()));
return players;
return (OfflinePlayer[]) players.toArray();
}
}