diff options
author | Andrew Ardill <andrew.ardill@gmail.com> | 2011-12-27 16:48:09 +1100 |
---|---|---|
committer | Andrew Ardill <andrew.ardill@gmail.com> | 2011-12-27 16:48:09 +1100 |
commit | fb8a45b6482af0457a7990c573a5723918310646 (patch) | |
tree | fedad3161eaaa75c0dddee59977e7229561b9ab5 /src/main/java | |
parent | 834c42025735e9db7044c3a2c66d162dc48dc4cf (diff) | |
download | craftbukkit-fb8a45b6482af0457a7990c573a5723918310646.tar craftbukkit-fb8a45b6482af0457a7990c573a5723918310646.tar.gz craftbukkit-fb8a45b6482af0457a7990c573a5723918310646.tar.lz craftbukkit-fb8a45b6482af0457a7990c573a5723918310646.tar.xz craftbukkit-fb8a45b6482af0457a7990c573a5723918310646.zip |
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
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/CraftServer.java | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index d07eb7c8..ea85cb6e 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -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; @@ -929,14 +929,15 @@ public final class CraftServer implements Server { } public OfflinePlayer[] getOfflinePlayers() { - WorldNBTStorage storage = (WorldNBTStorage)console.worlds.get(0).getDataManager(); + 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(); } } |