KenCommandAPI/kencommandapi-velocity/src/main/java/de/kentoj/kencommandapi/VelocityCommand.java
2026-07-06 22:08:48 +02:00

32 lines
No EOL
1 KiB
Java

package de.kentoj.kencommandapi;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.command.SimpleCommand;
import de.kentoj.kencommandapi.api.CommandHandler;
import de.kentoj.kencommandapi.api.literal.RootLiteral;
import lombok.RequiredArgsConstructor;
import java.util.List;
@RequiredArgsConstructor
public class VelocityCommand implements SimpleCommand {
private final CommandHandler<CommandSource> commandHandler;
private final RootLiteral<CommandSource> rootNode;
@Override
public void execute(Invocation invocation) {
commandHandler.invoke(rootNode, invocation.source(), invocation.arguments());
}
@Override
public boolean hasPermission(Invocation ctx) {
if (rootNode.getPermission() == null) return true;
return ctx.source().hasPermission(rootNode.getPermission());
}
@Override
public List<String> suggest(Invocation invocation) {
return commandHandler.getSuggestions(rootNode, invocation.source(), invocation.arguments());
}
}