Skip to content

Commit ca7ad2a

Browse files
committed
chore: bump base version to 0.0.4 and refactor server name handling in ServerCommand
1 parent e506f4c commit ca7ad2a

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

‎build.gradle.kts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ plugins {
77
`maven-publish`
88
}
99

10-
val baseVersion = "0.0.3"
10+
val baseVersion = "0.0.4"
1111
val commitHash = System.getenv("COMMIT_HASH")
1212
val snapshotversion = "${baseVersion}-dev.$commitHash"
1313

‎command-shared/src/main/kotlin/app/simplecloud/plugin/command/shared/commands/ServerCommand.kt‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package app.simplecloud.plugin.command.shared.commands
22

33
import app.simplecloud.api.CloudApi
4+
import app.simplecloud.api.server.Server
45
import app.simplecloud.plugin.command.shared.CloudSender
56
import app.simplecloud.plugin.command.shared.CommandPermission
67
import app.simplecloud.plugin.command.shared.CommandPlugin
@@ -57,7 +58,7 @@ class ServerCommand(
5758
messages.msg(messages.command.server.list.title, tags("count" to servers.size))
5859
)
5960
servers.forEach { server ->
60-
val serverName = "${server.group?.name ?: server.serverGroupId} ${server.numericalId}"
61+
val serverName = server.displayName()
6162
val value = "${server.playerCount ?: 0}/${server.maxPlayers} - ${server.state.name.lowercase()}"
6263
context.sender().sendMessage(
6364
messages.msg(messages.command.server.list.entry, tags("server" to serverName, "value" to value))
@@ -73,6 +74,18 @@ class ServerCommand(
7374
)
7475
}
7576

77+
private fun Server.displayName(): String {
78+
val groupName = group?.name?.takeUnless { it.isBlank() }
79+
?: serverGroupId?.takeUnless { it.isBlank() }
80+
if (groupName != null) {
81+
return "$groupName $numericalId"
82+
}
83+
84+
return persistentServer?.name?.takeUnless { it.isBlank() }
85+
?: persistentServerId?.takeUnless { it.isBlank() }
86+
?: serverId
87+
}
88+
7689
private fun <C : CloudSender> registerInfo(commandManager: CommandManager<C>) {
7790
commandManager.command(
7891
commandManager.commandBuilder("cloud", "sc", "simplecloud")

0 commit comments

Comments
 (0)