Add reason for /muteall.

This commit is contained in:
Aust1n46 2021-04-04 22:57:30 -05:00
parent c12c00b784
commit 44c2363db3
3 changed files with 56 additions and 18 deletions

View File

@ -54,7 +54,9 @@ MessageToggleOff: '&6You are now blocking messages.'
MessageToggleOn: '&6You are now receiving messages.' MessageToggleOn: '&6You are now receiving messages.'
MustListenOneChannel: '&cYou need to be listening on at least one channel, setting you into the default channel.' MustListenOneChannel: '&cYou need to be listening on at least one channel, setting you into the default channel.'
MutePlayerAllPlayer: '&cYou have just been muted in all channels.' MutePlayerAllPlayer: '&cYou have just been muted in all channels.'
MutePlayerAllPlayerReason: '&cYou have just been muted in all channels. &4Reason:&c {reason}'
MutePlayerAllSender: '&cMuted player &6{player} &cin all channels.' MutePlayerAllSender: '&cMuted player &6{player} &cin all channels.'
MutePlayerAllSenderReason: '&cMuted player &6{player} &cin all channels. &4Reason:&c {reason}'
MutePlayerPlayer: '&cYou have just been muted in: {channel_color}{channel_name}' MutePlayerPlayer: '&cYou have just been muted in: {channel_color}{channel_name}'
MutePlayerPlayerReason: '&cYou have just been muted in: {channel_color}{channel_name} &4Reason:&c {reason}' MutePlayerPlayerReason: '&cYou have just been muted in: {channel_color}{channel_name} &4Reason:&c {reason}'
MutePlayerPlayerTime: '&cYou have just been muted in: {channel_color}{channel_name} &cfor {time}' MutePlayerPlayerTime: '&cYou have just been muted in: {channel_color}{channel_name} &cfor {time}'

View File

@ -21,7 +21,7 @@ public class Muteall extends MineverseCommand {
if(args.length < 1) { if(args.length < 1) {
sender.sendMessage(LocalizedMessage.COMMAND_INVALID_ARGUMENTS.toString() sender.sendMessage(LocalizedMessage.COMMAND_INVALID_ARGUMENTS.toString()
.replace("{command}", "/muteall") .replace("{command}", "/muteall")
.replace("{args}", "[player]")); .replace("{args}", "[player] {reason}"));
return; return;
} }
MineverseChatPlayer player = MineverseChatAPI.getMineverseChatPlayer(args[0]); MineverseChatPlayer player = MineverseChatAPI.getMineverseChatPlayer(args[0]);
@ -30,30 +30,64 @@ public class Muteall extends MineverseCommand {
.replace("{args}", args[0])); .replace("{args}", args[0]));
return; return;
} }
boolean bungee = false; String reason = "";
for(ChatChannel channel : ChatChannel.getChatChannels()) { if(args.length > 1) {
if(channel.isMutable()) { StringBuilder reasonBuilder = new StringBuilder();
player.addMute(channel.getName()); for(int a = 1; a < args.length; a ++) {
if(channel.getBungee()) { reasonBuilder.append(args[a]);
bungee = true; }
reason = reasonBuilder.toString();
}
if(reason.isEmpty()) {
boolean bungee = false;
for(ChatChannel channel : ChatChannel.getChatChannels()) {
if(channel.isMutable()) {
player.addMute(channel.getName());
if(channel.getBungee()) {
bungee = true;
}
} }
} }
if(bungee) {
MineverseChat.getInstance().synchronize(player, true);
}
sender.sendMessage(LocalizedMessage.MUTE_PLAYER_ALL_SENDER.toString()
.replace("{player}", player.getName()));
if(player.isOnline()) {
player.getPlayer().sendMessage(LocalizedMessage.MUTE_PLAYER_ALL_PLAYER.toString());
}
else
player.setModified(true);
return;
} }
if(bungee) { else {
MineverseChat.getInstance().synchronize(player, true); boolean bungee = false;
for(ChatChannel channel : ChatChannel.getChatChannels()) {
if(channel.isMutable()) {
player.addMute(channel.getName(), reason);
if(channel.getBungee()) {
bungee = true;
}
}
}
if(bungee) {
MineverseChat.getInstance().synchronize(player, true);
}
sender.sendMessage(LocalizedMessage.MUTE_PLAYER_ALL_SENDER_REASON.toString()
.replace("{player}", player.getName())
.replace("{reason}", reason));
if(player.isOnline()) {
player.getPlayer().sendMessage(LocalizedMessage.MUTE_PLAYER_ALL_PLAYER_REASON.toString()
.replace("{reason}", reason));
}
else
player.setModified(true);
return;
} }
sender.sendMessage(LocalizedMessage.MUTE_PLAYER_ALL_SENDER.toString()
.replace("{player}", player.getName()));
if(player.isOnline()) {
player.getPlayer().sendMessage(LocalizedMessage.MUTE_PLAYER_ALL_PLAYER.toString());
}
else
player.setModified(true);
return;
} }
else { else {
sender.sendMessage(LocalizedMessage.COMMAND_NO_PERMISSION.toString()); sender.sendMessage(LocalizedMessage.COMMAND_NO_PERMISSION.toString());
return; return;
} }
} }
} }

View File

@ -61,7 +61,9 @@ public enum LocalizedMessage {
MESSAGE_TOGGLE_ON("MessageToggleOn"), MESSAGE_TOGGLE_ON("MessageToggleOn"),
MUST_LISTEN_ONE_CHANNEL("MustListenOneChannel"), MUST_LISTEN_ONE_CHANNEL("MustListenOneChannel"),
MUTE_PLAYER_ALL_PLAYER("MutePlayerAllPlayer"), MUTE_PLAYER_ALL_PLAYER("MutePlayerAllPlayer"),
MUTE_PLAYER_ALL_PLAYER_REASON("MutePlayerAllPlayerReason"),
MUTE_PLAYER_ALL_SENDER("MutePlayerAllSender"), MUTE_PLAYER_ALL_SENDER("MutePlayerAllSender"),
MUTE_PLAYER_ALL_SENDER_REASON("MutePlayerAllSenderReason"),
MUTE_PLAYER_PLAYER("MutePlayerPlayer"), MUTE_PLAYER_PLAYER("MutePlayerPlayer"),
MUTE_PLAYER_PLAYER_TIME("MutePlayerPlayerTime"), MUTE_PLAYER_PLAYER_TIME("MutePlayerPlayerTime"),
MUTE_PLAYER_PLAYER_TIME_REASON("MutePlayerPlayerTimeReason"), MUTE_PLAYER_PLAYER_TIME_REASON("MutePlayerPlayerTimeReason"),