diff options
| author | Sho Sakuma <me@m1sk9.dev> | 2026-08-03 15:19:08 +0900 |
|---|---|---|
| committer | Sho Sakuma <me@m1sk9.dev> | 2026-08-05 01:16:03 +0900 |
| commit | d45db164428bb4b350c879bf3f43ceb1cc581955 (patch) | |
| tree | 2c9ccedf53e5a24597631c97e20201e1caeaff29 /engine/src/test | |
| parent | 576c057bb98dab27c2b97931fc5635603fe1bf57 (diff) | |
| download | LunaticChat-d45db164428bb4b350c879bf3f43ceb1cc581955.tar.gz LunaticChat-d45db164428bb4b350c879bf3f43ceb1cc581955.tar.bz2 LunaticChat-d45db164428bb4b350c879bf3f43ceb1cc581955.zip | |
refactor: keep rendering out of CommandResult
CommandResult carried Adventure Components, which was engine's last
Minecraft dependency and the reason CLAUDE.md's "engine has no Minecraft
platform dependencies" was not quite true. It also meant a command could
not report a result without having already decided how it looks: every
site had to pick formatError versus format before it could return.
Results now carry text, and LunaticCommandBase.handleResult is the single
place that styles it - error red for Failure, normal for
SuccessWithMessage. The fail()/ok() helpers from #260 already funnelled
every call site through two functions, so this is a change to those two
plus the one command that composes its own success text.
engine's dependency list is down to kotlinx-serialization, and nothing
under engine/src references net.kyori, org.bukkit, com.velocitypowered or
io.papermc.
Not done: the review also proposed collapsing the per-command
`when (error)` blocks into one exception-to-key table. Those blocks pick
wording, not just a key - "only owners can delete this channel" reads
differently in the ban command than the delete command - so a shared table
would hand every caller the same sentence and need per-command overrides
on top. Left alone deliberately.
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'engine/src/test')
| -rw-r--r-- | engine/src/test/kotlin/dev/m1sk9/lunaticChat/engine/command/CommandResultTest.kt | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/engine/src/test/kotlin/dev/m1sk9/lunaticChat/engine/command/CommandResultTest.kt b/engine/src/test/kotlin/dev/m1sk9/lunaticChat/engine/command/CommandResultTest.kt index b80f116..a9033d0 100644 --- a/engine/src/test/kotlin/dev/m1sk9/lunaticChat/engine/command/CommandResultTest.kt +++ b/engine/src/test/kotlin/dev/m1sk9/lunaticChat/engine/command/CommandResultTest.kt @@ -1,6 +1,5 @@ package dev.m1sk9.lunaticChat.engine.command -import net.kyori.adventure.text.Component import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertIs @@ -13,13 +12,13 @@ class CommandResultTest { @Test fun `SuccessWithMessage toBrigadierResult should return 1`() { - val result = CommandResult.SuccessWithMessage(Component.text("ok")) + val result = CommandResult.SuccessWithMessage("ok") assertEquals(1, result.toBrigadierResult()) } @Test fun `Failure toBrigadierResult should return 0`() { - val result = CommandResult.Failure(Component.text("error")) + val result = CommandResult.Failure("error") assertEquals(0, result.toBrigadierResult()) } @@ -31,7 +30,7 @@ class CommandResultTest { @Test fun `SuccessWithMessage should preserve message`() { - val message = Component.text("Test message") + val message = "Test message" val result = CommandResult.SuccessWithMessage(message) assertIs<CommandResult.SuccessWithMessage>(result) assertEquals(message, result.message) @@ -39,7 +38,7 @@ class CommandResultTest { @Test fun `Failure should preserve message`() { - val message = Component.text("Error message") + val message = "Error message" val result = CommandResult.Failure(message) assertIs<CommandResult.Failure>(result) assertEquals(message, result.message) |
