mirror of
https://github.com/darksaid98/TownyChat.git
synced 2026-12-02 06:28:58 +00:00
Mute/Unmute fixes
This commit is contained in:
1 parent
19f50b982a
commit
091dc495d4
5 files changed
+31
-30
No files matched your search
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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")) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
+4
-5
@@ -23,22 +23,21 @@ commands:
|
||||
description: Channel leaving and joining
|
||||
usage: /<command> leave|join channel
|
||||
leave:
|
||||
aliases: [ch leave]
|
||||
description: Leaves a channel
|
||||
usage: /<command> channel
|
||||
join:
|
||||
aliases: [ch join]
|
||||
description: Joins a channel
|
||||
usage: /<command> channel
|
||||
mute:
|
||||
chmute:
|
||||
aliases: [mute]
|
||||
description: Mutes a player in a channel
|
||||
usage: /<command> channel player
|
||||
permission: townychat.mod.mute
|
||||
mutelist:
|
||||
description: Displays mute list for a channel
|
||||
usage: /<command> channel
|
||||
permission: townychat.mod.list.mute
|
||||
unmute:
|
||||
chunmute:
|
||||
aliases: [unmute]
|
||||
description: Unmutes a player in a channel
|
||||
usage: /<command> channel player
|
||||
permission: townychat.mod.unmute
|
||||
|
||||
Reference in new issue
Block a user