Search in sources :

Example 1 with GlowOfflinePlayer

use of net.glowstone.GlowOfflinePlayer in project Glowstone by GlowstoneMC.

the class NbtPlayerDataService method getOfflinePlayers.

@Override
public List<OfflinePlayer> getOfflinePlayers() {
    // list files in directory
    File[] files = playerDir.listFiles();
    if (files == null) {
        return Arrays.asList();
    }
    List<OfflinePlayer> result = new ArrayList<>(files.length);
    for (File file : files) {
        // first, make sure it looks like a player file
        String name = file.getName();
        if (name.length() != 40 || !name.endsWith(".dat")) {
            continue;
        }
        // get the UUID
        UUID uuid;
        try {
            uuid = UUID.fromString(name.substring(0, 36));
        } catch (IllegalArgumentException e) {
            continue;
        }
        // creating the OfflinePlayer will read the data
        result.add(new GlowOfflinePlayer(server, uuid));
    }
    return result;
}
Also used : GlowOfflinePlayer(net.glowstone.GlowOfflinePlayer) OfflinePlayer(org.bukkit.OfflinePlayer) GlowOfflinePlayer(net.glowstone.GlowOfflinePlayer) File(java.io.File)

Example 2 with GlowOfflinePlayer

use of net.glowstone.GlowOfflinePlayer in project Glowstone by GlowstoneMC.

the class GlowTeam method getPlayers.

@Override
@Deprecated
public Set<OfflinePlayer> getPlayers() throws IllegalStateException {
    Set<OfflinePlayer> playerObjectSet = new HashSet<>(players.size());
    playerObjectSet.addAll(players.stream().map(s -> new GlowOfflinePlayer((GlowServer) Bukkit.getServer(), s)).collect(Collectors.toList()));
    return playerObjectSet;
}
Also used : GlowOfflinePlayer(net.glowstone.GlowOfflinePlayer) OfflinePlayer(org.bukkit.OfflinePlayer) GlowOfflinePlayer(net.glowstone.GlowOfflinePlayer) GlowServer(net.glowstone.GlowServer) HashSet(java.util.HashSet)

Aggregations

GlowOfflinePlayer (net.glowstone.GlowOfflinePlayer)2 OfflinePlayer (org.bukkit.OfflinePlayer)2 File (java.io.File)1 HashSet (java.util.HashSet)1 GlowServer (net.glowstone.GlowServer)1