mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-29 12:14:43 +02:00
move chat config options from config.yml -> chat.yml
This commit is contained in:
@ -4,6 +4,7 @@ import com.gmail.nossr50.chat.author.Author;
|
||||
import com.gmail.nossr50.chat.author.ConsoleAuthor;
|
||||
import com.gmail.nossr50.chat.mailer.AdminChatMailer;
|
||||
import com.gmail.nossr50.chat.mailer.PartyChatMailer;
|
||||
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;
|
||||
@ -25,12 +26,15 @@ public class ChatManager {
|
||||
private final @NotNull ConsoleAuthor consoleAuthor;
|
||||
private final @NotNull Audience consoleAudience;
|
||||
|
||||
private final boolean isChatEnabled;
|
||||
|
||||
public ChatManager(@NotNull mcMMO pluginRef) {
|
||||
adminChatMailer = new AdminChatMailer(pluginRef);
|
||||
partyChatMailer = new PartyChatMailer(pluginRef);
|
||||
|
||||
this.consoleAuthor = new ConsoleAuthor(LocaleLoader.getString("Chat.Identity.Console"));
|
||||
this.consoleAudience = mcMMO.getAudiences().filter((cs) -> cs instanceof ConsoleCommandSender);
|
||||
this.isChatEnabled = ChatConfig.getInstance().isChatEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -179,5 +183,40 @@ public class ChatManager {
|
||||
public void sendConsoleMessage(@NotNull Author author, @NotNull TextComponent message) {
|
||||
consoleAudience.sendMessage(author, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the mcMMO chat system which handles party and admin chat is enabled or disabled
|
||||
* @return true if mcMMO chat processing (for party/admin chat) is enabled
|
||||
*/
|
||||
public boolean isChatEnabled() {
|
||||
return isChatEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not a specific chat channel is enabled
|
||||
* ChatChannels are enabled/disabled via user config
|
||||
*
|
||||
* If chat is disabled, this always returns false
|
||||
* If NONE is passed as a {@link ChatChannel} it will return true
|
||||
* @param chatChannel target chat channel
|
||||
* @return true if the chat channel is enabled
|
||||
*/
|
||||
public boolean isChatChannelEnabled(@NotNull ChatChannel chatChannel) {
|
||||
if(!isChatEnabled) {
|
||||
return false;
|
||||
} else {
|
||||
switch(chatChannel) {
|
||||
|
||||
case ADMIN:
|
||||
case PARTY:
|
||||
case PARTY_OFFICER:
|
||||
return ChatConfig.getInstance().isChatChannelEnabled(chatChannel);
|
||||
case NONE:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.chat.author;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.ChatConfig;
|
||||
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||
import com.google.common.base.Objects;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@ -23,7 +24,7 @@ public class AdminAuthor implements Author {
|
||||
if(overrideName != null) {
|
||||
return overrideName;
|
||||
} else {
|
||||
if(Config.getInstance().getAdminDisplayNames()) {
|
||||
if(ChatConfig.getInstance().useDisplayNames(ChatChannel.ADMIN)) {
|
||||
return player.getDisplayName();
|
||||
} else {
|
||||
return player.getName();
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.chat.author;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.ChatConfig;
|
||||
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||
import com.google.common.base.Objects;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@ -23,7 +24,7 @@ public class PartyAuthor implements Author {
|
||||
if(overrideName != null) {
|
||||
return overrideName;
|
||||
} else {
|
||||
if(Config.getInstance().getPartyDisplayNames()) {
|
||||
if(ChatConfig.getInstance().useDisplayNames(ChatChannel.PARTY)) {
|
||||
return player.getDisplayName();
|
||||
} else {
|
||||
return player.getName();
|
||||
|
Reference in New Issue
Block a user