diff --git a/src/main/java/buttondevteam/discordplugin/mcchat/ChannelconCommand.java b/src/main/java/buttondevteam/discordplugin/mcchat/ChannelconCommand.java index bc1cf20..d51a4b0 100644 --- a/src/main/java/buttondevteam/discordplugin/mcchat/ChannelconCommand.java +++ b/src/main/java/buttondevteam/discordplugin/mcchat/ChannelconCommand.java @@ -90,6 +90,10 @@ public class ChannelconCommand extends ICommand2DC { @Command2.Subcommand public boolean def(Command2DCSender sender, String channelID) { val message = sender.getMessage(); + if (!module.allowCustomChat().get()) { + sender.sendMessage("channel connection is not allowed on this Minecraft server."); + return true; + } if (checkPerms(message)) return true; if (MCChatCustom.hasCustomChat(message.getChannelId())) return respond(sender, "this channel is already connected to a Minecraft channel. Use `@ChromaBot channelcon remove` to remove it."); diff --git a/src/main/java/buttondevteam/discordplugin/mcchat/MCChatCommand.java b/src/main/java/buttondevteam/discordplugin/mcchat/MCChatCommand.java index 63b2fb5..f068a12 100755 --- a/src/main/java/buttondevteam/discordplugin/mcchat/MCChatCommand.java +++ b/src/main/java/buttondevteam/discordplugin/mcchat/MCChatCommand.java @@ -9,6 +9,7 @@ import buttondevteam.lib.TBMCCoreAPI; import buttondevteam.lib.chat.Command2; import buttondevteam.lib.chat.CommandClass; import discord4j.core.object.entity.PrivateChannel; +import lombok.RequiredArgsConstructor; import lombok.val; @CommandClass(helpText = { @@ -17,10 +18,17 @@ import lombok.val; "It can be useful if you don't want your messages to be visible, for example when talking in a private channel.", // "You can also run all of the ingame commands you have access to using this command, if you have your accounts connected." // }) +@RequiredArgsConstructor public class MCChatCommand extends ICommand2DC { + private final MinecraftChatModule module; + @Command2.Subcommand public boolean def(Command2DCSender sender) { + if (!module.allowPrivateChat().get()) { + sender.sendMessage("using the private chat is not allowed on this Minecraft server."); + return true; + } val message = sender.getMessage(); val channel = message.getChannel().block(); @SuppressWarnings("OptionalGetWithoutIsPresent") val author = message.getAuthor().get(); diff --git a/src/main/java/buttondevteam/discordplugin/mcchat/MCChatUtils.java b/src/main/java/buttondevteam/discordplugin/mcchat/MCChatUtils.java index 5f709d2..5e4c51c 100644 --- a/src/main/java/buttondevteam/discordplugin/mcchat/MCChatUtils.java +++ b/src/main/java/buttondevteam/discordplugin/mcchat/MCChatUtils.java @@ -53,7 +53,8 @@ public class MCChatUtils { private static HashMap, HashSet> staticExcludedPlugins = new HashMap<>(); public static void updatePlayerList() { - if (notEnabled()) return; + val mod = getModule(); + if (mod == null || !mod.showPlayerListOnDC().get()) return; if (lastmsgdata != null) updatePL(lastmsgdata); MCChatCustom.lastmsgCustom.forEach(MCChatUtils::updatePL); diff --git a/src/main/java/buttondevteam/discordplugin/mcchat/MinecraftChatModule.java b/src/main/java/buttondevteam/discordplugin/mcchat/MinecraftChatModule.java index 1534ee9..a44986a 100644 --- a/src/main/java/buttondevteam/discordplugin/mcchat/MinecraftChatModule.java +++ b/src/main/java/buttondevteam/discordplugin/mcchat/MinecraftChatModule.java @@ -77,6 +77,33 @@ public class MinecraftChatModule extends Component { return getConfig().getData("allowFakePlayerTeleports", false); } + /** + * If this is on, each chat channel will have a player list in their description. + * It only gets added if there's no description yet or there are (at least) two lines of "----" following each other. + * Note that it will replace everything between the first and last "----" but it will only detect exactly four dashes. + * So if you want to use dashes for something else in the description, make sure it's either less or more dashes in one line. + */ + public ConfigData showPlayerListOnDC() { + return getConfig().getData("showPlayerListOnDC", true); + } + + /** + * This setting controls whether custom chat connections can be created (existing connections will always work). + * Custom chat connections can be created using the channelcon command and they allow players to display town chat in a Discord channel for example. + * See the channelcon command for more details. + */ + public ConfigData allowCustomChat() { + return getConfig().getData("allowCustomChat", true); + } + + /** + * This setting allows you to control if players can DM the bot to log on the server from Discord. + * This allows them to both chat and perform any command they can in-game. + */ + public ConfigData allowPrivateChat() { + return getConfig().getData("allowPrivateChat", true); + } + @Override protected void enable() { if (DPUtils.disableIfConfigErrorRes(this, chatChannel(), chatChannelMono())) @@ -84,7 +111,7 @@ public class MinecraftChatModule extends Component { listener = new MCChatListener(this); TBMCCoreAPI.RegisterEventsForExceptions(listener, getPlugin()); TBMCCoreAPI.RegisterEventsForExceptions(new MCListener(this), getPlugin());//These get undone if restarting/resetting - it will ignore events if disabled - getPlugin().getManager().registerCommand(new MCChatCommand()); + getPlugin().getManager().registerCommand(new MCChatCommand(this)); getPlugin().getManager().registerCommand(new ChannelconCommand(this)); val chcons = getConfig().getConfig().getConfigurationSection("chcons");