add toggle for sending chat messages to console

Fixes #4415
This commit is contained in:
nossr50 2021-02-10 10:05:42 -08:00
parent addf9b0431
commit 1bde79cd6f
5 changed files with 14 additions and 2 deletions

View File

@ -1,4 +1,5 @@
Version 2.1.175
Added a setting to chat.yml to toggle sending party or admin chat messages to console
Added a set of "mastery" subskills meant for end game progression
Added the mastery subskill 'Mother Lode' to Mining
Added the mastery subskill 'Clean Cuts' to Woodcutting

View File

@ -3,6 +3,7 @@ package com.gmail.nossr50.chat.mailer;
import com.gmail.nossr50.chat.author.Author;
import com.gmail.nossr50.chat.message.AdminChatMessage;
import com.gmail.nossr50.chat.message.ChatMessage;
import com.gmail.nossr50.config.ChatConfig;
import com.gmail.nossr50.datatypes.chat.ChatChannel;
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
import com.gmail.nossr50.events.chat.McMMOChatEvent;
@ -44,7 +45,7 @@ public class AdminChatMailer extends AbstractChatMailer {
public @NotNull Predicate<CommandSender> predicate() {
return (commandSender) -> commandSender.isOp()
|| commandSender.hasPermission(MCMMO_CHAT_ADMINCHAT_PERMISSION)
|| commandSender instanceof ConsoleCommandSender;
|| (ChatConfig.getInstance().isConsoleIncludedInAudience(ChatChannel.ADMIN) && commandSender instanceof ConsoleCommandSender);
}
/**

View File

@ -1,6 +1,7 @@
package com.gmail.nossr50.chat.message;
import com.gmail.nossr50.chat.author.Author;
import com.gmail.nossr50.config.ChatConfig;
import com.gmail.nossr50.datatypes.chat.ChatChannel;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
@ -51,7 +52,8 @@ public class PartyChatMessage extends AbstractChatMessage {
messagePartyChatSpies(spyMessage);
//Console message
mcMMO.p.getChatManager().sendConsoleMessage(author, spyMessage);
if(ChatConfig.getInstance().isConsoleIncludedInAudience(ChatChannel.PARTY))
mcMMO.p.getChatManager().sendConsoleMessage(author, spyMessage);
}
/**

View File

@ -49,6 +49,12 @@ public class ChatConfig extends AutoUpdateConfigLoader {
return config.getBoolean(key, true);
}
public boolean isConsoleIncludedInAudience(@NotNull ChatChannel chatChannel) {
String key = "Chat.Channels." + StringUtils.getCapitalized(chatChannel.toString()) + ".Send_To_Console";
return config.getBoolean(key, true);
}
public boolean isSpyingAutomatic() {
return config.getBoolean("Chat.Channels.Party.Spies.Automatically_Enable_Spying", false);
}

View File

@ -8,10 +8,12 @@ Chat:
Enable: true
# Whether or not to use the current display name of a player
Use_Display_Names: true
Send_To_Console: true
Spies:
# Whether or not players with the chat spy permission join the server with chat spying toggled on
Automatically_Enable_Spying: false
Admin:
Send_To_Console: true
# Enable or disable admin chat
Enable: true
# Whether or not to use the current display name of a player