Fix HelpCommand not working without static CommandsExecutor
This commit is contained in:
@@ -6,5 +6,9 @@ import server.shop.ShopFactory;
|
||||
/**
|
||||
* @author Ponk
|
||||
*/
|
||||
public record CommandContext(DropProvider dropProvider, ShopFactory shopFactory) {
|
||||
public record CommandContext(CommandsExecutor commandsExecutor, DropProvider dropProvider, ShopFactory shopFactory) {
|
||||
|
||||
public CommandContext with(CommandsExecutor ce) {
|
||||
return new CommandContext(ce, this.dropProvider, this.shopFactory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class CommandsExecutor {
|
||||
private Pair<List<String>, List<String>> levelCommandsCursor;
|
||||
|
||||
public CommandsExecutor(CommandContext commandContext) {
|
||||
this.commandContext = commandContext;
|
||||
this.commandContext = commandContext.with(this);
|
||||
registerCommands();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import constants.id.NpcId;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class HelpCommand extends Command {
|
||||
{
|
||||
setDescription("Show available commands.");
|
||||
@@ -35,6 +37,7 @@ public class HelpCommand extends Command {
|
||||
|
||||
@Override
|
||||
public void execute(Client client, String[] params, CommandContext ctx) {
|
||||
client.getAbstractPlayerInteraction().openNpc(NpcId.STEWARD, "commands");
|
||||
Map<String, Object> bindings = Map.of("ce", ctx.commandsExecutor());
|
||||
client.getAbstractPlayerInteraction().openNpc(NpcId.STEWARD, "commands", bindings);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user