diff options
Diffstat (limited to 'platform-paper/src')
4 files changed, 53 insertions, 14 deletions
diff --git a/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/command/impl/lc/StatusCommand.kt b/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/command/impl/lc/StatusCommand.kt index 3a4149c..6b6fd09 100644 --- a/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/command/impl/lc/StatusCommand.kt +++ b/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/command/impl/lc/StatusCommand.kt @@ -104,8 +104,11 @@ class StatusCommand( // Nightly warning if (BuildInfo.isNightly) { - sendMessage(MessageFormatter.format(languageManager.getMessage("general.nightlyWarning")) - .color(NamedTextColor.YELLOW)) + sendMessage( + MessageFormatter + .format(languageManager.getMessage("general.nightlyWarning")) + .color(NamedTextColor.YELLOW), + ) } sendMessage(healthLine) diff --git a/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/command/impl/lcv/VelocityStatusCommand.kt b/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/command/impl/lcv/VelocityStatusCommand.kt index 9e926fc..439a29a 100644 --- a/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/command/impl/lcv/VelocityStatusCommand.kt +++ b/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/command/impl/lcv/VelocityStatusCommand.kt @@ -16,7 +16,6 @@ import dev.m1sk9.lunaticChat.paper.velocity.VelocityConnectionManager import io.papermc.paper.command.brigadier.CommandSourceStack import io.papermc.paper.command.brigadier.Commands import net.kyori.adventure.text.Component -import net.kyori.adventure.text.event.ClickEvent import net.kyori.adventure.text.event.HoverEvent import net.kyori.adventure.text.format.NamedTextColor @@ -143,8 +142,11 @@ class VelocityStatusCommand( // Nightly warning if (BuildInfo.isNightly) { - sendMessage(MessageFormatter.format(languageManager.getMessage("general.nightlyWarning")) - .color(NamedTextColor.YELLOW)) + sendMessage( + MessageFormatter + .format(languageManager.getMessage("general.nightlyWarning")) + .color(NamedTextColor.YELLOW), + ) } // Connection status details diff --git a/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/listener/PlayerPresenceListener.kt b/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/listener/PlayerPresenceListener.kt index 86a8519..fc79ffe 100644 --- a/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/listener/PlayerPresenceListener.kt +++ b/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/listener/PlayerPresenceListener.kt @@ -8,7 +8,6 @@ import dev.m1sk9.lunaticChat.paper.common.hasAnyPermission import dev.m1sk9.lunaticChat.paper.i18n.LanguageManager import dev.m1sk9.lunaticChat.paper.i18n.MessageFormatter import dev.m1sk9.lunaticChat.paper.settings.PlayerSettingsManager -import net.kyori.adventure.text.Component import net.kyori.adventure.text.event.ClickEvent import net.kyori.adventure.text.format.NamedTextColor import org.bukkit.event.EventHandler @@ -46,12 +45,16 @@ class PlayerPresenceListener( if (BuildInfo.isNightly) { lunaticChat.server.asyncScheduler.runDelayed(lunaticChat, { _ -> if (player.isOnline) { - player.sendMessage(MessageFormatter.format(languageManager.getMessage("general.nightlyWarning")) - .color(NamedTextColor.YELLOW)) player.sendMessage( - MessageFormatter.format(languageManager.getMessage("general.nightlyReportIssue")) + MessageFormatter + .format(languageManager.getMessage("general.nightlyWarning")) + .color(NamedTextColor.YELLOW), + ) + player.sendMessage( + MessageFormatter + .format(languageManager.getMessage("general.nightlyReportIssue")) .clickEvent(ClickEvent.openUrl("https://github.com/m1sk9/LunaticChat/issues")) - .color(NamedTextColor.YELLOW) + .color(NamedTextColor.YELLOW), ) } }, 6, TimeUnit.SECONDS) diff --git a/platform-paper/src/test/kotlin/dev/m1sk9/lunaticChat/paper/command/impl/lc/StatusCommandTest.kt b/platform-paper/src/test/kotlin/dev/m1sk9/lunaticChat/paper/command/impl/lc/StatusCommandTest.kt index 95c8b92..039b135 100644 --- a/platform-paper/src/test/kotlin/dev/m1sk9/lunaticChat/paper/command/impl/lc/StatusCommandTest.kt +++ b/platform-paper/src/test/kotlin/dev/m1sk9/lunaticChat/paper/command/impl/lc/StatusCommandTest.kt @@ -45,13 +45,25 @@ class StatusCommandTest { val mockPlayer: org.bukkit.entity.Player, ) + private fun mockBuildInfoStable() { + every { BuildInfo.versionWithCommit() } returns "0.10.0-test" + every { BuildInfo.isNightly } returns false + every { BuildInfo.channel } returns "stable" + } + + private fun mockBuildInfoNightly() { + every { BuildInfo.versionWithCommit() } returns "0.10.0-nightly.1-test" + every { BuildInfo.isNightly } returns true + every { BuildInfo.channel } returns "nightly" + } + @Test fun `execute should return Success`() { val deps = createDependencies() mockkObject(BuildInfo) try { - every { BuildInfo.versionWithCommit() } returns "0.10.0-test" + mockBuildInfoStable() val result = deps.command.execute(deps.ctx) @@ -67,7 +79,7 @@ class StatusCommandTest { mockkObject(BuildInfo) try { - every { BuildInfo.versionWithCommit() } returns "0.10.0-test" + mockBuildInfoStable() deps.command.execute(deps.ctx) @@ -96,7 +108,7 @@ class StatusCommandTest { mockkObject(BuildInfo) try { - every { BuildInfo.versionWithCommit() } returns "0.10.0-test" + mockBuildInfoStable() val result = deps.command.execute(deps.ctx) @@ -112,7 +124,7 @@ class StatusCommandTest { mockkObject(BuildInfo) try { - every { BuildInfo.versionWithCommit() } returns "0.10.0-test" + mockBuildInfoStable() deps.command.execute(deps.ctx) @@ -122,4 +134,23 @@ class StatusCommandTest { unmockkObject(BuildInfo) } } + + @Test + fun `execute with nightly build should display nightly warning and channel`() { + val deps = createDependencies() + + mockkObject(BuildInfo) + try { + mockBuildInfoNightly() + + val result = deps.command.execute(deps.ctx) + + assertIs<CommandResult.Success>(result) + // Nightly warning + version + health + features header + 4 features + config header + + // debug + checkForUpdates + releaseChannel + language + 3 links = at least 15 messages + verify(atLeast = 5) { deps.mockPlayer.sendMessage(any<Component>()) } + } finally { + unmockkObject(BuildInfo) + } + } } |
