Skip to content

v1.9.0

Choose a tag to compare

@Mqzn Mqzn released this 21 Apr 14:32
· 684 commits to master since this release

Ultra Update

This is the biggest release ever, containing alot of enhancements and bug fixes

✨ Enhancements

  • Improve workflow drastically for failure, Test allowing @SubCommand to act as shortcuts for @Usage by @iiAhmedYT in #6

  • Allow @ContextResolved to be placed on a class of a custom type to remove the need
    for the user to write the annotation every time on different command metods, by @iiAhmedYT in #7

  • Brigadier Internal Check
    Introduces a safeguard against unsupported internal operations to improve stability.

  • OptionalValueSupplier Refactor
    Redesigned to accept only string values—generic parameters have been removed for clarity.

  • ParameterType Refactor

    • Streamlined parsing logic and data structures for more reliable type handling.
    • Removed fromString method and added String input parameter to the resolve method.
    • The constructor requires Type now instead of TypeWrap
  • Command Tree Optimization
    Accelerates command-tree construction for snappier performance.

  • Annotation Harmony
    Allows @Usage and @SubCommand to coexist on the same method, boosting flexibility.

  • Context Resolution Guard
    Now enforces the @ContextResolved annotation before any ContextResolved parameters.

  • Annotation Map Preservation
    Retains unreplaced annotations in the internal map for seamless downstream processing.

  • Attachment Mode
    Adds a new AttachmentMode enum which defines how sub commands are attached to its parent command.
    The default value is UNSET.

    public enum AttachmentMode {
      /**
       * Attaches the subcommand to an empty usage of the {@link Command}
       */
      EMPTY,
      /**
       * Attaches the subcommand to the default usage of a {@link Command},
       * which may be empty or contain optional arguments/parameters.
       */
      DEFAULT,
      /**
       * Attaches the sub command to the main {@link CommandUsage} of a {@link Command}
       * A main usage is a usage that contains required arguments/parameters.
       */
      MAIN,
      /**
       * Behaves exactly like {@link AttachmentMode#MAIN},
       * It's used internally to know when to prefer the global attachment mode over the per subcommand one.
       */
      UNSET
    }
  • New Annotation @GlobalAttachmentMode
    Lets you define the default attachment mode
    of a command's subcommands to reduce boilerplate code.

  • Per command help provider
    Added new @Help to be placed below @Command to set help providers per commands.
    Example:

    @Command("mycommand")
    @Help(MyHelpProvider.class)
    public class MyCommand {
       //your command class
    }
    
    public class MyHelpProvider implements HelpProvider<YourPlatformSource> {
      @Override
      public void provide(ExecutionContext<S> context, S source) throws ImperatException {
         //implement your help sending logic here
      }
    }
  • API Update

    • Some Public-facing methods are no longer marked internal, making your API boundaries clearer.
    • Added Command#setDefaultUsage
    • Added Command#setHelpProvider and its builder method Command.Builder#helpProvider
    • Added a constant empty usage for every command being created, that can be fetched by calling Command#getEmptyUsage()

🐛 Bug Fixes

  • Repeatable SubCommands
    Fixed @SubCommand so you can now declare multiple methods with the same name to define different usages.

  • Argument Requirement Relaxation
    Removed the restriction that the first argument must be required, allowing optional-first usage.

  • AnnotationReplacer Correction
    Resolved an issue where certain annotations weren’t replaced when using AnnotationReplacer.

Full Changelog:

https://github.com/VelixDevelopments/Imperat/releases/tag/v1.9.0