From fff82354486d15b7dff42153ff6ff0c87d2e828d Mon Sep 17 00:00:00 2001 From: tastybento Date: Sun, 18 Jan 2015 08:45:08 -0800 Subject: [PATCH] Better compatibility with older server 1.7.9. --- plugin.yml | 2 +- .../wasteofplastic/askyblock/PlayerCache.java | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/plugin.yml b/plugin.yml index e0e75a456..e40a40864 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: ASkyBlock main: com.wasteofplastic.askyblock.ASkyBlock -version: 2.7.8 +version: 2.7.9pre description: A SkyBlock Plugin author: Tastybento depend: [Vault] diff --git a/src/com/wasteofplastic/askyblock/PlayerCache.java b/src/com/wasteofplastic/askyblock/PlayerCache.java index b7ea158d1..84643d622 100644 --- a/src/com/wasteofplastic/askyblock/PlayerCache.java +++ b/src/com/wasteofplastic/askyblock/PlayerCache.java @@ -18,14 +18,18 @@ import java.io.File; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.World; import org.bukkit.entity.Player; +import com.google.common.collect.Lists; + /** * @author ben * Provides a memory cache of online player information @@ -38,8 +42,8 @@ public class PlayerCache { protected PlayerCache(ASkyBlock plugin) { this.plugin = plugin; - final Collection serverPlayers = Bukkit.getServer().getOnlinePlayers(); - for (Player p : serverPlayers) { + //final Collection serverPlayers = Bukkit.getServer().getOnlinePlayers(); + for (Player p : getOnlinePlayers()) { if (p.isOnline()) { final Players playerInf = new Players(plugin, p.getUniqueId()); // Make sure parties are working correctly @@ -53,7 +57,14 @@ protected PlayerCache(ASkyBlock plugin) { } } } - + public static List getOnlinePlayers() { + List list = Lists.newArrayList(); + for (World world : Bukkit.getWorlds()) { + list.addAll(world.getPlayers()); + } + return Collections.unmodifiableList(list); + } + /* * Cache control methods */