From 86419f8772e4f1fa6907f1ea71bf05fead722416 Mon Sep 17 00:00:00 2001 From: Joey Hines Date: Mon, 29 Oct 2018 18:11:37 -0500 Subject: [PATCH] Added toggle to deathmute command --- src/main/java/xyz/etztech/qol/QoL.java | 6 +++++- .../xyz/etztech/qol/commands/DeathMuteCommand.java | 14 ++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/java/xyz/etztech/qol/QoL.java b/src/main/java/xyz/etztech/qol/QoL.java index b731f2e..bc88a4d 100644 --- a/src/main/java/xyz/etztech/qol/QoL.java +++ b/src/main/java/xyz/etztech/qol/QoL.java @@ -220,9 +220,13 @@ public class QoL extends JavaPlugin { } } - public static void addDeathMute(Player player) { + public static boolean addDeathMute(Player player) { if (!deathMutes.contains(player.getUniqueId())) { deathMutes.add(player.getUniqueId()); + return true; + } else { + deathMutes.remove(player.getUniqueId()); + return false; } } diff --git a/src/main/java/xyz/etztech/qol/commands/DeathMuteCommand.java b/src/main/java/xyz/etztech/qol/commands/DeathMuteCommand.java index d885c56..2e5fe47 100644 --- a/src/main/java/xyz/etztech/qol/commands/DeathMuteCommand.java +++ b/src/main/java/xyz/etztech/qol/commands/DeathMuteCommand.java @@ -21,13 +21,15 @@ public class DeathMuteCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) { + String message; + if (!commandSender.hasPermission("qol.deathmute")) { EtzTechUtil.sms(commandSender, Lang.NO_PERMISSION.getDef()); return true; } if (args.length < 1) { - EtzTechUtil.sms(commandSender, ChatColor.RED + "/dm "); + EtzTechUtil.sms(commandSender, ChatColor.RED + "/deathmute "); return true; } @@ -40,10 +42,14 @@ public class DeathMuteCommand implements CommandExecutor { final Player player = argPlayer; - EtzTechUtil.sms(commandSender, ChatColor.GREEN + "Death Muting " + ChatColor.YELLOW + - player.getName()); + if (QoL.addDeathMute(player)) { + message = ChatColor.GREEN + "Muting death messages from" + ChatColor.YELLOW + player.getName(); + } else { + message = ChatColor.GREEN + "Unmuting death messages from" + ChatColor.YELLOW + player.getName(); + } + + EtzTechUtil.sms(commandSender, message); - QoL.addDeathMute(player); return true; }