Only loop through op players when tab completing /deop Fixes BUKKIT-5748

When tab completing /deop, a potentially large set of players is used for
finding suitable player names. This potentially large set of players can
cause performance concerns on servers. To fix this, only the set of
operators should be considered for the /deop tab completion where the
player set is much more relevant and follows suit with other commands
which employ "more specific" player sets when possible. This commit adds
this more efficient behaviour.
This commit is contained in:
bendem
2014-08-06 20:29:26 +02:00
committed by turt2live
parent 8d5b4c1e9a
commit 93732941ac

View File

@@ -49,9 +49,9 @@ public class DeopCommand extends VanillaCommand {
if (args.length == 1) {
List<String> completions = new ArrayList<String>();
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
for (OfflinePlayer player : Bukkit.getOperators()) {
String playerName = player.getName();
if (player.isOp() && StringUtil.startsWithIgnoreCase(playerName, args[0])) {
if (StringUtil.startsWithIgnoreCase(playerName, args[0])) {
completions.add(playerName);
}
}