Improve FilteringCommandSuggestionProcessor and adjust default filters (#410)
This commit is contained in:
parent
6c026f994b
commit
eca81f7372
10 changed files with 278 additions and 8 deletions
|
|
@ -55,6 +55,7 @@ import cloud.commandframework.bukkit.parsers.selector.MultiplePlayerSelectorArgu
|
|||
import cloud.commandframework.bukkit.parsers.selector.SingleEntitySelectorArgument;
|
||||
import cloud.commandframework.bukkit.parsers.selector.SinglePlayerSelectorArgument;
|
||||
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
||||
import cloud.commandframework.execution.FilteringCommandSuggestionProcessor;
|
||||
import cloud.commandframework.tasks.TaskFactory;
|
||||
import cloud.commandframework.tasks.TaskRecipe;
|
||||
import io.leangen.geantyref.TypeToken;
|
||||
|
|
@ -134,6 +135,10 @@ public class BukkitCommandManager<C> extends CommandManager<C> implements Brigad
|
|||
final BukkitSynchronizer bukkitSynchronizer = new BukkitSynchronizer(owningPlugin);
|
||||
this.taskFactory = new TaskFactory(bukkitSynchronizer);
|
||||
|
||||
this.commandSuggestionProcessor(new FilteringCommandSuggestionProcessor<>(
|
||||
FilteringCommandSuggestionProcessor.Filter.<C>startsWith(true).andTrimBeforeLastSpace()
|
||||
));
|
||||
|
||||
/* Register capabilities */
|
||||
CloudBukkitCapabilities.CAPABLE.forEach(this::registerCapability);
|
||||
this.registerCapability(CloudCapability.StandardCapabilities.ROOT_COMMAND_DELETION);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import cloud.commandframework.bungee.arguments.PlayerArgument;
|
|||
import cloud.commandframework.bungee.arguments.ServerArgument;
|
||||
import cloud.commandframework.captions.FactoryDelegatingCaptionRegistry;
|
||||
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
||||
import cloud.commandframework.execution.FilteringCommandSuggestionProcessor;
|
||||
import cloud.commandframework.meta.SimpleCommandMeta;
|
||||
import io.leangen.geantyref.TypeToken;
|
||||
import java.util.function.Function;
|
||||
|
|
@ -76,6 +77,10 @@ public class BungeeCommandManager<C> extends CommandManager<C> {
|
|||
this.commandSenderMapper = commandSenderMapper;
|
||||
this.backwardsCommandSenderMapper = backwardsCommandSenderMapper;
|
||||
|
||||
this.commandSuggestionProcessor(new FilteringCommandSuggestionProcessor<>(
|
||||
FilteringCommandSuggestionProcessor.Filter.<C>startsWith(true).andTrimBeforeLastSpace()
|
||||
));
|
||||
|
||||
/* Register Bungee Preprocessor */
|
||||
this.registerCommandPreProcessor(new BungeeCommandPreprocessor<>(this));
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ package cloud.commandframework.cloudburst;
|
|||
import cloud.commandframework.CommandManager;
|
||||
import cloud.commandframework.CommandTree;
|
||||
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
||||
import cloud.commandframework.execution.FilteringCommandSuggestionProcessor;
|
||||
import cloud.commandframework.meta.CommandMeta;
|
||||
import cloud.commandframework.meta.SimpleCommandMeta;
|
||||
import java.util.function.Function;
|
||||
|
|
@ -69,6 +70,9 @@ public class CloudburstCommandManager<C> extends CommandManager<C> {
|
|||
this.commandSenderMapper = commandSenderMapper;
|
||||
this.backwardsCommandSenderMapper = backwardsCommandSenderMapper;
|
||||
this.owningPlugin = owningPlugin;
|
||||
this.commandSuggestionProcessor(new FilteringCommandSuggestionProcessor<>(
|
||||
FilteringCommandSuggestionProcessor.Filter.<C>startsWith(true).andTrimBeforeLastSpace()
|
||||
));
|
||||
|
||||
// Prevent commands from being registered when the server would reject them anyways
|
||||
this.owningPlugin.getServer().getPluginManager().registerEvent(
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import cloud.commandframework.brigadier.argument.WrappedBrigadierParser;
|
|||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.execution.AsynchronousCommandExecutionCoordinator;
|
||||
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
||||
import cloud.commandframework.execution.FilteringCommandSuggestionProcessor;
|
||||
import cloud.commandframework.fabric.argument.FabricArgumentParsers;
|
||||
import cloud.commandframework.fabric.argument.RegistryEntryArgument;
|
||||
import cloud.commandframework.fabric.argument.TeamArgument;
|
||||
|
|
@ -154,6 +155,9 @@ public abstract class FabricCommandManager<C, S extends SharedSuggestionProvider
|
|||
this.registerNativeBrigadierMappings(this.brigadierManager);
|
||||
this.captionRegistry(new FabricCaptionRegistry<>());
|
||||
this.registerCommandPreProcessor(new FabricCommandPreprocessor<>(this));
|
||||
this.commandSuggestionProcessor(new FilteringCommandSuggestionProcessor<>(
|
||||
FilteringCommandSuggestionProcessor.Filter.<C>startsWith(true).andTrimBeforeLastSpace()
|
||||
));
|
||||
|
||||
((FabricCommandRegistrationHandler<C, S>) this.commandRegistrationHandler()).initialize(this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import cloud.commandframework.CommandManager;
|
|||
import cloud.commandframework.CommandTree;
|
||||
import cloud.commandframework.execution.AsynchronousCommandExecutionCoordinator;
|
||||
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
||||
import cloud.commandframework.execution.FilteringCommandSuggestionProcessor;
|
||||
import cloud.commandframework.meta.CommandMeta;
|
||||
import cloud.commandframework.meta.SimpleCommandMeta;
|
||||
import java.util.function.Function;
|
||||
|
|
@ -78,6 +79,9 @@ public class SpongeCommandManager<C> extends CommandManager<C> {
|
|||
this.owningPlugin = requireNonNull(container, "container");
|
||||
this.forwardMapper = requireNonNull(forwardMapper, "forwardMapper");
|
||||
this.reverseMapper = requireNonNull(reverseMapper, "reverseMapper");
|
||||
this.commandSuggestionProcessor(new FilteringCommandSuggestionProcessor<>(
|
||||
FilteringCommandSuggestionProcessor.Filter.<C>startsWith(true).andTrimBeforeLastSpace()
|
||||
));
|
||||
((SpongePluginRegistrationHandler<C>) this.commandRegistrationHandler()).initialize(this);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import cloud.commandframework.brigadier.BrigadierManagerHolder;
|
|||
import cloud.commandframework.brigadier.CloudBrigadierManager;
|
||||
import cloud.commandframework.captions.FactoryDelegatingCaptionRegistry;
|
||||
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
||||
import cloud.commandframework.execution.FilteringCommandSuggestionProcessor;
|
||||
import cloud.commandframework.meta.CommandMeta;
|
||||
import cloud.commandframework.meta.SimpleCommandMeta;
|
||||
import cloud.commandframework.velocity.arguments.PlayerArgument;
|
||||
|
|
@ -114,6 +115,10 @@ public class VelocityCommandManager<C> extends CommandManager<C> implements Brig
|
|||
this.commandSenderMapper = commandSenderMapper;
|
||||
this.backwardsCommandSenderMapper = backwardsCommandSenderMapper;
|
||||
|
||||
this.commandSuggestionProcessor(new FilteringCommandSuggestionProcessor<>(
|
||||
FilteringCommandSuggestionProcessor.Filter.<C>startsWith(true).andTrimBeforeLastSpace()
|
||||
));
|
||||
|
||||
/* Register Velocity Preprocessor */
|
||||
this.registerCommandPreProcessor(new VelocityCommandPreprocessor<>(this));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue