net.forthecrown.grenadier.annotations.compiler.CompiledSuggester Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of grenadier-annotations Show documentation
Show all versions of grenadier-annotations Show documentation
Annotation-based command support for Grenadier
package net.forthecrown.grenadier.annotations.compiler;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.suggestion.SuggestionProvider;
import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import it.unimi.dsi.fastutil.Pair;
import java.lang.reflect.Method;
import java.util.concurrent.CompletableFuture;
import net.forthecrown.grenadier.CommandSource;
import net.forthecrown.grenadier.annotations.compiler.MemberChain.FieldMember;
import net.forthecrown.grenadier.annotations.compiler.MemberChain.MethodMember;
import net.forthecrown.grenadier.annotations.compiler.MemberChainCompiler.ChainCompileConfig;
import net.forthecrown.grenadier.annotations.tree.SuggestsTree.MemberSuggestions;
import net.forthecrown.grenadier.annotations.util.Result;
class CompiledSuggester implements SuggestionProvider {
private final MemberChain chain;
private final Object commandClass;
private final ParamFiller[] fillers;
private final Object[] parameterBuffer;
private final ContextFactory factory;
public CompiledSuggester(
MemberChain chain,
Object commandClass,
ParamFiller[] fillers,
ContextFactory factory
) {
this.chain = chain;
this.commandClass = commandClass;
this.fillers = fillers;
this.factory = factory;
this.parameterBuffer = new Object[fillers.length];
}
@Override
public CompletableFuture getSuggestions(
CommandContext context,
SuggestionsBuilder builder
) throws CommandSyntaxException {
Pair
© 2015 - 2025 Weber Informatics LLC | Privacy Policy