Don't tab-complete hidden players, fixes #339

This commit is contained in:
libraryaddict 2019-02-03 13:45:42 +13:00
parent 3edd1248ef
commit 294c944b12
10 changed files with 91 additions and 11 deletions

View File

@ -3,8 +3,8 @@ package me.libraryaddict.disguise.commands;
import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions; import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -74,6 +74,11 @@ public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabComp
if (args.length == 0) { if (args.length == 0) {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
// If command user cannot see player online, don't tab-complete name
if (sender instanceof Player && !((Player) sender).canSee(player)) {
continue;
}
tabs.add(player.getName()); tabs.add(player.getName());
} }
} }

View File

@ -6,9 +6,9 @@ import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.DisguiseType; import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import me.libraryaddict.disguise.utilities.parser.*; import me.libraryaddict.disguise.utilities.parser.*;
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo; import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -113,6 +113,11 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter
if (args.length == 1 && disguiseType.getType() == DisguiseType.PLAYER) { if (args.length == 1 && disguiseType.getType() == DisguiseType.PLAYER) {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
// If command user cannot see player online, don't tab-complete name
if (sender instanceof Player && !((Player) sender).canSee(player)) {
continue;
}
tabs.add(player.getName()); tabs.add(player.getName());
} }
} else { } else {
@ -146,6 +151,11 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter
tabs.addAll(info.getEnums(origArgs[origArgs.length - 1])); tabs.addAll(info.getEnums(origArgs[origArgs.length - 1]));
} else if (info.isParam(String.class)) { } else if (info.isParam(String.class)) {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
// If command user cannot see player online, don't tab-complete name
if (sender instanceof Player && !((Player) sender).canSee(player)) {
continue;
}
tabs.add(player.getName()); tabs.add(player.getName());
} }
} }

View File

@ -5,9 +5,9 @@ import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.DisguiseType; import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import me.libraryaddict.disguise.utilities.parser.*; import me.libraryaddict.disguise.utilities.parser.*;
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo; import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -89,6 +89,11 @@ public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCom
if (args.length == 1 && disguiseType.getType() == DisguiseType.PLAYER) { if (args.length == 1 && disguiseType.getType() == DisguiseType.PLAYER) {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
// If command user cannot see player online, don't tab-complete name
if (sender instanceof Player && !((Player) sender).canSee(player)) {
continue;
}
tabs.add(player.getName()); tabs.add(player.getName());
} }
} else { } else {
@ -122,6 +127,11 @@ public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCom
tabs.addAll(info.getEnums(origArgs[origArgs.length - 1])); tabs.addAll(info.getEnums(origArgs[origArgs.length - 1]));
} else if (info.isParam(String.class)) { } else if (info.isParam(String.class)) {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
// If command user cannot see player online, don't tab-complete name
if (sender instanceof Player && !((Player) sender).canSee(player)) {
continue;
}
tabs.add(player.getName()); tabs.add(player.getName());
} }
} }

View File

@ -4,9 +4,9 @@ import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.DisguiseType; import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import me.libraryaddict.disguise.utilities.parser.*; import me.libraryaddict.disguise.utilities.parser.*;
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo; import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -123,6 +123,11 @@ public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCom
tabs.addAll(info.getEnums(origArgs[origArgs.length - 1])); tabs.addAll(info.getEnums(origArgs[origArgs.length - 1]));
} else if (info.isParam(String.class)) { } else if (info.isParam(String.class)) {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
// If command user cannot see player online, don't tab-complete name
if (sender instanceof Player && !((Player) sender).canSee(player)) {
continue;
}
tabs.add(player.getName()); tabs.add(player.getName());
} }
} }

View File

@ -3,11 +3,11 @@ package me.libraryaddict.disguise.commands;
import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import me.libraryaddict.disguise.utilities.parser.DisguisePerm; import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions; import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
import me.libraryaddict.disguise.utilities.parser.ParamInfoManager; import me.libraryaddict.disguise.utilities.parser.ParamInfoManager;
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo; import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -82,6 +82,11 @@ public class DisguiseModifyEntityCommand extends DisguiseBaseCommand implements
tabs.addAll(info.getEnums(origArgs[origArgs.length - 1])); tabs.addAll(info.getEnums(origArgs[origArgs.length - 1]));
} else if (info.isParam(String.class)) { } else if (info.isParam(String.class)) {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
// If command user cannot see player online, don't tab-complete name
if (sender instanceof Player && !((Player) sender).canSee(player)) {
continue;
}
tabs.add(player.getName()); tabs.add(player.getName());
} }
} }

View File

@ -103,6 +103,11 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements
if (args.length == 0) { if (args.length == 0) {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
// If command user cannot see player online, don't tab-complete name
if (sender instanceof Player && !((Player) sender).canSee(player)) {
continue;
}
tabs.add(player.getName()); tabs.add(player.getName());
} }
} else { } else {
@ -158,6 +163,11 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements
tabs.addAll(info.getEnums(origArgs[origArgs.length - 1])); tabs.addAll(info.getEnums(origArgs[origArgs.length - 1]));
} else if (info.isParam(String.class)) { } else if (info.isParam(String.class)) {
for (Player p : Bukkit.getOnlinePlayers()) { for (Player p : Bukkit.getOnlinePlayers()) {
// If command user cannot see player online, don't tab-complete name
if (sender instanceof Player && !((Player) sender).canSee(p)) {
continue;
}
tabs.add(p.getName()); tabs.add(p.getName());
} }
} }

View File

@ -4,10 +4,10 @@ import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.DisguiseType; import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import me.libraryaddict.disguise.utilities.translations.TranslateType;
import me.libraryaddict.disguise.utilities.parser.*; import me.libraryaddict.disguise.utilities.parser.*;
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo; import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import me.libraryaddict.disguise.utilities.translations.TranslateType;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -261,6 +261,11 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
tabs.addAll(info.getEnums(origArgs[origArgs.length - 1])); tabs.addAll(info.getEnums(origArgs[origArgs.length - 1]));
} else if (info.isParam(String.class)) { } else if (info.isParam(String.class)) {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
// If command user cannot see player online, don't tab-complete name
if (sender instanceof Player && !((Player) sender).canSee(player)) {
continue;
}
tabs.add(player.getName()); tabs.add(player.getName());
} }
} }

View File

@ -6,9 +6,9 @@ import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.DisguiseType; import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import me.libraryaddict.disguise.utilities.parser.*; import me.libraryaddict.disguise.utilities.parser.*;
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo; import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -146,6 +146,11 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
if (args.length == 0) { if (args.length == 0) {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
// If command user cannot see player online, don't tab-complete name
if (sender instanceof Player && !((Player) sender).canSee(player)) {
continue;
}
tabs.add(player.getName()); tabs.add(player.getName());
} }
} else if (args.length == 1) { } else if (args.length == 1) {
@ -158,6 +163,11 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
if (args.length == 2 && disguiseType.getType() == DisguiseType.PLAYER) { if (args.length == 2 && disguiseType.getType() == DisguiseType.PLAYER) {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
// If command user cannot see player online, don't tab-complete name
if (sender instanceof Player && !((Player) sender).canSee(player)) {
continue;
}
tabs.add(player.getName()); tabs.add(player.getName());
} }
} else { } else {
@ -191,6 +201,11 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
tabs.addAll(info.getEnums(origArgs[origArgs.length - 1])); tabs.addAll(info.getEnums(origArgs[origArgs.length - 1]));
} else if (info.isParam(String.class)) { } else if (info.isParam(String.class)) {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
// If command user cannot see player online, don't tab-complete name
if (sender instanceof Player && !((Player) sender).canSee(player)) {
continue;
}
tabs.add(player.getName()); tabs.add(player.getName());
} }
} }

View File

@ -5,12 +5,12 @@ import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.DisguiseType; import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
import me.libraryaddict.disguise.utilities.reflection.ClassGetter;
import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import me.libraryaddict.disguise.utilities.translations.TranslateType;
import me.libraryaddict.disguise.utilities.parser.*; import me.libraryaddict.disguise.utilities.parser.*;
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo; import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
import me.libraryaddict.disguise.utilities.reflection.ClassGetter;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import me.libraryaddict.disguise.utilities.translations.TranslateType;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -269,6 +269,11 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
if (args.length == 1 + starting && disguiseType.getType() == DisguiseType.PLAYER) { if (args.length == 1 + starting && disguiseType.getType() == DisguiseType.PLAYER) {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
// If command user cannot see player online, don't tab-complete name
if (sender instanceof Player && !((Player) sender).canSee(player)) {
continue;
}
tabs.add(player.getName()); tabs.add(player.getName());
} }
} else { } else {
@ -303,6 +308,11 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
tabs.addAll(info.getEnums(origArgs[origArgs.length - 1])); tabs.addAll(info.getEnums(origArgs[origArgs.length - 1]));
} else if (info.isParam(String.class)) { } else if (info.isParam(String.class)) {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
// If command user cannot see player online, don't tab-complete name
if (sender instanceof Player && !((Player) sender).canSee(player)) {
continue;
}
tabs.add(player.getName()); tabs.add(player.getName());
} }
} }

View File

@ -99,6 +99,11 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
return filterTabs(tabs, origArgs); return filterTabs(tabs, origArgs);
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
// If command user cannot see player online, don't tab-complete name
if (sender instanceof Player && !((Player) sender).canSee(player)) {
continue;
}
tabs.add(player.getName()); tabs.add(player.getName());
} }