CommandsAPI - Enhanced Commands Creation icon

CommandsAPI - Enhanced Commands Creation -----

CommandsAPI is a framework designed to enhance and simplify command management on Spigot servers.



CommandsAPI v4.2.0 – Hierarchical CommandTree & Simplified Usage Formatting
Changelog – Version 4.2.0
This release adds a hierarchical command tree, improves default usage formatting, and lays the groundwork for more flexible subcommand management. It remains backward-compatible with 4.1.x.

Major Changes
Prefix-Tree Command Registry
  • Replaced the flat Map<String, Command> with a new CommandTree<T, S> data structure.
    • Commands and subcommands are now stored in a trie, keyed by dot-separated paths (e.g. "base.sub.subsub").
    • Lookup via findNode(base, rawArgs) returns the most specific matching node plus any leftover arguments.
    • Removal via removeCommand(label, prune) can either clear a single node or prune an entire subtree.
  • Introduced CommandNode<T, S> to represent each segment in the tree, with optional command payload and child-tracking (hadChildren) flags.
Refactored Default Usage Generation
  • Overhauled generateDefaultUsage(...) to show only one level of subcommands, then required and optional arguments.
    • Usage now prints:
      1. Full command path (/parent child …)
      2. First-level subcommand choices (<sub1|sub2>)
      3. Required args (<arg>…) and optional args ([opt]…)
  • Backward-compatible: existing explicit setUsage(...) overrides still apply.
✨ New Features
Improved Lookup & Autocomplete
  • Subcommands are no longer flat—autocomplete and invocation automatically traverse the tree.
  • Arguments fallback correctly when a node has no children but still accepts parameters.
Expanded Test Coverage
  • Added unit tests for CommandTree and CommandNode covering:
    • Adding and finding nested commands
    • Matching with extra args and partial paths
    • Removing nodes with both prune and “clear only” semantics
  • Updated existing CommandInvoker tests to work against the new tree-based lookup.
Bug Fixes & Tweaks
  • Fixed edge cases in removeCommand:
    • Pruning a branch now properly removes children and resets parent flags.
    • Clearing a command on a leaf node without children now unregisters that node.
  • Cleaned up legacy methods that referenced the old flat map.
General Improvements
  • Simplified the addCommand(label, command) API to accept full paths directly.
  • Streamlined tree traversal code with clearer branch and command-presence checks.
  • Minor logging enhancements when adding or removing commands from the tree.
⚠️ Migration Guide
  1. Update your dependency to 4.2.0:

    implementation "com.github.Traqueur-dev:core:4.2.0"
    implementation "com.github.Traqueur-dev:CommandsAPI-platform-<your-platform>:4.2.0"
  2. Review any custom invocation code: switch from manager.getCommands().get(label) to manager.getCommands().findNode(base, rawArgs) in CommandInvoker.

  3. Adjust tests or tooling that assumed a flat map of labels. All lookups now go through CommandTree.

  4. Verify your usage messages: autogenerated usage strings now show only one subcommand level; if you relied on deeper nesting, update your custom setUsage(...) or test expectations.
Full Changelog: 4.1.0...4.2.0
----------, Today at 9:21 AM
Resource Information
Author:
----------
Total Downloads: 267
First Release: Jul 29, 2024
Last Update: Today at 9:21 AM
Category: ---------------
All-Time Rating:
0 ratings
Version -----
Released: --------------------
Downloads: ------
Version Rating:
----------------------
-- ratings