Refactor CommandsExecutor - is no longer static singleton
Preparing for change in Command#handle, which is going to take a CommandContext as an additional argument. This way we can pass in command dependencies in a safe way instead of requiring them to access static methods.
This commit is contained in:
@@ -34,6 +34,11 @@ import tools.PacketCreator;
|
||||
|
||||
public final class GeneralChatHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(GeneralChatHandler.class);
|
||||
private final CommandsExecutor commandsExecutor;
|
||||
|
||||
public GeneralChatHandler(CommandsExecutor commandsExecutor) {
|
||||
this.commandsExecutor = commandsExecutor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(InPacket p, Client c) {
|
||||
@@ -51,7 +56,7 @@ public final class GeneralChatHandler extends AbstractPacketHandler {
|
||||
}
|
||||
char heading = s.charAt(0);
|
||||
if (CommandsExecutor.isCommand(c, s)) {
|
||||
CommandsExecutor.getInstance().handle(c, s);
|
||||
commandsExecutor.handle(c, s);
|
||||
} else if (heading != '/') {
|
||||
int show = p.readByte();
|
||||
if (chr.getMap().isMuted() && !chr.isGM()) {
|
||||
@@ -70,4 +75,4 @@ public final class GeneralChatHandler extends AbstractPacketHandler {
|
||||
chr.getAutobanManager().spam(7);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user