Skip to content

Commit

Permalink
Only loop through op players when tab completing /deop Fixes BUKKIT-5748
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bendem authored and turt2live committed Aug 17, 2014
1 parent 8d5b4c1 commit 9373294
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/bukkit/command/defaults/DeopCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public List<String> tabComplete(CommandSender sender, String alias, String[] arg

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);
}
}
Expand Down

0 comments on commit 9373294

Please sign in to comment.