Added toggle to deathmute command

master
Joey Hines 2018-10-29 18:11:37 -05:00
parent 1e6b917fa2
commit 86419f8772
2 changed files with 15 additions and 5 deletions

View File

@ -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;
}
}

View File

@ -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 <player>");
EtzTechUtil.sms(commandSender, ChatColor.RED + "/deathmute <player>");
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;
}