Allow explicitly hiding or unhiding with /lb hide <on/off>. Addresses #526

This commit is contained in:
Ammar Askar
2015-03-20 20:29:08 +05:00
parent a719891f74
commit 1f5b7fed7c
2 changed files with 24 additions and 5 deletions

View File

@@ -189,10 +189,21 @@ public class CommandsHandler implements CommandExecutor
} else if (command.equals("hide")) { } else if (command.equals("hide")) {
if (sender instanceof Player) { if (sender instanceof Player) {
if (logblock.hasPermission(sender, "logblock.hide")) { if (logblock.hasPermission(sender, "logblock.hide")) {
if (Consumer.hide((Player)sender)) if (args.length == 2) {
sender.sendMessage(ChatColor.GREEN + "You are now hidden and aren't logged. Type '/lb hide' again to unhide"); if (args[1].equalsIgnoreCase("on")) {
else Consumer.hide((Player) sender);
sender.sendMessage(ChatColor.GREEN + "You aren't hidden anylonger."); sender.sendMessage(ChatColor.GREEN + "You are now hidden and aren't logged. Type /lb hide to unhide.");
} else if (args[1].equalsIgnoreCase("off")) {
Consumer.unHide((Player) sender);
sender.sendMessage(ChatColor.GREEN + "You aren't hidden any longer.");
}
} else {
if (Consumer.toggleHide((Player) sender)) {
sender.sendMessage(ChatColor.GREEN + "You are now hidden and aren't logged. Type '/lb hide' again to unhide.");
} else {
sender.sendMessage(ChatColor.GREEN + "You aren't hidden any longer.");
}
}
} else } else
sender.sendMessage(ChatColor.RED + "You aren't allowed to do this."); sender.sendMessage(ChatColor.RED + "You aren't allowed to do this.");
} else } else

View File

@@ -396,7 +396,15 @@ public class Consumer extends TimerTask
return queue.size(); return queue.size();
} }
static boolean hide(Player player) { static void hide(Player player) {
hiddenPlayers.add(player.getName().toLowerCase());
}
static void unHide(Player player) {
hiddenPlayers.remove(player.getName().toLowerCase());
}
static boolean toggleHide(Player player) {
final String playerName = player.getName().toLowerCase(); final String playerName = player.getName().toLowerCase();
if (hiddenPlayers.contains(playerName)) { if (hiddenPlayers.contains(playerName)) {
hiddenPlayers.remove(playerName); hiddenPlayers.remove(playerName);