From 92d63180f99760dba2cf523b269b58e6b3f8735d Mon Sep 17 00:00:00 2001 From: ZeroEpoch1969 <13510767+ZeroEpoch1969@users.noreply.github.com> Date: Fri, 29 Jun 2018 10:49:06 -0700 Subject: [PATCH] Add a silent option for the vanish command --- .../command/Command_vanish.java | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java index a96ddf55..da74105a 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java @@ -15,17 +15,25 @@ import java.util.ArrayList; import me.totalfreedom.totalfreedommod.rank.Rank; @CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME) -@CommandParameters(description = "Vanish/unvanish yourself.", usage = "/", aliases = "v") +@CommandParameters(description = "Vanish/unvanish yourself.", usage = "/ [-s[ilent]]", aliases = "v") public class Command_vanish extends FreedomCommand { public static ArrayList VANISHED = new ArrayList(); - + public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole) { Displayable display = plugin.rm.getDisplay(playerSender); String loginMsg = display.getColoredLoginMessage(); String displayName = display.getColor() + playerSender.getName(); String tag = display.getColoredTag(); Admin admin = plugin.al.getAdmin(playerSender); + boolean silent = false; + if (args.length > 0) + { + if (args[0].equalsIgnoreCase("-s") || args[0].equalsIgnoreCase("-silent")) + { + silent = true; + } + } if (VANISHED.contains(playerSender)) { msg(ChatColor.GOLD + "You have been unvanished."); @@ -33,8 +41,11 @@ public class Command_vanish extends FreedomCommand { loginMsg = FUtil.colorize(admin.getLoginMessage()); } - FUtil.bcastMsg(ChatColor.AQUA + playerSender.getName() + " is " + loginMsg); - FUtil.bcastMsg(playerSender.getName() + " joined the game", ChatColor.YELLOW); + if (!silent) + { + FUtil.bcastMsg(ChatColor.AQUA + playerSender.getName() + " is " + loginMsg); + FUtil.bcastMsg(playerSender.getName() + " joined the game", ChatColor.YELLOW); + } if (admin.getTag() != null) { tag = FUtil.colorize(admin.getTag()); @@ -56,7 +67,10 @@ public class Command_vanish extends FreedomCommand else { msg("You have been vanished.", ChatColor.GOLD); - FUtil.bcastMsg(playerSender.getName() + " left the game", ChatColor.YELLOW); + if (!silent) + { + FUtil.bcastMsg(playerSender.getName() + " left the game", ChatColor.YELLOW); + } FLog.info(playerSender.getName() + " is now vanished."); for (Player player : server.getOnlinePlayers()) {