Mute/Unmute fixes

This commit is contained in:
Marco Cunha committed 2012-08-25 03:09:11 +02:00
1 parent 19f50b982a
commit 091dc495d4
5 files changed
+30 -29

No files matched your search

@@ -77,8 +77,8 @@ public class Chat extends JavaPlugin {
getCommand("channel").setExecutor(new ChannelCommand(this)); getCommand("channel").setExecutor(new ChannelCommand(this));
getCommand("join").setExecutor(new JoinCommand(this)); getCommand("join").setExecutor(new JoinCommand(this));
getCommand("leave").setExecutor(new LeaveCommand(this)); getCommand("leave").setExecutor(new LeaveCommand(this));
getCommand("mute").setExecutor(new MuteCommand(this)); getCommand("chmute").setExecutor(new MuteCommand(this));
getCommand("unmute").setExecutor(new UnmuteCommand(this)); getCommand("chunmute").setExecutor(new UnmuteCommand(this));
getCommand("mutelist").setExecutor(new MuteListCommand(this)); getCommand("mutelist").setExecutor(new MuteListCommand(this));
} }
@@ -33,11 +33,11 @@ public class ChannelCommand implements CommandExecutor {
} }
if (args[0].equalsIgnoreCase("mute")) { 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")) { 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")) { if (args[0].equalsIgnoreCase("mutelist")) {
@@ -23,6 +23,7 @@ public class MuteCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
// If not our command // If not our command
if ((!label.equalsIgnoreCase("mute") || args.length != 2) && if ((!label.equalsIgnoreCase("mute") || args.length != 2) &&
(!label.equalsIgnoreCase("chmute") || args.length != 2) &&
(!label.equalsIgnoreCase("ch") || args.length != 3 || !args[0].equalsIgnoreCase("mute"))) { (!label.equalsIgnoreCase("ch") || args.length != 3 || !args[0].equalsIgnoreCase("mute"))) {
TownyMessaging.sendErrorMsg(sender, "[TownyChat] Error: Invalid command!"); TownyMessaging.sendErrorMsg(sender, "[TownyChat] Error: Invalid command!");
return false; return false;
@@ -34,14 +35,14 @@ public class MuteCommand implements CommandExecutor {
Player player = ((Player)sender); Player player = ((Player)sender);
String name = null; String channelName = null;
String mutee = null; String mutee = null;
if (label.equalsIgnoreCase("mute")){ if (label.equalsIgnoreCase("chmute") || label.equalsIgnoreCase("mute")){
name = args[0]; channelName = args[0];
mutee = args[1]; mutee = args[1];
} else { } else {
name = args[1]; channelName = args[1];
mutee = args[1]; mutee = args[2];
} }
String mutePerm = plugin.getChannelsHandler().getMutePermission(); String mutePerm = plugin.getChannelsHandler().getMutePermission();
@@ -70,13 +71,13 @@ public class MuteCommand implements CommandExecutor {
return true; 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 we can't find the channel by name, look up all the channel commands for an alias
if (chan == null) { if (chan == null) {
for(Channel chan2 : plugin.getChannelsHandler().getAllChannels().values()) { for(Channel chan2 : plugin.getChannelsHandler().getAllChannels().values()) {
for (String command : chan2.getCommands()) { for (String command : chan2.getCommands()) {
if (command.equalsIgnoreCase(name)) { if (command.equalsIgnoreCase(channelName)) {
chan = chan2; chan = chan2;
break; break;
} }
@@ -88,17 +89,17 @@ public class MuteCommand implements CommandExecutor {
} }
if (chan == null) { 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; return true;
} }
if (!chan.mute(name)) { if (!chan.mute(mutee)) {
TownyMessaging.sendMsg(sender, "[TownyChat] Player is already muted in "+ Colors.White + chan.getName()); TownyMessaging.sendMsg(sender, "[TownyChat] Player is already muted in "+ Colors.White + chan.getName());
return true; 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; return true;
} }
} }
@@ -23,6 +23,7 @@ public class UnmuteCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
// If not our command // 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"))) { (!label.equalsIgnoreCase("ch") || args.length != 3 || !args[0].equalsIgnoreCase("unmute"))) {
TownyMessaging.sendErrorMsg(sender, "[TownyChat] Error: Invalid command!"); TownyMessaging.sendErrorMsg(sender, "[TownyChat] Error: Invalid command!");
return false; return false;
@@ -34,14 +35,14 @@ public class UnmuteCommand implements CommandExecutor {
Player player = ((Player)sender); Player player = ((Player)sender);
String name = null; String channelName = null;
String mutee = null; String mutee = null;
if (label.equalsIgnoreCase("unmute")){ if (label.equalsIgnoreCase("chunmute") || label.equalsIgnoreCase("unmute")){
name = args[0]; channelName = args[0];
mutee = args[1]; mutee = args[1];
} else { } else {
name = args[1]; channelName = args[1];
mutee = args[1]; mutee = args[2];
} }
String unmutePerm = plugin.getChannelsHandler().getUnmutePermission(); String unmutePerm = plugin.getChannelsHandler().getUnmutePermission();
@@ -58,13 +59,13 @@ public class UnmuteCommand implements CommandExecutor {
mutee = muteePlayer.getName(); 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 we can't find the channel by name, look up all the channel commands for an alias
if (chan == null) { if (chan == null) {
for(Channel chan2 : plugin.getChannelsHandler().getAllChannels().values()) { for(Channel chan2 : plugin.getChannelsHandler().getAllChannels().values()) {
for (String command : chan2.getCommands()) { for (String command : chan2.getCommands()) {
if (command.equalsIgnoreCase(name)) { if (command.equalsIgnoreCase(channelName)) {
chan = chan2; chan = chan2;
break; break;
} }
@@ -76,17 +77,17 @@ public class UnmuteCommand implements CommandExecutor {
} }
if (chan == null) { 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; return true;
} }
if (!chan.mute(name)) { if (!chan.mute(mutee)) {
TownyMessaging.sendMsg(sender, "[TownyChat] Player is not muted in "+ Colors.White + chan.getName()); TownyMessaging.sendMsg(sender, "[TownyChat] Player is not muted in "+ Colors.White + chan.getName());
return true; 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; return true;
} }
} }
+4 -5
View File
@@ -23,22 +23,21 @@ commands:
description: Channel leaving and joining description: Channel leaving and joining
usage: /<command> leave|join channel usage: /<command> leave|join channel
leave: leave:
aliases: [ch leave]
description: Leaves a channel description: Leaves a channel
usage: /<command> channel usage: /<command> channel
join: join:
aliases: [ch join]
description: Joins a channel description: Joins a channel
usage: /<command> channel usage: /<command> channel
mute: chmute:
aliases: [mute]
description: Mutes a player in a channel description: Mutes a player in a channel
usage: /<command> channel player usage: /<command> channel player
permission: townychat.mod.mute permission: townychat.mod.mute
mutelist: mutelist:
description: Displays mute list for a channel description: Displays mute list for a channel
usage: /<command> channel usage: /<command> channel
permission: townychat.mod.list.mute chunmute:
unmute: aliases: [unmute]
description: Unmutes a player in a channel description: Unmutes a player in a channel
usage: /<command> channel player usage: /<command> channel player
permission: townychat.mod.unmute permission: townychat.mod.unmute