refactor: change command handler executeCommand signature to be more clean
This commit is contained in:
@@ -1 +1 @@
|
||||
2684
|
||||
2687
|
||||
@@ -58,6 +58,6 @@ public class PacketHandler {
|
||||
player
|
||||
);
|
||||
|
||||
bot.commandHandler.executeCommand(input, context, null);
|
||||
bot.commandHandler.executeCommand(input, context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import java.awt.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class DiscordCommandContext extends CommandContext {
|
||||
private final MessageReceivedEvent event;
|
||||
public final MessageReceivedEvent event;
|
||||
|
||||
private final Bot bot;
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public class NetCommandCommand extends Command {
|
||||
|
||||
final CommandContext remoteContext = new RemoteCommandContext(bot, context);
|
||||
|
||||
context.bot.commandHandler.executeCommand(command, remoteContext, null);
|
||||
context.bot.commandHandler.executeCommand(command, remoteContext);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -61,7 +61,7 @@ public class GuildMessageEventHandler extends ListenerAdapter {
|
||||
if (messageString.startsWith(prefix)) {
|
||||
final DiscordCommandContext context = new DiscordCommandContext(bot, prefix, event);
|
||||
|
||||
bot.commandHandler.executeCommand(messageString.substring(prefix.length()), context, event);
|
||||
bot.commandHandler.executeCommand(messageString.substring(prefix.length()), context);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -98,6 +98,6 @@ public class ChatCommandHandlerPlugin implements ChatPlugin.Listener, CommandSpy
|
||||
packetType
|
||||
);
|
||||
|
||||
bot.commandHandler.executeCommand(commandString, context, null);
|
||||
bot.commandHandler.executeCommand(commandString, context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,11 +108,20 @@ public class CommandHandlerPlugin implements TickPlugin.Listener {
|
||||
// though it can also be as low as 4000 ns)
|
||||
public void executeCommand (
|
||||
final String input,
|
||||
final CommandContext context,
|
||||
final MessageReceivedEvent event
|
||||
final CommandContext context
|
||||
) {
|
||||
final boolean inGame = context instanceof PlayerCommandContext;
|
||||
final boolean discord = context instanceof DiscordCommandContext;
|
||||
|
||||
final boolean discord;
|
||||
final MessageReceivedEvent event;
|
||||
|
||||
if (context instanceof final DiscordCommandContext discordContext) {
|
||||
discord = true;
|
||||
event = discordContext.event;
|
||||
} else {
|
||||
discord = false;
|
||||
event = null;
|
||||
}
|
||||
|
||||
final boolean bypass = context instanceof ConsoleCommandContext || context instanceof ChomeNSModCommandContext;
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ public class ConsolePlugin implements Completer {
|
||||
if (line.startsWith(prefix)) {
|
||||
final ConsoleCommandContext context = new ConsoleCommandContext(bot, prefix);
|
||||
|
||||
bot.commandHandler.executeCommand(line.substring(prefix.length()), context, null);
|
||||
bot.commandHandler.executeCommand(line.substring(prefix.length()), context);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ public class IRCPlugin extends ListenerAdapter {
|
||||
|
||||
final IRCCommandContext context = new IRCCommandContext(serverBot, commandPrefix, name);
|
||||
|
||||
serverBot.commandHandler.executeCommand(noPrefix, context, null);
|
||||
serverBot.commandHandler.executeCommand(noPrefix, context);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user