### Creating Rich Completion Proposals Source: https://cloud.incendo.org/spring?q= Example of creating a CloudCompletionProposal with display name and category. ```java CloudCompletionProposal.of("proposal") .displayName("with a display name") .category("and a category"); ``` -------------------------------- ### Literal Examples Source: https://cloud.incendo.org/core Create command literals using Command.Builder#literal. Literals are fixed strings that can have aliases and descriptions. ```java builder .literal("foo") .literal( "bar", Description.of("A literal with a description and an alias"), "b" ); ``` -------------------------------- ### Example Annotated Command Source: https://cloud.incendo.org/spring?q= An example of a command class annotated with @ScanCommands, @CommandGroup, @CommandDescription, and @CommandMethod. ```java @ScanCommands @Component public class SomeCommand { @CommandGroup("A group") @CommandDescription("A description") @CommandMethod("A command") public void yourCommand() { // ... } } ``` -------------------------------- ### Install Coroutine Support Source: https://cloud.incendo.org/kotlin/annotations?q= Install the CoroutineSupport extension for the annotation parser. You can optionally override the default coroutine scope and context. ```kotlin annotationParser.installCoroutineSupport() ``` -------------------------------- ### Suggestion Provider Signatures Source: https://cloud.incendo.org/annotations?q= Examples of method signatures for creating suggestion providers. ```java @Suggestions("name") public List suggestions(CommandContext context, CommandInput input) { /* ... */ } ``` ```java @Suggestions("name") public Stream suggestions(CommandContext context, String input) { /* ... */ } ``` ```java @Suggestions("name") public Set suggestions(CommandContext context, CommandInput input) { /* ... */ } ``` ```java @Suggestions("name") public Iterable suggestions(CommandContext context, String input) { /* ... */ } ``` -------------------------------- ### Example of Either Parser Usage Source: https://cloud.incendo.org/core Demonstrates how to use ArgumentParser.firstOf to create a parser that accepts either an integer or a boolean, and how to handle the parsed result. ```java commandBuilder.required("either", ArgumentParser.firstOf(integerParser(), booleanParser())) .handler(context -> { Either either = context.get("either"); if (either.primary().isPresent()) { int integer = either.primary().get(); } else { boolean bool = either.fallback().get(); } }); ``` -------------------------------- ### Gradle Kotlin DSL (NeoGradle) Source: https://cloud.incendo.org/minecraft/modded/neoforge Add this to your build.gradle.kts file to include Cloud for NeoForge using the NeoGradle setup. ```gradle repositories { mavenCentral() } jarJar.enable() dependencies { val cloudNeoforge = "org.incendo:cloud-neoforge:VERSION" implementation(cloudNeoforge) jarJar(cloudNeoforge) } ``` -------------------------------- ### Either Parser Example Source: https://cloud.incendo.org/core?q= Demonstrates creating an `Either` parser that attempts to parse an integer first, then a boolean. The handler logic shows how to access the parsed integer or boolean. ```java commandBuilder.required("either", ArgumentParser.firstOf(integerParser(), booleanParser())) .handler(context -> { Either either = context.get("either"); if (either.primary().isPresent()) { int integer = either.primary().get(); } else { boolean bool = either.fallback().get(); } }); ``` -------------------------------- ### Gradle Kotlin DSL Setup Source: https://cloud.incendo.org/minecraft/modded/fabric Add Cloud for Fabric to your project using the Kotlin DSL for Gradle. Ensure mavenCentral() is in your repositories. ```gradle repositories { mavenCentral() } dependencies { val cloudFabric = "org.incendo:cloud-fabric:VERSION" modImplementation(cloudFabric) include(cloudFabric) } ``` -------------------------------- ### Gradle Groovy DSL (NeoGradle) Source: https://cloud.incendo.org/minecraft/modded/neoforge Add this to your build.gradle file to include Cloud for NeoForge using the NeoGradle setup. ```gradle repositories { mavenCentral() } jarJar.enable() dependencies { def cloudNeoforge = 'org.incendo:cloud-neoforge:VERSION' implementation(cloudNeoforge) jarJar(cloudNeoforge) } ``` -------------------------------- ### Suspending Suggestion Provider Example Source: https://cloud.incendo.org/kotlin/annotations Shows how to create a suspending suggestion provider that returns a sequence of suggestions. This allows for asynchronous fetching or generation of suggestions. ```kotlin @Suggestions("custom-suggestions") suspend fun suggestionMethod( context: CommandContext, input: String ): Sequence = sequenceOf("a", "b", "c").map(Suggestion::simple) ``` -------------------------------- ### Configure Brigadier Settings Source: https://cloud.incendo.org/minecraft/brigadier?q= Example of how to access CloudBrigadierManager settings and set the FORCE_EXECUTABLE flag to true. ```java CloudBrigadierManager manager = commandManager.brigadierManager(); Configurable settings = manager.settings(); settings.set(BrigadierSetting.FORCE_EXECUTABLE, true); ``` -------------------------------- ### Examples of Unique Commands Source: https://cloud.incendo.org/core Illustrates different ways to define unique commands, including literal strings, required variables, and optional variables. ```plaintext /foo bar one /foo bar two -- Command with a required variable /bar [arg] -- Command with an optional variable ``` -------------------------------- ### PaperCommandManager with Sender Mapper Source: https://cloud.incendo.org/minecraft/paper?q= Example of creating a PaperCommandManager with a simple sender mapper and registering a command that targets players. ```java PaperCommandManager commandManager = PaperCommandManager .builder(PaperSimpleSenderMapper.simpleSenderMapper()) .executionCoordinator(executionCoordinator) .buildOnEnable(javaPlugin); // or: .buildBootstrapped(bootstrapContext); // this command will only be available to players, and the player type is directly available. commandManager.command(commandManager.commandBuilder("player_command") .senderType(PlayerSource.class) .handler(context -> { Player player = context.sender().source(); player.sendMessage("Hello, player!"); }) ); ``` -------------------------------- ### Gradle Kotlin DSL (Architectury Loom) Source: https://cloud.incendo.org/minecraft/modded/neoforge Add this to your build.gradle.kts file to include Cloud for NeoForge using the Architectury Loom setup. ```gradle repositories { mavenCentral() } dependencies { val cloudNeoforge = "org.incendo:cloud-neoforge:VERSION" modImplementation(cloudNeoforge) include(cloudNeoforge) } ``` -------------------------------- ### Gradle Groovy DSL Setup Source: https://cloud.incendo.org/minecraft/modded/fabric Add Cloud for Fabric to your project using the Groovy DSL for Gradle. Ensure mavenCentral() is in your repositories. ```gradle repositories { mavenCentral() } dependencies { def cloudFabric = 'org.incendo:cloud-fabric:VERSION' modImplementation(cloudFabric) include(cloudFabric) } ``` -------------------------------- ### Gradle Groovy DSL (Architectury Loom) Source: https://cloud.incendo.org/minecraft/modded/neoforge Add this to your build.gradle file to include Cloud for NeoForge using the Architectury Loom setup. ```gradle repositories { mavenCentral() } dependencies { def cloudNeoforge = 'org.incendo:cloud-neoforge:VERSION' modImplementation(cloudNeoforge) include(cloudNeoforge) } ``` -------------------------------- ### Install KordCommandManager Listener Source: https://cloud.incendo.org/discord/kord Register the command manager as a Kord event listener to handle command synchronization, execution, and autocompletion. ```kotlin commandManager.installListener(kord) ``` -------------------------------- ### Install Confirmation Annotation Modifier Source: https://cloud.incendo.org/processors/confirmation Install the ConfirmationBuilderModifier to enable the use of the @Confirmation annotation. ```java ConfirmationBuilderModifier.install(annotationParser); ``` -------------------------------- ### ReplySetting Annotation Source: https://cloud.incendo.org/discord/jda5 Explains how to use the `@ReplySetting` annotation with annotated commands after installing the necessary builder modifier. ```APIDOC ## ReplySetting Annotation ### Description If you are using annotated commands, you can use the `@ReplySetting` annotation to configure reply behavior. You must first install the `ReplySettingBuilderModifier`. ### Installation ```java ReplySettingBuilderModifier.install(annotationParser); ``` ### Usage ```java @ReplySetting(defer = true, ephemeral = true) @Command("command") public void yourCommand() { /* ... */ } ``` This example shows a command that defers its reply and makes it ephemeral. ``` -------------------------------- ### Install Command Scope Annotation Modifier Source: https://cloud.incendo.org/discord/kord Install the CommandScopeBuilderModifier to enable the use of @CommandScope annotations. ```kotlin CommandScopeBuilderModifier.install(annotationParser) ``` -------------------------------- ### Command with Presence Flag Source: https://cloud.incendo.org/core Example of how to define and check for the presence of a flag in a command. Flags are optional and parsed at the tail of a command chain. ```java manager.commandBuilder("command") .flag(manager.flagBuilder("flag").withAliases("f")) .handler(context -> { boolean present = context.flags().isPresent("flag"); })); ``` -------------------------------- ### CommandScope Annotation Source: https://cloud.incendo.org/discord/jda5 Explains how to use the `@CommandScope` annotation with annotated commands after installing the necessary builder modifier. ```APIDOC ## CommandScope Annotation ### Description If using annotated commands, you can use the `@CommandScope` annotation to define the command's registration scope. You must first install the `CommandScopeBuilderModifier`. ### Installation ```java CommandScopeBuilderModifier.install(annotationParser); ``` ### Usage ```java @CommandScope(guilds = { 1337 }) @Command("command") public void yourCommand() { /* ... */ } ``` This example registers the command only in the guild with ID 1337. ``` -------------------------------- ### Disallowed Command Structures Source: https://cloud.incendo.org/core Shows examples of command structures that are not allowed due to ambiguity, such as optional components following required ones or conflicting variable components. ```plaintext /foo one /foo two /foo bar ``` -------------------------------- ### Registering a Custom Integer Parser Source: https://cloud.incendo.org/core Register a custom parser supplier for a specific type in the parser registry. This example shows how to register a supplier for Integer, allowing for range customization via options. ```java parserRegistry.registerParserSupplier(TypeToken.get(Integer.class), options -> new IntegerParser<>( (int) options.get(StandardParameters.RANGE_MIN, Integer.MIN_VALUE), (int) options.get(StandardParameters.RANGE_MAX, Integer.MAX_VALUE) )); ``` -------------------------------- ### Suspending Command Method Example Source: https://cloud.incendo.org/kotlin/annotations Demonstrates how to define a suspending command method that can utilize Kotlin default parameter values and run operations within a specified coroutine context. ```kotlin @Command("command [argument]") suspend fun yourCommand( argument: String = "default value" ): Unit = withContext(Dispatchers.IO) { // ... } ``` -------------------------------- ### Custom UUID Argument Parser Implementation Source: https://cloud.incendo.org/core Provides an example of a custom parser for the UUID type. It demonstrates peeking and reading from CommandInput, and returning success or failure results. ```java public class UUIDParser implements ArgumentParser { @Override public @NonNull ArgumentParseResult parse( @NonNull CommandContext context, @NonNull CommandInput commandInput ) { final String input = commandInput.peekString(); // Does not remove the string from the input! try { final UUID uuid = UUID.fromString(input); commandInput.readString(); // Removes the string from the input. return ArgumentParseResult.success(uuid); } catch (final IllegalArgumentException e) { return ArgumentParseResult.failure(new UUIDParseException(input, context)); } } } ``` -------------------------------- ### Install Cooldown Annotation Modifier Source: https://cloud.incendo.org/processors/cooldown?q= Install the builder modifier to enable the @Cooldown annotation. ```java CooldownBuilderModifier.install(annotationParser); ``` -------------------------------- ### Register Help Command with Query Source: https://cloud.incendo.org/minecraft/minecraft-extras Implement a help command that accepts an optional query argument to filter help topics. ```java commandManager.command( commandManager.commandBuilder("helpcommand") .optional("query", greedyStringParser(), DefaultValue.constant("")) .handler(context -> { help.queryCommands(context.get("query"), context.sender()); }) ); ``` -------------------------------- ### Create Native MinecraftHelp Instance Source: https://cloud.incendo.org/minecraft/minecraft-extras Instantiate MinecraftHelp with default native audience support. Assumes YourSenderType extends Audience. ```java // Assuming YourSenderType extends Audience MinecraftHelp help = MinecraftHelp.createNative( "/helpcommand", commandManager ); ``` -------------------------------- ### Build MinecraftHelp with Custom Styling (Native) Source: https://cloud.incendo.org/minecraft/minecraft-extras Configure MinecraftHelp using a builder, customizing colors and other settings for native senders. ```java MinecraftHelp help = MinecraftHelp.builder() .commandManager(commandManager) .audienceProvider(AudienceProvider.nativeAudience()) .commandPrefix("/helpcommand") .colors(MinecraftHelp.helpColors(NamedTextColor.GREEN, NamedTextColor.RED, NamedTextColor.AQUA, NamedTextColor.BLACK, NamedTextColor.WHITE )) /* other settings... */ .build(); ``` -------------------------------- ### Build MinecraftHelp with Custom Styling (Other) Source: https://cloud.incendo.org/minecraft/minecraft-extras Construct a MinecraftHelp instance with a custom audience provider and styling for non-native sender types. ```java AudienceProvider audienceProvider = SenderType::audience; MinecraftHelp help = MinecraftHelp.builder() .commandManager(commandManager) .audienceProvider(audienceProvider) .commandPrefix("/helpcommand") .colors(MinecraftHelp.helpColors(NamedTextColor.GREEN, NamedTextColor.RED, NamedTextColor.AQUA, NamedTextColor.BLACK, NamedTextColor.WHITE )) /* other settings... */ .build(); ``` -------------------------------- ### Registering Requirements with Builders (Direct) Source: https://cloud.incendo.org/processors/requirements?q= Register requirements directly to a command builder using the meta() method and the previously defined CloudKey. ```java commandBuilder.meta(REQUIREMENT_KEY, Requirements.of(requirement, requirement1, ...)); ``` -------------------------------- ### Install CommandScope Builder Modifier Source: https://cloud.incendo.org/discord/jda5?q= Install the CommandScopeBuilderModifier to enable the @CommandScope annotation for annotated commands. This simplifies scope configuration. ```java CommandScopeBuilderModifier.install(annotationParser); ``` -------------------------------- ### Install ReplySetting Builder Modifier Source: https://cloud.incendo.org/discord/jda5?q= Install the ReplySettingBuilderModifier to enable the @ReplySetting annotation for annotated commands. This simplifies applying reply settings. ```java ReplySettingBuilderModifier.install(annotationParser); ``` -------------------------------- ### Registering Requirements with Builders (Applicable System) Source: https://cloud.incendo.org/processors/requirements?q= Use the RequirementApplicable system for registering requirements. First, create a factory, then apply it to the command builder. ```java // Store this somewhere: RequirementApplicable.RequirementApplicableFactory factory = RequirementApplicable.factory(REQUIREMENT_KEY); // Then register the requirements: commandBuilder.apply(factory.create(requirement, requirement1, ...)); ``` -------------------------------- ### Annotated Command Scope Source: https://cloud.incendo.org/discord/discord4j?q= Use the @CommandScope annotation with annotated commands after installing the builder modifier. ```java @CommandScope(guilds = { 1337 }) @Command("command") public void yourCommand() { /* ... */ } ``` -------------------------------- ### Help Command with Query Suggestions Source: https://cloud.incendo.org/minecraft/minecraft-extras Enhance the help command with suggestions for the query argument, providing available command syntaxes. ```java .optional( "query", greedyStringParser(), DefaultValue.constant(""), SuggestionProvider.blocking((ctx, in) -> commandManager.createHelpHandler() .queryRootIndex(ctx.sender()) .entries() .stream() .map(CommandEntry::syntax) .map(Suggestion::suggestion) .collect(Collectors.toList()) ) ) ``` -------------------------------- ### Build Native MinecraftHelp with Custom Colors Source: https://cloud.incendo.org/minecraft/minecraft-extras?q= Configure MinecraftHelp using a builder, specifying custom colors and native audience provider. ```java MinecraftHelp help = MinecraftHelp.builder() .commandManager(commandManager) .audienceProvider(AudienceProvider.nativeAudience()) .commandPrefix("/helpcommand") .colors(MinecraftHelp.helpColors(NamedTextColor.GREEN, NamedTextColor.RED, NamedTextColor.AQUA, NamedTextColor.BLACK, NamedTextColor.WHITE )) /* other settings... */ .build(); ``` -------------------------------- ### Build MinecraftHelp with Custom Audience Provider Source: https://cloud.incendo.org/minecraft/minecraft-extras?q= Construct a MinecraftHelp instance with a custom audience provider and command prefix. ```java AudienceProvider audienceProvider = SenderType::audience; MinecraftHelp help = MinecraftHelp.builder() .commandManager(commandManager) .audienceProvider(audienceProvider) .commandPrefix("/helpcommand") .colors(MinecraftHelp.helpColors(NamedTextColor.GREEN, NamedTextColor.RED, NamedTextColor.AQUA, NamedTextColor.BLACK, NamedTextColor.WHITE )) /* other settings... */ .build(); ``` -------------------------------- ### CloudKey for Requirements Source: https://cloud.incendo.org/processors/requirements?q= Create a CloudKey to store and access requirements in the command meta. Ensure the TypeToken is correctly specified. ```java public static final CloudKey> REQUIREMENT_KEY = CloudKey.of( "requirements", new TypeToken>() {} ); ``` -------------------------------- ### Creating an AnnotationParser Source: https://cloud.incendo.org/annotations?q= Instantiate an AnnotationParser. An optional mapper can be provided to map parser parameters to command meta. ```java // Parser without a CommandMeta mapper. AnnotationParser annotationParser = new AnnotationParser(commandManager); ``` ```java // Parser with a CommandMeta mapper. AnnotationParser annotationParser = new AnnotationParser( commandManager, parameters -> CommandMeta.empty() ); ``` -------------------------------- ### Allowed Command Structures Source: https://cloud.incendo.org/core Demonstrates valid command structures that avoid ambiguity, including valid placement of variable components and literals. ```plaintext /foo one /foo bar two /foo bar baz ``` -------------------------------- ### Defining a Standard Command Handler Source: https://cloud.incendo.org/core Shows how to define a command handler using a lambda expression that receives the command context. ```java builder.handler(ctx -> { // your command handling... }); ``` -------------------------------- ### Create ConfirmationManager Instance Source: https://cloud.incendo.org/processors/confirmation Instantiate ConfirmationManager with a ConfirmationConfiguration. ```java ConfirmationManager confirmationManager = ConfirmationManager.of(configuration); ``` -------------------------------- ### Creating a Default-Providing Method Source: https://cloud.incendo.org/annotations Implement a method to dynamically provide default values for command parameters. The method accepts a Parameter and returns a DefaultValue. ```java @Default(name = "method") // Could also be @Default without an explicit name! public DefaultValue method(Parameter parameter) { return DefaultValue.dynamic(context -> /* your logic */); } ``` -------------------------------- ### Annotated Command with Reply Setting Source: https://cloud.incendo.org/discord/jda5?q= Use the @ReplySetting annotation on an annotated command method to configure its reply behavior. Ensure the ReplySettingBuilderModifier is installed. ```java @ReplySetting(defer = true, ephemeral = true) @Command("command") public void yourCommand() { /* ... */ } ``` -------------------------------- ### Creating an Annotation Parser Source: https://cloud.incendo.org/annotations Instantiate an AnnotationParser. An optional mapper can be provided to map parser parameters to command meta. ```java // Parser without a CommandMeta mapper. AnnotationParser annotationParser = new AnnotationParser(commandManager); // Parser with a CommandMeta mapper. AnnotationParser annotationParser = new AnnotationParser( commandManager, parameters -> CommandMeta.empty() ); ``` -------------------------------- ### Custom Failure Handler Source: https://cloud.incendo.org/processors/requirements?q= Implement RequirementFailureHandler to define how to handle command failures due to unmet requirements. This example sends a message to the sender. ```java public final class YourFailureHandler implements RequirementFailureHandler { @Override public void handleFailure( final @NonNull CommandContext context, final YourRequirementInterface requirement ) { context.sender().sendMessage("Requirement failed: " + requirement.errorMessage()); } } ``` -------------------------------- ### Create a Suspending Argument Parser Source: https://cloud.incendo.org/kotlin/coroutines?q= Implement suspendingArgumentParser to create custom argument parsers that can perform suspending operations. This example shows parsing an integer. ```kotlin suspendingArgumentParser { ctx, input -> ArgumentParseResult.success(input.readInteger()) } ``` -------------------------------- ### Build ConfirmationConfiguration Source: https://cloud.incendo.org/processors/confirmation Configure the ConfirmationManager using a builder, optionally setting a cache and notifiers. ```java ConfirmationConfiguration.builder() .cache(cache) .noPendingCommandNotifier(...) .confirmationRequiredNotifier(...) .build(); ``` -------------------------------- ### Annotated Command with Specific Guild Scope Source: https://cloud.incendo.org/discord/jda5?q= Use the @CommandScope annotation with specific guild IDs to restrict an annotated command's availability. Ensure the CommandScopeBuilderModifier is installed. ```java @CommandScope(guilds = { 1337 }) @Command("command") public void yourCommand() { /* ... */ } ``` -------------------------------- ### Command Descriptions Source: https://cloud.incendo.org/core Add command descriptions using Command.Builder#commandDescription. The CommandDescription instance holds short and optional verbose descriptions. ```java // Using the CommandDescription.commandDescription static import with strings: builder.commandDescription(commandDescription("The description")); builder.commandDescription(commandDescription("The short description", "The verbose description")); // Using the CommandDescription.commandDescription static import with description objects: builder.commandDescription(commandDescription(Description.of("The description"))); ``` -------------------------------- ### Install Coroutine Support for Annotation Parser Source: https://cloud.incendo.org/kotlin/annotations Call this method to enable coroutine support within the annotation parser. You can optionally override the default coroutine scope and context. ```kotlin annotationParser.installCoroutineSupport() ``` -------------------------------- ### Apply Confirmation Meta Key Source: https://cloud.incendo.org/processors/confirmation Manually apply the META_CONFIRMATION_REQUIRED meta key to a command builder. ```java commandBuilder.meta(ConfirmationManager.META_CONFIRMATION_REQUIRED, true) ``` -------------------------------- ### Create a Suspending Suggestion Provider Source: https://cloud.incendo.org/kotlin/coroutines?q= Use suspendingSuggestionProvider to create custom suggestion providers that can perform suspending operations. This example provides suggestions as numbers 1 to 3. ```kotlin suspendingSuggestionProvider { ctx, input -> (1..3).asSequence() .map(Number::toString) .map(Suggestion::simple) .asIterable() } ``` -------------------------------- ### Register Command Manager as JDA Event Listener Source: https://cloud.incendo.org/discord/jda5?q= Register the command manager's listener with JDABuilder to handle commands. This setup is crucial for command synchronization and execution. ```java JDABuilder.createDefault(yourToken) .addEventListeners(commandManager.createListener()) .build(); ``` -------------------------------- ### Set Command Permission with DiscordPermission Source: https://cloud.incendo.org/discord/jda5?q= Set the default permission for a command using DiscordPermission.of(Long), which accepts JDA's Permission helper class. This example sets all permissions. ```java // Using JDA's Permission helper class. commandBuilder.permission(DiscordPermission.of(Permission.ALL_PERMISSION)) ``` -------------------------------- ### Create Command Builder via Command Manager Source: https://cloud.incendo.org/core It is recommended to create a new command builder through the command manager to tie it to the parser registry. ```java CommandManager#commandBuilder ``` -------------------------------- ### Defining a Future-Returning Command Handler Source: https://cloud.incendo.org/core Illustrates how to implement a command handler that returns a CompletableFuture, allowing for asynchronous command execution. ```java builder.futureHandler(ctx -> CompletableFuture.completedFuture(null)) ``` -------------------------------- ### Create MinecraftHelp Instance with Audience Mapper Source: https://cloud.incendo.org/minecraft/minecraft-extras Create a MinecraftHelp instance using a custom audience mapper to convert your sender type to an Adventure Audience. ```java MinecraftHelp help = MinecraftHelp.create( "/helpcommand", commandManager, audienceMapper // YourSenderType -> Audience ); ``` -------------------------------- ### Command Meta-Data Configuration Source: https://cloud.incendo.org/core Attach key-value pairs to commands using CloudKey. Configure meta-data in the command builder or when creating the command builder. ```java final CloudKey metaKey = CloudKey.of("your-key", String.class); commandBuilder.meta(metaKey, "your value"); ``` ```java final CloudKey metaKey = CloudKey.of("your-key", String.class); commandManager.commandBuilder("command", CommandMeta.builder().with(metaKey, "your value").build()); ``` -------------------------------- ### Build CooldownConfiguration Source: https://cloud.incendo.org/processors/cooldown?q= Configure cooldown settings, including the repository and event listeners. ```java CooldownRepository repository = CooldownRepository.forMap(new HashMap<>()); CooldownConfiguration configuration = CooldownConfiguration.builder() // ... .repository(repository) .addActiveCooldownListener(((sender, command, cooldown, remainingTime) -> { /* ... */})) .build(); ``` -------------------------------- ### Creating a Default-Providing Method Source: https://cloud.incendo.org/annotations?q= Define a method to provide default values. It accepts a Parameter and must return a DefaultValue instance. ```java @Default(name = "method") // Could also be @Default without an explicit name! public DefaultValue method(Parameter parameter) { return DefaultValue.dynamic(context -> /* your logic */); } ``` -------------------------------- ### Create RichDescription using Alias Source: https://cloud.incendo.org/minecraft/minecraft-extras Use the statically importable alias RichDescription.richDescription() as an alternative to RichDescription.of(). ```java Description description = RichDescription.richDescription(text("Hello world!")); ``` -------------------------------- ### Apply Cooldown via Meta Source: https://cloud.incendo.org/processors/cooldown?q= Manually set the cooldown duration meta value on a command builder. ```java commandBuilder.meta(CooldownManager.META_COOLDOWN_DURATION, cooldown); ``` -------------------------------- ### Compound Permissions (All Of) Source: https://cloud.incendo.org/annotations?q= Define a command that requires all of the specified permissions. ```java @Permission(value = { "permission.1", "permission.2" }, mode = Permission.Mode.ALL_OF) ``` -------------------------------- ### Simple String Permission Source: https://cloud.incendo.org/annotations?q= Assign a single string permission to a command method. ```java @Permission("the.permission") ``` -------------------------------- ### Create TextColor Parser Source: https://cloud.incendo.org/minecraft/minecraft-extras Instantiate a TextColorParser using its static factory method. This parser handles named colors, legacy color codes, and hex codes. ```java ParserDescriptor parser = TextColorParser.textColorParser(); ``` -------------------------------- ### DiscordSetting for Behavior Modification Source: https://cloud.incendo.org/discord/jda5 Explains how to modify specific behaviors of the command manager using `DiscordSetting`s. ```APIDOC ## DiscordSetting for Behavior Modification ### Description You can modify certain behaviors of the `JDA5CommandManager` using `DiscordSetting`s. These settings allow for fine-tuning the command manager's operation. ### Accessing Settings You can access the `Configurable` instance using `JDA5CommandManager.discordSettings()`. This provides a way to customize aspects like command cooldowns, message formatting, and other Discord-specific behaviors. ``` -------------------------------- ### Command Method with Argument and Qualifier Injection Source: https://cloud.incendo.org/spring?q= Demonstrates injecting Spring beans with @Qualifier into command methods that accept arguments. ```java @CommandMethod("command ") public void yourCommand( @Argument String argument, @Qualifier("bean") SomeBean someBean ) { // ... } ``` -------------------------------- ### Creating Rich Descriptions Source: https://cloud.incendo.org/minecraft/minecraft-extras?q= Use RichDescription.of() or RichDescription.richDescription() for basic text, and RichDescription.translatable() for translatable components with arguments. ```java // Static factory: Description description = RichDescription.of(text("Hello world!")); // Statically importable alias: Description description = RichDescription.richDescription(text("Hello world!")); // Utility for translatable components: Description description = RichDescription.translatable("some.key", text("an arg")); ``` -------------------------------- ### Simple Execution Coordinator Source: https://cloud.incendo.org/core Creates a simple execution coordinator where parsing and suggestion generation occur on the calling thread unless redirected. ```java ExecutionCoordinator.simpleCoordinator() ``` -------------------------------- ### Maven Repository for Sonatype Snapshots Source: https://cloud.incendo.org/ Add this Maven repository configuration to your pom.xml to access development builds of Cloud. ```xml sonatype-snapshots https://central.sonatype.com/repository/maven-snapshots/ ``` -------------------------------- ### Register Asynchronous Completions with Legacy Command Manager Source: https://cloud.incendo.org/minecraft/paper?q= Enable asynchronous completions for the legacy command manager if the capability is present. ```java if (commandManager.hasCapability(CloudBukkitCapabilities.ASYNCHRONOUS_COMPLETION)) { commandManager.registerAsynchronousCompletions(); } ``` -------------------------------- ### Registering Command Manager as JDA Event Listener Source: https://cloud.incendo.org/discord/jda5 Shows how to register the command manager's listener with JDA to handle command synchronization, execution, and autocompletion. ```APIDOC ## Registering Command Manager as JDA Event Listener ### Description Registers the `JDA5CommandManager` as a JDA event listener to enable command handling, including synchronization, execution, and autocompletion. ### Usage ```java JDABuilder.createDefault(yourToken) .addEventListeners(commandManager.createListener()) .build(); ``` This ensures that the JDA bot listens for and processes commands managed by the `JDA5CommandManager`. ``` -------------------------------- ### Mapping CooldownRepository Source: https://cloud.incendo.org/processors/cooldown?q= Create a repository that maps senders to their cooldown profiles using a persistent key. ```java CooldownRepository repository = CooldownRepository.mapping( YourSenderType::uuid, CooldownRepository.forMap(new HashMap<>()) ); ``` -------------------------------- ### mods.toml Dependency Configuration Source: https://cloud.incendo.org/minecraft/modded/neoforge Configure the 'cloud' dependency in your mods.toml file to ensure compatibility with other mods. ```toml [[dependencies.your_mod_id]] modId = "cloud" type = "required" versionRange = "[1.0,)" ordering = "NONE" side = "BOTH" ``` -------------------------------- ### Gradle Groovy DSL (NeoGradle) Source: https://cloud.incendo.org/minecraft/modded/neoforge?q= Add Cloud NeoForge as a dependency using the Groovy DSL for NeoGradle. Ensure mavenCentral() is in your repositories and jarJar is enabled. ```gradle repositories { mavenCentral() } jarJar.enable() dependencies { def cloudNeoforge = 'org.incendo:cloud-neoforge:VERSION' implementation(cloudNeoforge) jarJar(cloudNeoforge) } ``` -------------------------------- ### Registering Requirement Postprocessor Source: https://cloud.incendo.org/processors/requirements?q= Instantiate and register the RequirementPostprocessor with the command manager. A custom failure handler is required. ```java final RequirementPostprocessor postprocessor = RequirementPostprocessor.of( REQUIREMENTS_KEY, new YourFailureHandler() ); commandManager.registerPostprocessor(postprocessor); ``` -------------------------------- ### JDA5CommandManager Initialization Source: https://cloud.incendo.org/discord/jda5 Demonstrates how to initialize the JDA5CommandManager with either the native JDAInteraction sender type or a custom sender type. ```APIDOC ## JDA5CommandManager Initialization ### Description Initializes the `JDA5CommandManager` for handling Discord slash commands. You can use the native `JDAInteraction` sender or a custom sender type. ### Usage ```java // Using the "native" JDAInteraction sender type: JDA5CommandManager commandManager = new JDA5CommandManager<>( executionCoordinator, JDAInteraction.InteractionMapper.identity() ); // Using a custom sender type: JDA5CommandManager commandManager = new JDA5CommandManager<>( executionCoordinator, interaction -> yourSenderType ); ``` Replace `executionCoordinator` with an `ExecutionCoordinator` instance and `YourSenderType` with your custom sender type. ``` -------------------------------- ### Gradle (Kotlin) Repository for Sonatype Snapshots Source: https://cloud.incendo.org/ Configure your Gradle build script (Kotlin DSL) to include the Sonatype Snapshots Repository for development builds. ```kotlin maven("https://central.sonatype.com/repository/maven-snapshots/") { name = "sonatype-snapshots" mavenContent { snapshotsOnly() } } ``` -------------------------------- ### Set Command Permissions using Builder Source: https://cloud.incendo.org/discord/kord Set default permissions for a command using the permissions builder, granting Administrator permission. ```kotlin permissions(Permissions(Permission.Administrator)) ``` -------------------------------- ### Create Confirmation Command Source: https://cloud.incendo.org/processors/confirmation Create a 'confirm' command that uses the confirmation manager's execution handler. ```java commandManager.command( commandManager.commandBuilder("confirm") .handler(confirmationManager.createExecutionHandler()) ); ``` -------------------------------- ### Gradle Kotlin DSL (NeoGradle) Source: https://cloud.incendo.org/minecraft/modded/neoforge?q= Add Cloud NeoForge as a dependency using the Kotlin DSL for NeoGradle. Ensure mavenCentral() is in your repositories and jarJar is enabled. ```gradle repositories { mavenCentral() } jarJar.enable() dependencies { val cloudNeoforge = "org.incendo:cloud-neoforge:VERSION" implementation(cloudNeoforge) jarJar(cloudNeoforge) } ``` -------------------------------- ### DiscordPermission for Command Permissions Source: https://cloud.incendo.org/discord/jda5 Shows how to set default command permissions using `DiscordPermission.of(Long)`. ```APIDOC ## DiscordPermission for Command Permissions ### Description You can set the default permissions for commands using `DiscordPermission.of(Long)`. ### Usage ```java // Using JDA's Permission helper class. commandBuilder.permission(DiscordPermission.of(Permission.ALL_PERMISSION)) ``` This example sets the permission to `ALL_PERMISSION` for the command. You can also use ordinary permissions by setting the permission function in `JDA5CommandManager`. ``` -------------------------------- ### Command Method with Argument Mapping Source: https://cloud.incendo.org/annotations?q= Map method parameters to command syntax fragments using @Argument annotations. Parameter names can be inferred if compiled with -parameters. ```java @Command("command [optional]") public void yourCommand( @Argument(value = "required", description = "A string") String string, // Uses a name override! @Nullable String optional // Name is inferred, and so is @Argument! ) { // ... } ``` -------------------------------- ### Gradle Groovy DSL (Architectury Loom) Source: https://cloud.incendo.org/minecraft/modded/neoforge?q= Add Cloud NeoForge as a dependency using the Groovy DSL for Architectury Loom. Ensure mavenCentral() is in your repositories. ```gradle repositories { mavenCentral() } dependencies { def cloudNeoforge = 'org.incendo:cloud-neoforge:VERSION' modImplementation(cloudNeoforge) include(cloudNeoforge) } ``` -------------------------------- ### Create Translatable RichDescription Source: https://cloud.incendo.org/minecraft/minecraft-extras Use RichDescription.translatable() to create a description from a translation key and arguments. This is useful for localized descriptions. ```java Description description = RichDescription.translatable("some.key", text("an arg")); ``` -------------------------------- ### Gradle Kotlin DSL (Architectury Loom) Source: https://cloud.incendo.org/minecraft/modded/neoforge?q= Add Cloud NeoForge as a dependency using the Kotlin DSL for Architectury Loom. Ensure mavenCentral() is in your repositories. ```gradle repositories { mavenCentral() } dependencies { val cloudNeoforge = "org.incendo:cloud-neoforge:VERSION" modImplementation(cloudNeoforge) include(cloudNeoforge) } ``` -------------------------------- ### Creating BungeeCommandManager Source: https://cloud.incendo.org/minecraft/bungee?q= Instantiate BungeeCommandManager with your plugin, an execution coordinator, and a sender mapper. Use SenderMapper.identity() if CommandSender is your sender type. ```java BungeeCommandManager commandManager = new BungeeCommandManager<>( plugin, executionCoordinator, senderMapper ); ``` -------------------------------- ### Accessing Parsed Values and Flags in Command Context Source: https://cloud.incendo.org/core Demonstrates how to retrieve parsed string values, check for flag presence, access the command sender, and inject typed collections from the command context. ```java final CloudKey nameKey = CloudKey.of("name", String.class); final String parsedName = commandContext.getOrDefault(nameKey, "Default Name"); final boolean overrideFlag = commandContext.flags().hasFlag("override"); final CommandSender sender = commandContext.sender(); final List cats = commandContext.inject(new TypeToken>() {}); ``` -------------------------------- ### Registering an Injection Service Source: https://cloud.incendo.org/annotations?q= Register an injection service with the parameter registry. ```java manager.parameterInjectionRegistry().registerInjectionService(theService); ``` -------------------------------- ### Register Command with Integer Choices Source: https://cloud.incendo.org/discord/kord Register a command with an integer option that uses DiscordChoices for predefined integer suggestions. ```kotlin commandBuilder.required( "integer", integerParser(), DiscordChoices.integers(1, 2, 3) ) ``` -------------------------------- ### Defer Reply with Ephemeral Response Source: https://cloud.incendo.org/discord/jda5?q= Apply ReplySetting.defer(true) to a command builder to automatically defer the slash command reply and send an ephemeral response. This is useful for commands that require a moment to process. ```java // Defer with an ephemeral response: commandBuilder.apply(ReplySetting.defer(true)); ``` -------------------------------- ### Parsers and Suggestion Handlers Returning Futures Source: https://cloud.incendo.org/cloud-v2?q= The command tree now supports `CompletableFuture`, allowing parsers and suggestion providers to return futures for asynchronous operations. ```java public interface ArgumentParser { CompletableFuture parse(CommandContext context, CommandInput input); } public interface SuggestionProvider { CompletableFuture> provideSuggestions(CommandContext context, StringLiteral literal); } ``` -------------------------------- ### Compound Permissions (Any Of) Source: https://cloud.incendo.org/annotations?q= Define a command that requires at least one of the specified permissions. ```java @Permission(value = { "permission.1", "permission.2" }, mode = Permission.Mode.ANY_OF) ``` -------------------------------- ### Defer Reply with Non-Ephemeral Response Source: https://cloud.incendo.org/discord/jda5?q= Apply ReplySetting.defer(false) to a command builder to automatically defer the slash command reply with a non-ephemeral response. Use this for commands that will take time to process and should be visible to all users. ```java // Defer with a non-ephemeral response: commandBuilder.apply(ReplySetting.defer(false)); ``` -------------------------------- ### Gradle (Kotlin) Dependency for Cloud Minecraft Extras Source: https://cloud.incendo.org/minecraft/minecraft-extras Include this line in your build.gradle.kts file to add cloud-minecraft-extras as an implementation dependency. ```gradle implementation("org.incendo:cloud-minecraft-extras:2.0.0-beta.10") ``` -------------------------------- ### Registering Requirements with Annotations Source: https://cloud.incendo.org/processors/requirements?q= Bind custom annotations to requirements using RequirementBindings. This allows annotating command methods to apply requirements. ```java // Create some annotation: @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface YourAnnotation { // ... } // Then register a binding for it: RequirementBindings.create(this.annotationParser, REQUIREMENT_KEY).register( YourAnnotation.class, annotation -> new YourRequirement() ); // Then annotate a method with it: @YourAnnotation @Command("command") public void commandMethod() { // ... } ``` -------------------------------- ### Registering a Command Builder Source: https://cloud.incendo.org/core?q= Registers a command builder with the command manager to make the command recognized. ```java commandManager.command(Command.newBuilder(MyCommand.class)...) ``` -------------------------------- ### Permission Combinations Source: https://cloud.incendo.org/core Combine permissions using Permission.anyOf or Permission.allOf. PredicatePermission.of can be used for custom predicate-based permissions. ```java Permission.anyOf(Permission...) Permission.allOf(Permission...) PredicatePermission.of(Predicate) ``` -------------------------------- ### Implementing Complex Suggestions Source: https://cloud.incendo.org/cloud-v2?q= Suggestions are now handled via a `Suggestion` interface, allowing for richer suggestion types beyond simple strings. Implement `stringSuggestions()` for string-based suggestions. ```java public class MySuggestionProvider implements SuggestionProvider { @Override public CompletableFuture> provideSuggestions(CommandContext context, StringLiteral literal) { // ... implementation ... } // For string suggestions public CompletableFuture> stringSuggestions(CommandContext context, StringLiteral literal) { // ... implementation ... } } ``` -------------------------------- ### Set Command Permissions using Vararg Source: https://cloud.incendo.org/discord/kord Set default permissions for a command using the vararg overload, granting Administrator permission. ```kotlin permissions(Permission.Administrator) ``` -------------------------------- ### Manual Command Synchronization Source: https://cloud.incendo.org/discord/jda5 Provides methods for manually synchronizing commands with Discord guilds or globally. ```APIDOC ## Manual Command Synchronization ### Description Allows for manual synchronization of commands with Discord. You can register commands to specific guilds or globally. ### Methods - `JDA5CommandManager.registerGuildCommands(Guild)`: Registers commands for a specific guild. - `JDA5CommandManager.registerGlobalCommands(JDA)`: Registers commands globally. These methods are useful for controlling when and where your commands are updated on Discord. ```