diff options
author | Nathan Adams <dinnerbone@dinnerbone.com> | 2011-12-04 17:57:00 +0000 |
---|---|---|
committer | Nathan Adams <dinnerbone@dinnerbone.com> | 2011-12-04 17:57:00 +0000 |
commit | dbd3ff71fc7f07abb36843616bf7d1e832e32655 (patch) | |
tree | fca65a0dc7f884b6d0092d1e9d5ff4add0e9f80a | |
parent | c6d182286c69a5d0500c53fd3a743d48e9f326e8 (diff) | |
download | craftbukkit-dbd3ff71fc7f07abb36843616bf7d1e832e32655.tar craftbukkit-dbd3ff71fc7f07abb36843616bf7d1e832e32655.tar.gz craftbukkit-dbd3ff71fc7f07abb36843616bf7d1e832e32655.tar.lz craftbukkit-dbd3ff71fc7f07abb36843616bf7d1e832e32655.tar.xz craftbukkit-dbd3ff71fc7f07abb36843616bf7d1e832e32655.zip |
Implemented server.getOfflinePlayers
3 files changed, 28 insertions, 0 deletions
diff --git a/src/main/java/net/minecraft/server/WorldNBTStorage.java b/src/main/java/net/minecraft/server/WorldNBTStorage.java index 934e777d..7f05f273 100644 --- a/src/main/java/net/minecraft/server/WorldNBTStorage.java +++ b/src/main/java/net/minecraft/server/WorldNBTStorage.java @@ -253,5 +253,9 @@ public class WorldNBTStorage implements PlayerFileData, IDataManager { return null; } } + + public File getPlayerDir() { + return playerDir; + } // CraftBukkit end } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 28684105..f0d4b58a 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -51,6 +51,7 @@ import net.minecraft.server.Item; import net.minecraft.server.ItemStack; import net.minecraft.server.WorldMap; import net.minecraft.server.WorldMapCollection; +import net.minecraft.server.WorldNBTStorage; import net.minecraft.server.WorldSettings; import org.bukkit.*; import org.bukkit.configuration.ConfigurationSection; @@ -71,6 +72,7 @@ import org.bukkit.craftbukkit.inventory.CraftShapelessRecipe; import org.bukkit.craftbukkit.map.CraftMapView; import org.bukkit.scheduler.BukkitWorker; import org.bukkit.craftbukkit.scheduler.CraftScheduler; +import org.bukkit.craftbukkit.util.DatFileFilter; import org.bukkit.craftbukkit.util.Versioning; import org.bukkit.util.permissions.DefaultPermissions; import org.bukkit.event.world.WorldInitEvent; @@ -918,4 +920,16 @@ public final class CraftServer implements Server { public File getWorldContainer() { return new File(configuration.getString("settings.world-container", ".")); } + + public OfflinePlayer[] getOfflinePlayers() { + WorldNBTStorage storage = (WorldNBTStorage)console.worlds.get(0).getDataManager(); + String[] files = storage.getPlayerDir().list(new DatFileFilter()); + OfflinePlayer[] players = new OfflinePlayer[files.length]; + + for (int i = 0; i < files.length; i++) { + players[i] = getOfflinePlayer(files[i].substring(0, files[i].length() - 4)); + } + + return players; + } } diff --git a/src/main/java/org/bukkit/craftbukkit/util/DatFileFilter.java b/src/main/java/org/bukkit/craftbukkit/util/DatFileFilter.java new file mode 100644 index 00000000..712c44f1 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/util/DatFileFilter.java @@ -0,0 +1,10 @@ +package org.bukkit.craftbukkit.util; + +import java.io.File; +import java.io.FilenameFilter; + +public class DatFileFilter implements FilenameFilter { + public boolean accept(File dir, String name) { + return name.endsWith(".dat"); + } +} |