Added ability to ignore commands using regexp; Refactored MinecraftListener;
Issue https://github.com/Chikachi/DiscordIntegration/issues/86 Signed-off-by: Mijago <afruehwald@mijago.de>
This commit is contained in:
parent
64db9374bc
commit
0a1f488ff4
@ -49,15 +49,29 @@ public class MinecraftListener {
|
||||
if (event.isCanceled()) return;
|
||||
|
||||
String commandName = event.getCommand().getName();
|
||||
ICommandSender sender = event.getSender();
|
||||
|
||||
MinecraftConfig minecraftConfig = Configuration.getConfig().minecraft;
|
||||
MinecraftDimensionConfig genericConfig = minecraftConfig.dimensions.generic;
|
||||
|
||||
MessageConfig messageConfig;
|
||||
|
||||
if (commandName.equalsIgnoreCase("say") || commandName.equalsIgnoreCase("me")) {
|
||||
boolean isSayCommand = commandName.equalsIgnoreCase("say");
|
||||
broadcastMeOrSayToDiscord(event);
|
||||
} else {
|
||||
String commandWithParameters = event.getCommand().getName() + " " + Joiner.on(" ").join(event.getParameters());
|
||||
boolean commandIgnored = Configuration.getConfig().minecraft.dimensions.generic.isCommandIgnored(commandWithParameters);
|
||||
boolean isLinkCommand = commandName.equalsIgnoreCase("discord")
|
||||
&& event.getParameters().length > 0
|
||||
&& event.getParameters()[0].equalsIgnoreCase("link");
|
||||
|
||||
if (!commandIgnored && !isLinkCommand) {
|
||||
// Do not relay link commands
|
||||
broadcastCommandToDiscord(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastMeOrSayToDiscord(CommandEvent event) {
|
||||
ICommandSender sender = event.getSender();
|
||||
MinecraftConfig minecraftConfig = Configuration.getConfig().minecraft;
|
||||
MinecraftDimensionConfig genericConfig = minecraftConfig.dimensions.generic;
|
||||
MessageConfig messageConfig;
|
||||
boolean isSayCommand = event.getCommand().getName().equalsIgnoreCase("say");
|
||||
|
||||
if (isSayCommand && !Configuration.getConfig().minecraft.dimensions.generic.relaySayCommand) {
|
||||
return;
|
||||
@ -126,13 +140,13 @@ public class MinecraftListener {
|
||||
.setPrefix(prefix),
|
||||
channels
|
||||
);
|
||||
} else if (commandName.equalsIgnoreCase("discord")) {
|
||||
// Do not relay linking commands
|
||||
if (event.getParameters().length > 0 && event.getParameters()[0].equalsIgnoreCase("link")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastCommandToDiscord(CommandEvent event) {
|
||||
ICommandSender sender = event.getSender();
|
||||
MinecraftConfig minecraftConfig = Configuration.getConfig().minecraft;
|
||||
MinecraftDimensionConfig genericConfig = minecraftConfig.dimensions.generic;
|
||||
MessageConfig messageConfig;
|
||||
ArrayList<Long> channels;
|
||||
|
||||
messageConfig = minecraftConfig.dimensions.generic.messages.command;
|
||||
|
Loading…
x
Reference in New Issue
Block a user