Class CloudBrigadierManager<C,S>

java.lang.Object
org.incendo.cloud.brigadier.CloudBrigadierManager<C,S>
Type Parameters:
C - cloud command sender type
S - brigadier command source type
All Implemented Interfaces:
SenderMapperHolder<S,C>

public final class CloudBrigadierManager<C,S> extends Object implements SenderMapperHolder<S,C>
Manager used to map cloud Command

The structure of this class is largely inspired by ACFBrigadiermanager in the ACF project, which was originally written by MiniDigger and licensed under the MIT license.

  • Constructor Details

    • CloudBrigadierManager

      public CloudBrigadierManager(@NonNull CommandManager<C> commandManager, @NonNull SenderMapper<S,C> brigadierSourceMapper)
      Create a new cloud brigadier manager
      Parameters:
      commandManager - Command manager
      brigadierSourceMapper - Mapper between the Brigadier command source type and cloud command sender type
  • Method Details

    • settings

      Returns a Configurable instance that can be used to modify the settings for this instance.
      Returns:
      settings instance
      Since:
      2.0.0
    • senderMapper

      public @NonNull SenderMapper<S,C> senderMapper()
      Specified by:
      senderMapper in interface SenderMapperHolder<C,S>
    • setNativeNumberSuggestions

      @API(status=STABLE, since="1.2.0") public void setNativeNumberSuggestions(boolean nativeNumberSuggestions)
      Sets whether Brigadier's native suggestions for number types will be used, or if cloud's number suggestions should be used instead. At the time of writing the native suggestions are equivalent to SuggestionProvider.noSuggestions().

      The default is to use cloud's suggestions, or false.

      Parameters:
      nativeNumberSuggestions - whether Brigadier suggestions should be used for number types
      Since:
      1.2.0
    • setNativeSuggestions

      @API(status=STABLE, since="1.2.0") public <T, K extends ArgumentParser<C, T>> void setNativeSuggestions(@NonNull TypeToken<K> argumentType, boolean nativeSuggestions) throws IllegalArgumentException
      Set whether to use Brigadier's native suggestions for an argument type with an already registered mapper.

      If Brigadier's suggestions are not used, suggestions will fall back to the cloud suggestion provider.

      Type Parameters:
      T - argument type
      K - cloud argument parser type
      Parameters:
      argumentType - cloud argument parser type
      nativeSuggestions - whether Brigadier suggestions should be used
      Throws:
      IllegalArgumentException - when there is no mapper registered for the provided argument type
      Since:
      1.2.0
    • registerMapping

      @API(status=STABLE, since="1.5.0") public <K extends ArgumentParser<C, ?>> void registerMapping(@NonNull TypeToken<K> parserType, Consumer<BrigadierMappingBuilder<K,S>> configurer)
      Register a cloud-Brigadier mapping.
      Type Parameters:
      K - cloud argument parser type
      Parameters:
      parserType - The cloud argument parser type
      configurer - a callback that will configure the mapping attributes
      Since:
      1.5.0
    • mappings

      @API(status=INTERNAL, since="2.0.0") public @NonNull BrigadierMappings<C,S> mappings()
      Returns the mappings between Cloud and Brigadier types.
      Returns:
      the mappings
      Since:
      2.0.0
    • literalBrigadierNodeFactory

      @API(status=STABLE, since="2.0.0") public @NonNull LiteralBrigadierNodeFactory<C,S> literalBrigadierNodeFactory()
      Returns a factory that creates literal command nodes from Cloud commands.
      Returns:
      the literal node factory
      Since:
      2.0.0
    • registerDefaultArgumentTypeSupplier

      @API(status=STABLE, since="2.0.0") public <T> void registerDefaultArgumentTypeSupplier(@NonNull Class<T> clazz, @NonNull ArgumentTypeFactory<T> factory)
      Register a default mapping to between a class and a Brigadier argument type
      Type Parameters:
      T - the type
      Parameters:
      clazz - the type to map
      factory - factory that creates the argument type
      Since:
      2.0.0
    • defaultArgumentTypeFactories

      @API(status=INTERNAL, since="2.0.0") public @NonNull Map<@NonNull Class<?>,@NonNull ArgumentTypeFactory<?>> defaultArgumentTypeFactories()
      Returns the default argument type factories.
      Returns:
      immutable view of the factories
      Since:
      2.0.0