From 037456c99db15ab28d0f0ae095ce5e86ad561037 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 16 Aug 2014 19:04:13 +1000 Subject: [PATCH] Fix missed cases from previous user iteration optimizations. --- Essentials/src/com/earth2me/essentials/Essentials.java | 8 +++----- Essentials/src/com/earth2me/essentials/User.java | 2 +- .../src/com/earth2me/essentials/commands/Commandnear.java | 5 ++--- .../com/earth2me/essentials/commands/Commandptime.java | 4 ++-- .../com/earth2me/essentials/commands/Commandpweather.java | 4 ++-- .../earth2me/essentials/textreader/KeywordReplacer.java | 2 +- 6 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index fc100ee3d..e8d0a5d3a 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -325,9 +325,8 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials @Override public void onDisable() { - for (Player p : getServer().getOnlinePlayers()) + for (User user : getOnlineUsers()) { - User user = getUser(p); if (user.isVanished()) { user.setVanished(false); @@ -562,9 +561,8 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials public void cleanupOpenInventories() { - for (Player player : getServer().getOnlinePlayers()) + for (User user : getOnlineUsers()) { - User user = getUser(player); if (user.isRecipeSee()) { user.getBase().getOpenInventory().getTopInventory().clear(); @@ -742,7 +740,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials event.getPlayer().sendMessage("Essentials failed to load, read the log file."); } }, this); - for (Player player : getServer().getOnlinePlayers()) + for (Player player : getOnlinePlayers()) { player.sendMessage("Essentials failed to load, read the log file."); } diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index a0dc39843..41a32e529 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -780,7 +780,7 @@ public class User extends UserData implements Comparable, IReplyTo, net.es } else { - for (Player p : ess.getServer().getOnlinePlayers()) + for (Player p : ess.getOnlinePlayers()) { p.showPlayer(getBase()); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandnear.java b/Essentials/src/com/earth2me/essentials/commands/Commandnear.java index 29d30b3e7..a31c220ca 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandnear.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandnear.java @@ -103,10 +103,9 @@ public class Commandnear extends EssentialsCommand final long radiusSquared = radius * radius; boolean showHidden = user.canInteractVanished(); - for (Player onlinePlayer : server.getOnlinePlayers()) + for (User player: ess.getOnlineUsers()) { - final User player = ess.getUser(onlinePlayer); - if (!player.equals(user) && (!player.isHidden(user.getBase()) || showHidden || user.getBase().canSee(onlinePlayer))) + if (!player.equals(user) && (!player.isHidden(user.getBase()) || showHidden || user.getBase().canSee(player.getBase()))) { final Location playerLoc = player.getLocation(); if (playerLoc.getWorld() != world) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandptime.java b/Essentials/src/com/earth2me/essentials/commands/Commandptime.java index 6bd748bff..edb16d5d7 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandptime.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandptime.java @@ -220,9 +220,9 @@ public class Commandptime extends EssentialsCommand // If that fails, Is the argument something like "*" or "all"? else if (selector.equalsIgnoreCase("*") || selector.equalsIgnoreCase("all")) { - for (Player player : server.getOnlinePlayers()) + for (User u : ess.getOnlineUsers()) { - users.add(ess.getUser(player)); + users.add(u); } } // We failed to understand the world target... diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandpweather.java b/Essentials/src/com/earth2me/essentials/commands/Commandpweather.java index 9aec1ff6b..69e0295dc 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandpweather.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandpweather.java @@ -170,9 +170,9 @@ public class Commandpweather extends EssentialsCommand // If that fails, Is the argument something like "*" or "all"? else if (selector.equalsIgnoreCase("*") || selector.equalsIgnoreCase("all")) { - for (Player player : server.getOnlinePlayers()) + for (User u : ess.getOnlineUsers()) { - users.add(ess.getUser(player)); + users.add(u); } } // We failed to understand the world target... diff --git a/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java b/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java index 3395a4b7f..c2c40b1dc 100644 --- a/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java +++ b/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java @@ -222,7 +222,7 @@ public class KeywordReplacer implements IText //Now lets build the all user playerlist final StringBuilder playerlistBuilder = new StringBuilder(); - for (Player p : ess.getServer().getOnlinePlayers()) + for (Player p : ess.getOnlinePlayers()) { if (ess.getUser(p).isHidden()) {