From 091dc495d40d0dd7c0936b4c8553618f8f2a7d56 Mon Sep 17 00:00:00 2001 From: Marco Cunha Date: Sat, 25 Aug 2012 03:09:11 +0200 Subject: [PATCH] Mute/Unmute fixes --- .../palmergames/bukkit/TownyChat/Chat.java | 4 ++-- .../TownyChat/Command/ChannelCommand.java | 4 ++-- .../bukkit/TownyChat/Command/MuteCommand.java | 21 +++++++++-------- .../TownyChat/Command/UnmuteCommand.java | 23 ++++++++++--------- src/plugin.yml | 9 ++++---- 5 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/com/palmergames/bukkit/TownyChat/Chat.java b/src/com/palmergames/bukkit/TownyChat/Chat.java index 8b4e488..42fb7b7 100644 --- a/src/com/palmergames/bukkit/TownyChat/Chat.java +++ b/src/com/palmergames/bukkit/TownyChat/Chat.java @@ -77,8 +77,8 @@ public class Chat extends JavaPlugin { getCommand("channel").setExecutor(new ChannelCommand(this)); getCommand("join").setExecutor(new JoinCommand(this)); getCommand("leave").setExecutor(new LeaveCommand(this)); - getCommand("mute").setExecutor(new MuteCommand(this)); - getCommand("unmute").setExecutor(new UnmuteCommand(this)); + getCommand("chmute").setExecutor(new MuteCommand(this)); + getCommand("chunmute").setExecutor(new UnmuteCommand(this)); getCommand("mutelist").setExecutor(new MuteListCommand(this)); } diff --git a/src/com/palmergames/bukkit/TownyChat/Command/ChannelCommand.java b/src/com/palmergames/bukkit/TownyChat/Command/ChannelCommand.java index ebc1da2..245fbff 100644 --- a/src/com/palmergames/bukkit/TownyChat/Command/ChannelCommand.java +++ b/src/com/palmergames/bukkit/TownyChat/Command/ChannelCommand.java @@ -33,11 +33,11 @@ public class ChannelCommand implements CommandExecutor { } if (args[0].equalsIgnoreCase("mute")) { - return plugin.getCommand("mute").getExecutor().onCommand(sender, cmd, label, args); + return plugin.getCommand("chmute").getExecutor().onCommand(sender, cmd, label, args); } if (args[0].equalsIgnoreCase("unmute")) { - return plugin.getCommand("unmute").getExecutor().onCommand(sender, cmd, label, args); + return plugin.getCommand("chunmute").getExecutor().onCommand(sender, cmd, label, args); } if (args[0].equalsIgnoreCase("mutelist")) { diff --git a/src/com/palmergames/bukkit/TownyChat/Command/MuteCommand.java b/src/com/palmergames/bukkit/TownyChat/Command/MuteCommand.java index b568d8d..adb96f7 100644 --- a/src/com/palmergames/bukkit/TownyChat/Command/MuteCommand.java +++ b/src/com/palmergames/bukkit/TownyChat/Command/MuteCommand.java @@ -23,6 +23,7 @@ public class MuteCommand implements CommandExecutor { public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { // If not our command if ((!label.equalsIgnoreCase("mute") || args.length != 2) && + (!label.equalsIgnoreCase("chmute") || args.length != 2) && (!label.equalsIgnoreCase("ch") || args.length != 3 || !args[0].equalsIgnoreCase("mute"))) { TownyMessaging.sendErrorMsg(sender, "[TownyChat] Error: Invalid command!"); return false; @@ -34,14 +35,14 @@ public class MuteCommand implements CommandExecutor { Player player = ((Player)sender); - String name = null; + String channelName = null; String mutee = null; - if (label.equalsIgnoreCase("mute")){ - name = args[0]; + if (label.equalsIgnoreCase("chmute") || label.equalsIgnoreCase("mute")){ + channelName = args[0]; mutee = args[1]; } else { - name = args[1]; - mutee = args[1]; + channelName = args[1]; + mutee = args[2]; } String mutePerm = plugin.getChannelsHandler().getMutePermission(); @@ -70,13 +71,13 @@ public class MuteCommand implements CommandExecutor { return true; } - Channel chan = plugin.getChannelsHandler().getChannel(name); + Channel chan = plugin.getChannelsHandler().getChannel(channelName); // If we can't find the channel by name, look up all the channel commands for an alias if (chan == null) { for(Channel chan2 : plugin.getChannelsHandler().getAllChannels().values()) { for (String command : chan2.getCommands()) { - if (command.equalsIgnoreCase(name)) { + if (command.equalsIgnoreCase(channelName)) { chan = chan2; break; } @@ -88,17 +89,17 @@ public class MuteCommand implements CommandExecutor { } if (chan == null) { - TownyMessaging.sendErrorMsg(sender, "[TownyChat] There is no channel called " + Colors.White + name); + TownyMessaging.sendErrorMsg(sender, "[TownyChat] There is no channel called " + Colors.White + channelName); return true; } - if (!chan.mute(name)) { + if (!chan.mute(mutee)) { TownyMessaging.sendMsg(sender, "[TownyChat] Player is already muted in "+ Colors.White + chan.getName()); return true; } - TownyMessaging.sendMsg(sender, "[TownyChat] " + Colors.White + name + Colors.Green +" is now muted in "+ Colors.White + chan.getName()); + TownyMessaging.sendMsg(sender, "[TownyChat] " + Colors.White + mutee + Colors.Green +" is now muted in "+ Colors.White + chan.getName()); return true; } } diff --git a/src/com/palmergames/bukkit/TownyChat/Command/UnmuteCommand.java b/src/com/palmergames/bukkit/TownyChat/Command/UnmuteCommand.java index 0528660..d1f7ede 100644 --- a/src/com/palmergames/bukkit/TownyChat/Command/UnmuteCommand.java +++ b/src/com/palmergames/bukkit/TownyChat/Command/UnmuteCommand.java @@ -22,7 +22,8 @@ public class UnmuteCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { // If not our command - if ((!label.equalsIgnoreCase("unmute") || args.length != 2) && + if ((!label.equalsIgnoreCase("unmute") || args.length != 2) && + (!label.equalsIgnoreCase("chunmute") || args.length != 2) && (!label.equalsIgnoreCase("ch") || args.length != 3 || !args[0].equalsIgnoreCase("unmute"))) { TownyMessaging.sendErrorMsg(sender, "[TownyChat] Error: Invalid command!"); return false; @@ -34,14 +35,14 @@ public class UnmuteCommand implements CommandExecutor { Player player = ((Player)sender); - String name = null; + String channelName = null; String mutee = null; - if (label.equalsIgnoreCase("unmute")){ - name = args[0]; + if (label.equalsIgnoreCase("chunmute") || label.equalsIgnoreCase("unmute")){ + channelName = args[0]; mutee = args[1]; } else { - name = args[1]; - mutee = args[1]; + channelName = args[1]; + mutee = args[2]; } String unmutePerm = plugin.getChannelsHandler().getUnmutePermission(); @@ -58,13 +59,13 @@ public class UnmuteCommand implements CommandExecutor { mutee = muteePlayer.getName(); - Channel chan = plugin.getChannelsHandler().getChannel(name); + Channel chan = plugin.getChannelsHandler().getChannel(channelName); // If we can't find the channel by name, look up all the channel commands for an alias if (chan == null) { for(Channel chan2 : plugin.getChannelsHandler().getAllChannels().values()) { for (String command : chan2.getCommands()) { - if (command.equalsIgnoreCase(name)) { + if (command.equalsIgnoreCase(channelName)) { chan = chan2; break; } @@ -76,17 +77,17 @@ public class UnmuteCommand implements CommandExecutor { } if (chan == null) { - TownyMessaging.sendErrorMsg(sender, "[TownyChat] There is no channel called " + Colors.White + name); + TownyMessaging.sendErrorMsg(sender, "[TownyChat] There is no channel called " + Colors.White + channelName); return true; } - if (!chan.mute(name)) { + if (!chan.mute(mutee)) { TownyMessaging.sendMsg(sender, "[TownyChat] Player is not muted in "+ Colors.White + chan.getName()); return true; } - TownyMessaging.sendMsg(sender, "[TownyChat] " + Colors.White + name + Colors.Green +" is now muted in "+ Colors.White + chan.getName()); + TownyMessaging.sendMsg(sender, "[TownyChat] " + Colors.White + mutee + Colors.Green +" is now muted in "+ Colors.White + chan.getName()); return true; } } diff --git a/src/plugin.yml b/src/plugin.yml index 708c177..d2bc1bf 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -23,22 +23,21 @@ commands: description: Channel leaving and joining usage: / leave|join channel leave: - aliases: [ch leave] description: Leaves a channel usage: / channel join: - aliases: [ch join] description: Joins a channel usage: / channel - mute: + chmute: + aliases: [mute] description: Mutes a player in a channel usage: / channel player permission: townychat.mod.mute mutelist: description: Displays mute list for a channel usage: / channel - permission: townychat.mod.list.mute - unmute: + chunmute: + aliases: [unmute] description: Unmutes a player in a channel usage: / channel player permission: townychat.mod.unmute