Skip to content
This repository was archived by the owner on Apr 12, 2026. It is now read-only.

Refactor DaisyCommands to 2.0 runtime and typed DSL#16

Merged
DaisyCatTs merged 4 commits into
masterfrom
feature/release/2-0-runtime-dsl
Mar 20, 2026
Merged

Refactor DaisyCommands to 2.0 runtime and typed DSL#16
DaisyCatTs merged 4 commits into
masterfrom
feature/release/2-0-runtime-dsl

Conversation

@DaisyCatTs
Copy link
Copy Markdown
Owner

@DaisyCatTs DaisyCatTs commented Mar 20, 2026

  • Replace mutable command model with compiled CommandRuntime dispatcher
  • Migrate DSL/API toward typed ArgumentRef<T> and new command/sub/execute style
  • Switch to Paper registerCommands(...) registration and remove old SubCommand
  • Add migration guide, rewrite README for 2.0, and add core runtime tests

Summary by CodeRabbit

Release Notes - v3.0.0

  • New Features

    • Complete redesign as Kotlin-only command framework with modern DSL
    • Typed argument references replacing string-key access
    • Configurable messaging and theme system
    • Enhanced flags and options as first-class citizens
  • Documentation

    • Added migration guide for upgrading to 3.0
    • Entirely redesigned README with Kotlin-focused examples
  • Chores

    • Updated minimum requirement to Paper 1.21.11
    • Upgraded Kotlin to 2.3.20

- Replace mutable command model with compiled `CommandRuntime` dispatcher
- Migrate DSL/API toward typed `ArgumentRef<T>` and new `command/sub/execute` style
- Switch to Paper `registerCommands(...)` registration and remove old `SubCommand`
- Add migration guide, rewrite README for 2.0, and add core runtime tests
- Bump Kotlin from 2.3.0 to 2.3.20
- Upgrade Gradle wrapper to 9.4.1
- Switch upload-artifact action from v6 to v4
- Delete README.md
- Add a new README covering 2.0 DSL usage, features, and installation
- Rewrite MIGRATION.md with before/after API examples and upgrade checklist
- Clarify deprecated 1.x shims and emphasize Paper-only 2.0 registration flow
- Bump library/version docs to 3.0.0 and target Paper 1.21.11
- Remove legacy `DaisyCommand` compatibility API and string-key context access
- Extend runtime DSL with first-class flags/options, defaults, validation, and suggestions
- Refresh migration/README guidance and fix CI artifact upload path
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 20, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This major version upgrade (1.0.0 → 3.0.0) transforms DaisyCommands into a Kotlin-only, Paper-focused framework. Changes include: removal of Java compatibility APIs, introduction of a new CommandSpec/CompiledCommand execution model with CommandRuntime, complete redesign of argument handling via ArgumentRef and DaisyParser with context carriers, replacement of legacy SubCommand framework with a DSL-based builder pattern, refactoring of context APIs for typed argument retrieval, migration of cooldown semantics from milliseconds to Duration, removal of text utility functions and color conversion, and comprehensive test coverage.

Changes

Cohort / File(s) Summary
Project Configuration
build.gradle.kts, gradle.properties, gradle/wrapper/gradle-wrapper.properties, .github/workflows/build.yml
Version bumps: Kotlin 2.3.0→2.3.20, project 1.0.0→3.0.0, Paper 1.21.10→1.21.11, Gradle 9.3.0→9.4.1. JAR artifact path changed from Jar/*.jar to build/libs/*.jar. Removed custom JAR copying logic. Added test dependencies (JUnit, Mockito, Kotlin test).
Core Command Execution Runtime
src/main/kotlin/cat/daisy/command/core/CommandRuntime.kt
Introduces new 1227-line CommandRuntime module with CommandSpec/CompiledCommand/CompiledNode execution model. Implements command compilation with validation (name patterns, argument rules, alias checks), argument parsing with option/flag/positional support, help rendering, and autocompletion. Defines SenderConstraint enum and CooldownSpec data class for constraint/cooldown metadata.
Command DSL & Registration
src/main/kotlin/cat/daisy/command/core/DaisyCommands.kt, src/main/kotlin/cat/daisy/command/dsl/CommandDSL.kt
Replaced singleton DaisyCommands with JavaPlugin.registerCommands extension functions. New CommandBuilder DSL producing immutable CommandSpec. Replaced old daisyCommand/buildCommand with command(...) root builder. Unified handler configuration via execute, executePlayer, executeConsole. New CommandSetBuilder for grouping multiple commands with shared DaisyConfig. Introduced PaperCommandAdapter integrating with Paper's command system.
Configuration & Rendering
src/main/kotlin/cat/daisy/command/core/DaisyConfig.kt
New module defining DaisyTheme, DaisyMessages, renderer interfaces (DaisyHelpEntryRenderer, DaisyArgumentErrorRenderer, DaisyCooldownRenderer), and DaisyConfigBuilder DSL for message/theme customization.
Argument Parsing System
src/main/kotlin/cat/daisy/command/arguments/Arguments.kt
Complete overhaul: replaced ArgParser<T> with DaisyParser<T> taking ParseContext/SuggestContext. Removed ArgumentDef and subclasses; introduced ArgumentRef<T> with MutableArgumentDefinition supporting optional(), default(), suggests(), validate(). Introduced DaisyPlatform abstraction for resolving Player/OfflinePlayer/World via context. Renamed parsers (e.g., GREEDY_STRINGTEXT), updated all built-in parsers to new interface.
Context & Execution State
src/main/kotlin/cat/daisy/command/context/Context.kt
Removed string-keyed argument access, positional helpers, cooldown methods, parser APIs. Added ResolvedArguments for typed argument retrieval by ArgumentRef. Reworked CommandContext constructor to accept resolvedArguments: ResolvedArguments and runtime: CommandRuntime. Introduced PlayerCommandContext and ConsoleCommandContext (internal constructors). Added fail(message): Nothing and AbortExecution sentinel exception. Removed TabContext and TabIndexBuilder.
Cooldown System
src/main/kotlin/cat/daisy/command/cooldown/DaisyCooldowns.kt
Migrated from millisecond/seconds semantics to java.time.Duration and java.time.Instant. Removed getRemainingCooldown, checkCooldown, isOnCooldown, bypass-aware checks, manual reset variants. Added Duration-based remaining(), set(), clear() (player/global), unified clearAll(). Updated formatting to format(Duration).
Legacy API Removal
src/main/kotlin/cat/daisy/command/DaisyCommand.kt, src/main/kotlin/cat/daisy/command/core/SubCommand.kt
Deleted DaisyCommand.kt (123 lines): removed DaisyCommandAPI with VERSION, create(), build() and type aliases (DaisyCmd, SubCmd, CmdContext, etc.). Deleted SubCommand.kt (431 lines): removed entire SubCommand class, SubCommandData, and legacy argument parsing/completion utilities.
Text & Logging Utilities
src/main/kotlin/cat/daisy/command/text/DaisyText.kt
Removed color conversion (convertLegacyColors), raw MiniMessage parsing (mmRaw), text gradients/rainbows, placeholder replacement, and all console logging (log, logInfo, logSuccess, etc.). Simplified String.mm() to deserialize directly. Removed Colors object.
Documentation & Testing
README.md, MIGRATION.md, src/test/kotlin/cat/daisy/command/core/DaisyCommandsTest.kt
Rewrote README positioning DaisyCommands as Kotlin-only, Paper-focused; updated install coords to 3.0.0, PaperMC Maven repo, and usage examples. Added 208-line MIGRATION.md documenting upgrade path from 2.x, breaking changes, and before/after DSL examples. Added comprehensive 449-line DaisyCommandsTest covering compilation, execution, parsing, help, cooldown, and suggestion validation.

Sequence Diagram(s)

sequenceDiagram
    participant Builder as DSL Builder<br/>(CommandBuilder)
    participant Compiler as Command Compiler
    participant CompiledCmd as CompiledCommand
    participant Runtime as CommandRuntime
    participant Handler as Handler<br/>(execute block)

    Builder->>Compiler: CommandSpec with<br/>arguments, handlers,<br/>children
    Compiler->>Compiler: Validate node rules,<br/>argument constraints,<br/>build lookup tables
    Compiler->>CompiledCmd: Create compiled<br/>executable structure
    
    Note over CompiledCmd: Ready for execution

    CompiledCmd->>Runtime: execute(sender, args,<br/>config)
    Runtime->>Runtime: Resolve target node<br/>via arg traversal
    Runtime->>Runtime: Check permission &<br/>sender constraint
    Runtime->>Runtime: Parse arguments<br/>(options, flags,<br/>positionals)
    Runtime->>Runtime: Check requirements<br/>& cooldown bypass
    Runtime->>Handler: Invoke handler with<br/>ResolvedArguments
    Handler->>Handler: Access typed args<br/>via ArgumentRef<T>
    Handler-->>Runtime: Execute completes
    Runtime->>Runtime: Apply cooldown<br/>if successful
    Runtime-->>CompiledCmd: Execution result
Loading
sequenceDiagram
    participant Parser as DaisyParser<T>
    participant ParseCtx as ParseContext<br/>(with Platform)
    participant Platform as DaisyPlatform<br/>(BukkitPlatform)
    participant Bukkit as Bukkit API

    Parser->>ParseCtx: parse(input, context)
    ParseCtx->>Platform: Resolve player/world/<br/>other types via<br/>context.platform
    Platform->>Bukkit: Bukkit.getPlayer(name)<br/>Bukkit.getWorld(name)
    Bukkit-->>Platform: Return resolved entity
    Platform-->>ParseCtx: Provide resolved object
    ParseCtx-->>Parser: Return typed T or<br/>parse failure
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐰 A rabbit's ode to the refactor grand,
Commands now compiled, not made by hand!
ArgumentRef holds types so true,
CommandRuntime flows, fresh and new!
Paper shall sing with Kotlin's grace,
Legacy gone—let's embrace this space! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Title describes a major version refactor (2.0 runtime and typed DSL), which is accurate but overshadows the final version bump to 3.0.0 with additional features (flags, options, validation).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/release/2-0-runtime-dsl
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can enable review details to help with troubleshooting, context usage and more.

Enable the reviews.review_details setting to include review details such as the model used, the time taken for each step and more in the review comments.

@DaisyCatTs DaisyCatTs merged commit 90bd15b into master Mar 20, 2026
1 of 2 checks passed
@DaisyCatTs DaisyCatTs deleted the feature/release/2-0-runtime-dsl branch March 20, 2026 02:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant