Fix /mcchat not using the configured prefix

This commit is contained in:
Norbi Peti 2020-09-07 01:09:39 +02:00
parent 3ee1eb3dec
commit d784d8b1e2
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
4 changed files with 5 additions and 4 deletions

View file

@ -180,7 +180,7 @@ public class DiscordPlugin extends ButtonPlugin {
Component.registerComponent(this, new GameRoleModule()); //Needs the mainServer to be set
Component.registerComponent(this, new AnnouncerModule());
Component.registerComponent(this, new FunModule());
new ChromaBot(this).updatePlayerList(); //Initialize ChromaBot - The MCCHatModule is tested to be enabled
new ChromaBot(this).updatePlayerList(); //Initialize ChromaBot - The MCChatModule is tested to be enabled
getManager().registerCommand(new VersionCommand());
getManager().registerCommand(new UserinfoCommand());

View file

@ -225,6 +225,7 @@ public class MCChatListener implements Listener {
timings.printElapsed("Chat event");
val author = ev.getMessage().getAuthor();
final boolean hasCustomChat = MCChatCustom.hasCustomChat(ev.getMessage().getChannelId());
var prefix = DiscordPlugin.getPrefix();
return ev.getMessage().getChannel().filter(channel -> {
timings.printElapsed("Filter 1");
return !(ev.getMessage().getChannelId().asLong() != module.chatChannel().get().asLong()
@ -236,7 +237,7 @@ public class MCChatListener implements Listener {
return !(channel instanceof PrivateChannel //Only in private chat
&& ev.getMessage().getContent().isPresent()
&& ev.getMessage().getContent().get().length() < "/mcchat<>".length()
&& ev.getMessage().getContent().get().replace("/", "")
&& ev.getMessage().getContent().get().replace(prefix + "", "")
.equalsIgnoreCase("mcchat")); //Either mcchat or /mcchat
//Allow disabling the chat if needed
}).filterWhen(channel -> CommandListener.runCommand(ev.getMessage(), channel, true))

View file

@ -53,7 +53,7 @@ public class MCChatUtils {
LastMsgData lastmsgdata;
static LongObjectHashMap<Message> lastmsgfromd = new LongObjectHashMap<>(); // Last message sent by a Discord user, used for clearing checkmarks
private static MinecraftChatModule module;
private static HashMap<Class<? extends Event>, HashSet<String>> staticExcludedPlugins = new HashMap<>();
private static final HashMap<Class<? extends Event>, HashSet<String>> staticExcludedPlugins = new HashMap<>();
public static void updatePlayerList() {
val mod = getModule();

View file

@ -75,7 +75,7 @@ public class MinecraftChatModule extends Component<DiscordPlugin> {
/**
* 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 <b>everything</b> between the first and last "----" but it will only detect exactly four dashes.
* Note that it will replace <b>everything</b> above the first and below the 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<Boolean> showPlayerListOnDC() {