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.'
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.'
MutePlayerAllPlayerReason: '&cYou have just been muted in all channels. &4Reason:&c {reason}'
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}'
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}'

View File

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

View File

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