pass literal to CommandContextFactory
All checks were successful
/ test (push) Successful in 1m0s
/ deploy (push) Successful in 1m12s

This commit is contained in:
kento2 2026-08-29 02:37:23 +02:00
parent b8fbda94fc
commit 613ea016f1
6 changed files with 9 additions and 7 deletions

View file

@ -28,7 +28,7 @@ public class BukkitScrowCommand<C extends BukkitCommandContext<C>> extends Comma
public boolean execute(@NotNull CommandSender commandSender, @NotNull String commandLabel, String @NotNull [] args) {
commandHandler.invoke(
rootLiteral,
commandContextFactory.createContext(commandSender),
commandContextFactory.createContext(rootLiteral, commandSender),
Stream.of(args).filter(str -> !str.isEmpty())
);
return true;

View file

@ -1,9 +1,10 @@
package site.lab0x13.scrow.commands.bukkit;
import org.bukkit.command.CommandSender;
import site.lab0x13.scrow.commands.model.literal.RootLiteral;
@FunctionalInterface
public interface CommandContextFactory<C extends BukkitCommandContext<C>> {
C createContext(CommandSender sender);
C createContext(RootLiteral<C> literal, CommandSender sender);
}

View file

@ -38,7 +38,7 @@ public class TabCompleteListener<C extends BukkitCommandContext<C>> implements L
ev.setHandled(true);
ev.setCompletions(commandHandler.suggest(
literal,
commandContextFactory.createContext(ev.getSender()),
commandContextFactory.createContext(literal, ev.getSender()),
Arrays.copyOfRange(args, 1, args.length),
ev.getBuffer().endsWith(" ")
));