summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2014-07-12 16:03:36 +1000
committerKHobbits <rob@khobbits.co.uk>2014-07-19 20:07:50 +0100
commit465041b98b5283cfff231473d457b11f13766a76 (patch)
treedeee438a807191ab4cd4795dab7326c53623d71c
parented56afda26107837ce63dac63554ad8dc0e7bbcc (diff)
downloadEssentials-465041b98b5283cfff231473d457b11f13766a76.tar
Essentials-465041b98b5283cfff231473d457b11f13766a76.tar.gz
Essentials-465041b98b5283cfff231473d457b11f13766a76.tar.lz
Essentials-465041b98b5283cfff231473d457b11f13766a76.tar.xz
Essentials-465041b98b5283cfff231473d457b11f13766a76.zip
Optimize player / user iteration.
* Add a method for backwards compatability with unmapped code. * Convert all getOnlinePlayers() calls to use this method, part of the IEssentials interface * Add a new method getOnlineUsers() Ljava/lang/Iterable; * Convert appropriate calls to use this method * Update Bukkit to #1945 * Update CraftBukkit to #3103
-rw-r--r--Essentials/src/com/earth2me/essentials/Backup.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/Essentials.java59
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java5
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsTimer.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/IEssentials.java5
-rw-r--r--Essentials/src/com/earth2me/essentials/PlayerList.java15
-rw-r--r--Essentials/src/com/earth2me/essentials/User.java9
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java7
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandessentials.java6
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandkickall.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandnick.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandnuke.java7
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandptime.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandpweather.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandrealname.java5
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java3
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtpall.java3
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/EssentialsLoopCommand.java15
-rw-r--r--Essentials/src/com/earth2me/essentials/metrics/Metrics.java3
-rw-r--r--Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java6
-rw-r--r--Essentials/test/com/earth2me/essentials/FakeServer.java8
-rw-r--r--EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java6
-rw-r--r--EssentialsXMPP/src/com/earth2me/essentials/xmpp/IEssentialsXMPP.java3
-rw-r--r--EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java2
-rw-r--r--lib/bukkit.jarbin4948889 -> 4952817 bytes
-rw-r--r--lib/craftbukkit.jarbin20453584 -> 20468888 bytes
27 files changed, 126 insertions, 63 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Backup.java b/Essentials/src/com/earth2me/essentials/Backup.java
index 5ace61e98..889d2cbfe 100644
--- a/Essentials/src/com/earth2me/essentials/Backup.java
+++ b/Essentials/src/com/earth2me/essentials/Backup.java
@@ -24,7 +24,7 @@ public class Backup implements Runnable
{
this.ess = ess;
server = ess.getServer();
- if (server.getOnlinePlayers().length > 0)
+ if (!ess.getOnlinePlayers().isEmpty())
{
ess.runTaskAsynchronously(new Runnable()
{
@@ -152,7 +152,7 @@ public class Backup implements Runnable
public void run()
{
server.dispatchCommand(cs, "save-on");
- if (server.getOnlinePlayers().length == 0)
+ if (ess.getOnlinePlayers().isEmpty())
{
stopTask();
}
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java
index fbe874f16..fc100ee3d 100644
--- a/Essentials/src/com/earth2me/essentials/Essentials.java
+++ b/Essentials/src/com/earth2me/essentials/Essentials.java
@@ -35,10 +35,17 @@ import com.earth2me.essentials.textreader.IText;
import com.earth2me.essentials.textreader.KeywordReplacer;
import com.earth2me.essentials.textreader.SimpleTextInput;
import com.earth2me.essentials.utils.DateUtil;
+import com.google.common.base.Function;
+import com.google.common.base.Throwables;
+import com.google.common.collect.Iterables;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
import java.util.List;
import java.util.UUID;
import java.util.logging.Level;
@@ -100,6 +107,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials
private transient Metrics metrics;
private transient EssentialsTimer timer;
private final transient List<String> vanishedPlayers = new ArrayList<String>();
+ private transient Method oldGetOnlinePlayers;
public Essentials()
{
@@ -181,6 +189,16 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials
LOGGER.log(Level.INFO, getServer().getBukkitVersion());
}
execTimer.mark("BukkitCheck");
+
+ for (Method method : Server.class.getDeclaredMethods())
+ {
+ if (method.getName().endsWith("getOnlinePlayers") && method.getReturnType() == Player[].class)
+ {
+ oldGetOnlinePlayers = method;
+ break;
+ }
+ }
+
try
{
final EssentialsUpgrade upgrade = new EssentialsUpgrade(this);
@@ -784,7 +802,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials
IText broadcast = new SimpleTextInput(message);
- final Player[] players = getServer().getOnlinePlayers();
+ final Collection<Player> players = getOnlinePlayers();
for (Player player : players)
{
@@ -803,7 +821,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials
}
}
- return players.length;
+ return players.size();
}
@Override
@@ -890,6 +908,43 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials
return vanishedPlayers;
}
+ @Override
+ public Collection<Player> getOnlinePlayers()
+ {
+ try
+ {
+ return (Collection<Player>)getServer().getOnlinePlayers(); // Needed for sanity here, the Bukkit API is a bit broken in the sense it only allows subclasses of Player to this list
+ }
+ catch (NoSuchMethodError ex)
+ {
+ try
+ {
+ return Arrays.asList((Player[])oldGetOnlinePlayers.invoke(getServer()));
+ }
+ catch (InvocationTargetException ex1)
+ {
+ throw Throwables.propagate(ex.getCause());
+ }
+ catch (IllegalAccessException ex1)
+ {
+ throw new RuntimeException("Error invoking oldGetOnlinePlayers", ex1);
+ }
+ }
+ }
+
+ @Override
+ public Iterable<User> getOnlineUsers()
+ {
+ return Iterables.transform(getOnlinePlayers(), new Function<Player, User>()
+ {
+
+ @Override
+ public User apply(Player player)
+ {
+ return getUser(player);
+ }
+ });
+ }
private static class EssentialsWorldListener implements Listener, Runnable
{
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
index eb3ceed26..32e69fcde 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
@@ -435,10 +435,9 @@ public class EssentialsPlayerListener implements Listener
final String cmd = event.getMessage().toLowerCase(Locale.ENGLISH).split(" ")[0].replace("/", "").toLowerCase(Locale.ENGLISH);
if (ess.getSettings().getSocialSpyCommands().contains(cmd) || ess.getSettings().getSocialSpyCommands().contains("*"))
{
- for (Player onlinePlayer : ess.getServer().getOnlinePlayers())
+ for (User spyer : ess.getOnlineUsers())
{
- final User spyer = ess.getUser(onlinePlayer);
- if (spyer.isSocialSpyEnabled() && !player.equals(onlinePlayer))
+ if (spyer.isSocialSpyEnabled() && !player.equals(spyer.getBase()))
{
spyer.sendMessage(player.getDisplayName() + " : " + event.getMessage());
}
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsTimer.java b/Essentials/src/com/earth2me/essentials/EssentialsTimer.java
index 4c17fda37..8f75445e2 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsTimer.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsTimer.java
@@ -48,7 +48,7 @@ public class EssentialsTimer implements Runnable
}
lastPoll = startTime;
int count = 0;
- for (Player player : ess.getServer().getOnlinePlayers())
+ for (Player player : ess.getOnlinePlayers())
{
count++;
if (skip1 > 0)
diff --git a/Essentials/src/com/earth2me/essentials/IEssentials.java b/Essentials/src/com/earth2me/essentials/IEssentials.java
index 1e155976e..3f6f05703 100644
--- a/Essentials/src/com/earth2me/essentials/IEssentials.java
+++ b/Essentials/src/com/earth2me/essentials/IEssentials.java
@@ -6,6 +6,7 @@ import com.earth2me.essentials.api.IWarps;
import com.earth2me.essentials.metrics.Metrics;
import com.earth2me.essentials.perm.PermissionsHandler;
import com.earth2me.essentials.register.payment.Methods;
+import java.util.Collection;
import java.util.List;
import java.util.UUID;
import org.bukkit.World;
@@ -91,4 +92,8 @@ public interface IEssentials extends Plugin
EssentialsTimer getTimer();
List<String> getVanishedPlayers();
+
+ Collection<Player> getOnlinePlayers();
+
+ Iterable<User> getOnlineUsers();
}
diff --git a/Essentials/src/com/earth2me/essentials/PlayerList.java b/Essentials/src/com/earth2me/essentials/PlayerList.java
index f0ce2fb84..fb8a1f0bc 100644
--- a/Essentials/src/com/earth2me/essentials/PlayerList.java
+++ b/Essentials/src/com/earth2me/essentials/PlayerList.java
@@ -49,12 +49,12 @@ public class PlayerList
Server server = ess.getServer();
int playerHidden = 0;
int hiddenCount = 0;
- for (Player onlinePlayer : server.getOnlinePlayers())
+ for (User onlinePlayer : ess.getOnlineUsers())
{
- if (ess.getUser(onlinePlayer).isHidden() || (user != null && !user.getBase().canSee(onlinePlayer)))
+ if (onlinePlayer.isHidden() || (user != null && !user.getBase().canSee(onlinePlayer.getBase())))
{
playerHidden++;
- if (showHidden || user.getBase().canSee(onlinePlayer))
+ if (showHidden || user.getBase().canSee(onlinePlayer.getBase()))
{
hiddenCount++;
}
@@ -63,11 +63,11 @@ public class PlayerList
String online;
if (hiddenCount > 0)
{
- online = tl("listAmountHidden", server.getOnlinePlayers().length - playerHidden, hiddenCount, server.getMaxPlayers());
+ online = tl("listAmountHidden", ess.getOnlinePlayers().size() - playerHidden, hiddenCount, server.getMaxPlayers());
}
else
{
- online = tl("listAmount", server.getOnlinePlayers().length - playerHidden, server.getMaxPlayers());
+ online = tl("listAmount", ess.getOnlinePlayers().size() - playerHidden, server.getMaxPlayers());
}
return online;
}
@@ -77,11 +77,10 @@ public class PlayerList
{
Server server = ess.getServer();
final Map<String, List<User>> playerList = new HashMap<String, List<User>>();
- for (Player onlinePlayer : server.getOnlinePlayers())
+ for (User onlineUser : ess.getOnlineUsers())
{
- final User onlineUser = ess.getUser(onlinePlayer);
if ((sender == null && !showHidden && onlineUser.isHidden()) ||
- (sender != null && !showHidden && !sender.getBase().canSee(onlinePlayer)))
+ (sender != null && !showHidden && !sender.getBase().canSee(onlineUser.getBase())))
{
continue;
}
diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java
index bca444dde..2487fafc2 100644
--- a/Essentials/src/com/earth2me/essentials/User.java
+++ b/Essentials/src/com/earth2me/essentials/User.java
@@ -623,9 +623,8 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
this.getBase().kickPlayer(kickReason);
- for (Player player : ess.getServer().getOnlinePlayers())
+ for (User user : ess.getOnlineUsers())
{
- final User user = ess.getUser(player);
if (user.isAuthorized("essentials.kick.notify"))
{
user.sendMessage(tl("playerKicked", Console.NAME, getName(), kickReason));
@@ -765,11 +764,11 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
vanished = set;
if (set)
{
- for (Player p : ess.getServer().getOnlinePlayers())
+ for (User user : ess.getOnlineUsers())
{
- if (!ess.getUser(p).isAuthorized("essentials.vanish.see"))
+ if (!user.isAuthorized("essentials.vanish.see"))
{
- p.hidePlayer(getBase());
+ user.getBase().hidePlayer(getBase());
}
}
setHidden(true);
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java b/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java
index 1633fd685..311cb3e13 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java
@@ -5,8 +5,7 @@ import static com.earth2me.essentials.I18n.tl;
import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.NumberUtil;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
+import java.util.Collection;
import java.util.Locale;
import org.bukkit.Server;
import org.bukkit.entity.Player;
@@ -36,7 +35,7 @@ public class Commandclearinventory extends EssentialsCommand
private void parseCommand(Server server, CommandSource sender, String[] args, boolean allowOthers, boolean allowAll) throws Exception
{
- List<Player> players = new ArrayList<Player>();
+ Collection<Player> players = new ArrayList<Player>();
int offset = 0;
if (sender.isPlayer())
@@ -48,7 +47,7 @@ public class Commandclearinventory extends EssentialsCommand
{
sender.sendMessage(tl("inventoryClearingFromAll"));
offset = 1;
- players = Arrays.asList(server.getOnlinePlayers());
+ players = ess.getOnlinePlayers();
}
else if (allowOthers && args.length > 0 && args[0].trim().length() > 2)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java b/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java
index 23173661e..54f409b8e 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java
@@ -165,7 +165,7 @@ public class Commandessentials extends EssentialsCommand
{
return;
}
- for (Player onlinePlayer : server.getOnlinePlayers())
+ for (Player onlinePlayer : ess.getOnlinePlayers())
{
onlinePlayer.playSound(onlinePlayer.getLocation(), Sound.NOTE_PIANO, 1, noteMap.get(note));
}
@@ -214,7 +214,7 @@ public class Commandessentials extends EssentialsCommand
{
logger.info(s);
}
- for (Player player : ess.getServer().getOnlinePlayers())
+ for (Player player : ess.getOnlinePlayers())
{
player.sendMessage(playerMoo);
player.playSound(player.getLocation(), Sound.COW_IDLE, 1, 1.0f);
@@ -348,7 +348,7 @@ public class Commandessentials extends EssentialsCommand
UUID onlineUUID = null;
- for (Player player : server.getOnlinePlayers())
+ for (Player player : ess.getOnlinePlayers())
{
if (player.getName().equalsIgnoreCase(name))
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java b/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java
index ba885731a..745da13e3 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java
@@ -20,7 +20,7 @@ public class Commandkickall extends EssentialsCommand
String kickReason = args.length > 0 ? getFinalArg(args, 0) : tl("kickDefault");
kickReason = FormatUtil.replaceFormat(kickReason.replace("\\n", "\n").replace("|", "\n"));
- for (Player onlinePlayer : server.getOnlinePlayers())
+ for (Player onlinePlayer : ess.getOnlinePlayers())
{
if (!sender.isPlayer() || !onlinePlayer.getName().equalsIgnoreCase(sender.getPlayer().getName()))
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandnick.java b/Essentials/src/com/earth2me/essentials/commands/Commandnick.java
index 366b525e0..fb8914fe4 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandnick.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandnick.java
@@ -109,7 +109,7 @@ public class Commandnick extends EssentialsLoopCommand
private boolean nickInUse(final Server server, final User target, String nick)
{
final String lowerNick = FormatUtil.stripFormat(nick.toLowerCase(Locale.ENGLISH));
- for (final Player onlinePlayer : server.getOnlinePlayers())
+ for (final Player onlinePlayer : ess.getOnlinePlayers())
{
if (target.getBase().getName().equals(onlinePlayer.getName()))
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandnuke.java b/Essentials/src/com/earth2me/essentials/commands/Commandnuke.java
index 7e6e347c3..e82c46c8d 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandnuke.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandnuke.java
@@ -3,8 +3,7 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource;
import static com.earth2me.essentials.I18n.tl;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
+import java.util.Collection;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.World;
@@ -22,7 +21,7 @@ public class Commandnuke extends EssentialsCommand
@Override
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws NoSuchFieldException, NotEnoughArgumentsException
{
- List<Player> targets;
+ Collection<Player> targets;
if (args.length > 0)
{
targets = new ArrayList<Player>();
@@ -35,7 +34,7 @@ public class Commandnuke extends EssentialsCommand
}
else
{
- targets = Arrays.asList(server.getOnlinePlayers());
+ targets = ess.getOnlinePlayers();
}
ess.getTNTListener().enable();
for (Player player : targets)
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandptime.java b/Essentials/src/com/earth2me/essentials/commands/Commandptime.java
index c14f31cbb..6bd748bff 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandptime.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandptime.java
@@ -197,9 +197,9 @@ public class Commandptime extends EssentialsCommand
}
else
{
- for (Player player : server.getOnlinePlayers())
+ for (User user : ess.getOnlineUsers())
{
- users.add(ess.getUser(player));
+ users.add(user);
}
}
return users;
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandpweather.java b/Essentials/src/com/earth2me/essentials/commands/Commandpweather.java
index cf47e8b17..9aec1ff6b 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandpweather.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandpweather.java
@@ -147,9 +147,9 @@ public class Commandpweather extends EssentialsCommand
}
else
{
- for (Player player : server.getOnlinePlayers())
+ for (User user : ess.getOnlineUsers())
{
- users.add(ess.getUser(player));
+ users.add(user);
}
}
return users;
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java b/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java
index a292316bd..55cdadbfb 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java
@@ -26,10 +26,9 @@ public class Commandrealname extends EssentialsCommand
final String whois = args[0].toLowerCase(Locale.ENGLISH);
boolean skipHidden = sender.isPlayer() && !ess.getUser(sender.getPlayer()).canInteractVanished();
boolean foundUser = false;
- for (Player onlinePlayer : server.getOnlinePlayers())
+ for (User u: ess.getOnlineUsers())
{
- final User u = ess.getUser(onlinePlayer);
- if (skipHidden && u.isHidden(sender.getPlayer()) && !sender.getPlayer().canSee(onlinePlayer))
+ if (skipHidden && u.isHidden(sender.getPlayer()) && !sender.getPlayer().canSee(u.getBase()))
{
continue;
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java
index 572083540..4cbd9603b 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java
@@ -34,9 +34,8 @@ public class Commandtpaall extends EssentialsCommand
private void teleportAAllPlayers(final Server server, final CommandSource sender, final User target)
{
sender.sendMessage(tl("teleportAAll"));
- for (Player onlinePlayer : server.getOnlinePlayers())
+ for (User player : ess.getOnlineUsers())
{
- final User player = ess.getUser(onlinePlayer);
if (target == player)
{
continue;
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java
index 503d29e98..c850fad2e 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java
@@ -37,9 +37,8 @@ public class Commandtpall extends EssentialsCommand
{
sender.sendMessage(tl("teleportAll"));
final Location loc = target.getLocation();
- for (Player onlinePlayer : server.getOnlinePlayers())
+ for (User player : ess.getOnlineUsers())
{
- final User player = ess.getUser(onlinePlayer);
if (target == player)
{
continue;
diff --git a/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java b/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java
index 71d45a288..ee605ffb3 100644
--- a/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java
+++ b/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java
@@ -137,10 +137,8 @@ public abstract class EssentialsCommand implements IEssentialsCommand
if (matches.isEmpty())
{
final String matchText = searchTerm.toLowerCase(Locale.ENGLISH);
- for (Player onlinePlayer : server.getOnlinePlayers())
+ for (User userMatch : ess.getOnlineUsers())
{
- final User userMatch = ess.getUser(onlinePlayer);
-
if (getHidden || canInteractWith(sourceUser, userMatch))
{
final String displayName = FormatUtil.stripFormat(userMatch.getDisplayName()).toLowerCase(Locale.ENGLISH);
diff --git a/Essentials/src/com/earth2me/essentials/commands/EssentialsLoopCommand.java b/Essentials/src/com/earth2me/essentials/commands/EssentialsLoopCommand.java
index 7dfa594fc..ccb297f14 100644
--- a/Essentials/src/com/earth2me/essentials/commands/EssentialsLoopCommand.java
+++ b/Essentials/src/com/earth2me/essentials/commands/EssentialsLoopCommand.java
@@ -38,10 +38,9 @@ public abstract class EssentialsLoopCommand extends EssentialsCommand
else if (matchWildcards && searchTerm.contentEquals("*"))
{
boolean skipHidden = sender.isPlayer() && !ess.getUser(sender.getPlayer()).canInteractVanished();
- for (Player onlinePlayer : server.getOnlinePlayers())
+ for (User onlineUser : ess.getOnlineUsers())
{
- final User onlineUser = ess.getUser(onlinePlayer);
- if (skipHidden && onlineUser.isHidden(sender.getPlayer()) && !sender.getPlayer().canSee(onlinePlayer))
+ if (skipHidden && onlineUser.isHidden(sender.getPlayer()) && !sender.getPlayer().canSee(onlineUser.getBase()))
{
continue;
}
@@ -85,10 +84,9 @@ public abstract class EssentialsLoopCommand extends EssentialsCommand
if (matchWildcards && (searchTerm.contentEquals("**") || searchTerm.contentEquals("*")))
{
- for (Player onlinePlayer : server.getOnlinePlayers())
+ for (User onlineUser : ess.getOnlineUsers())
{
- final User onlineUser = ess.getUser(onlinePlayer);
- if (skipHidden && onlineUser.isHidden(sender.getPlayer()) && !sender.getPlayer().canSee(onlinePlayer))
+ if (skipHidden && onlineUser.isHidden(sender.getPlayer()) && !sender.getPlayer().canSee(onlineUser.getBase()))
{
continue;
}
@@ -107,10 +105,9 @@ public abstract class EssentialsLoopCommand extends EssentialsCommand
if (matchedPlayers.isEmpty())
{
final String matchText = searchTerm.toLowerCase(Locale.ENGLISH);
- for (Player onlinePlayer : server.getOnlinePlayers())
+ for (User player : ess.getOnlineUsers())
{
- final User player = ess.getUser(onlinePlayer);
- if (skipHidden && player.isHidden(sender.getPlayer()) && !sender.getPlayer().canSee(onlinePlayer))
+ if (skipHidden && player.isHidden(sender.getPlayer()) && !sender.getPlayer().canSee(player.getBase()))
{
continue;
}
diff --git a/Essentials/src/com/earth2me/essentials/metrics/Metrics.java b/Essentials/src/com/earth2me/essentials/metrics/Metrics.java
index 5ecf9c60d..07229f091 100644
--- a/Essentials/src/com/earth2me/essentials/metrics/Metrics.java
+++ b/Essentials/src/com/earth2me/essentials/metrics/Metrics.java
@@ -24,6 +24,7 @@ package com.earth2me.essentials.metrics;
* should not be interpreted as representing official policies, either expressed or implied, of anybody else.
*/
+import com.earth2me.essentials.IEssentials;
import java.io.*;
import java.net.Proxy;
import java.net.URL;
@@ -352,7 +353,7 @@ public class Metrics
boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE if online mode is enabled
String pluginVersion = description.getVersion();
String serverVersion = Bukkit.getVersion();
- int playersOnline = Bukkit.getServer().getOnlinePlayers().length;
+ int playersOnline = ((IEssentials)plugin).getOnlinePlayers().size();
// END server software specific section -- all code below does not use any code outside of this class / Java
diff --git a/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java b/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java
index 111c1b3cd..3395a4b7f 100644
--- a/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java
+++ b/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java
@@ -166,14 +166,14 @@ public class KeywordReplacer implements IText
break;
case ONLINE:
int playerHidden = 0;
- for (Player p : ess.getServer().getOnlinePlayers())
+ for (User u : ess.getOnlineUsers())
{
- if (ess.getUser(p).isHidden())
+ if (u.isHidden())
{
playerHidden++;
}
}
- replacer = Integer.toString(ess.getServer().getOnlinePlayers().length - playerHidden);
+ replacer = Integer.toString(ess.getOnlinePlayers().size() - playerHidden);
break;
case UNIQUE:
replacer = Integer.toString(ess.getUserMap().getUniqueUsers());
diff --git a/Essentials/test/com/earth2me/essentials/FakeServer.java b/Essentials/test/com/earth2me/essentials/FakeServer.java
index ca989f21a..e11d4ab76 100644
--- a/Essentials/test/com/earth2me/essentials/FakeServer.java
+++ b/Essentials/test/com/earth2me/essentials/FakeServer.java
@@ -74,11 +74,17 @@ public class FakeServer implements Server
}
@Override
- public Player[] getOnlinePlayers()
+ public Player[] _INVALID_getOnlinePlayers()
{
return players.toArray(new Player[0]);
}
+ @Override
+ public Collection<? extends Player> getOnlinePlayers()
+ {
+ return players;
+ }
+
public void setOnlinePlayers(List<Player> players)
{
this.players = players;
diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java
index ab7cf986c..f1a2cd21d 100644
--- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java
+++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java
@@ -149,4 +149,10 @@ public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP
// Ignore exceptions
}
}
+
+ @Override
+ public IEssentials getEss()
+ {
+ return ess;
+ }
}
diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/IEssentialsXMPP.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/IEssentialsXMPP.java
index df329156d..cdc964cb1 100644
--- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/IEssentialsXMPP.java
+++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/IEssentialsXMPP.java
@@ -1,5 +1,6 @@
package com.earth2me.essentials.xmpp;
+import com.earth2me.essentials.IEssentials;
import net.ess3.api.IUser;
import java.util.List;
import org.bukkit.entity.Player;
@@ -25,4 +26,6 @@ public interface IEssentialsXMPP extends Plugin
boolean toggleSpy(final Player user);
void broadcastMessage(final IUser sender, final String message, final String xmppAddress);
+
+ IEssentials getEss();
}
diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java
index 3d82670d1..a0ffd72e1 100644
--- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java
+++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java
@@ -163,7 +163,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
final int usercount;
final StringBuilder stringBuilder = new StringBuilder();
- usercount = parent.getServer().getOnlinePlayers().length;
+ usercount = parent.getEss().getOnlinePlayers().size();
if (usercount == 0)
{
diff --git a/lib/bukkit.jar b/lib/bukkit.jar
index 9b8f8bae2..8f98d73d6 100644
--- a/lib/bukkit.jar
+++ b/lib/bukkit.jar
Binary files differ
diff --git a/lib/craftbukkit.jar b/lib/craftbukkit.jar
index b7cd2968d..4d8c0650d 100644
--- a/lib/craftbukkit.jar
+++ b/lib/craftbukkit.jar
Binary files differ