Browse Source

add toggle for sending chat messages to console
Fixes #4415

nossr50 4 years ago
parent
commit
1bde79cd6f

+ 1 - 0
Changelog.txt

@@ -1,4 +1,5 @@
 Version 2.1.175
 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 a set of "mastery" subskills meant for end game progression
     Added the mastery subskill 'Mother Lode' to Mining
     Added the mastery subskill 'Mother Lode' to Mining
     Added the mastery subskill 'Clean Cuts' to Woodcutting
     Added the mastery subskill 'Clean Cuts' to Woodcutting

+ 2 - 1
src/main/java/com/gmail/nossr50/chat/mailer/AdminChatMailer.java

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

+ 3 - 1
src/main/java/com/gmail/nossr50/chat/message/PartyChatMessage.java

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

+ 6 - 0
src/main/java/com/gmail/nossr50/config/ChatConfig.java

@@ -49,6 +49,12 @@ public class ChatConfig extends AutoUpdateConfigLoader {
         return config.getBoolean(key, true);
         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() {
     public boolean isSpyingAutomatic() {
         return config.getBoolean("Chat.Channels.Party.Spies.Automatically_Enable_Spying", false);
         return config.getBoolean("Chat.Channels.Party.Spies.Automatically_Enable_Spying", false);
     }
     }

+ 2 - 0
src/main/resources/chat.yml

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