Skip to content

Commit

Permalink
feat: improve server version status text
Browse files Browse the repository at this point in the history
  • Loading branch information
WiIIiam278 committed Aug 9, 2024
1 parent 7d8a743 commit 5c234cd
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,12 @@ public String getPlatformType() {
return PLATFORM_TYPE_ID;
}

@Override
@NotNull
public String getServerVersion() {
return String.format("%s/%s", getServer().getName(), getServer().getVersion());
}

@Override
public Optional<LegacyConverter> getLegacyConverter() {
return Optional.of(legacyConverter);
Expand Down
8 changes: 8 additions & 0 deletions common/src/main/java/net/william278/husksync/HuskSync.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,14 @@ default ConsoleUser getConsole() {
@NotNull
String getPlatformType();

/**
* Returns the server software version
*
* @return the server software version string
*/
@NotNull
String getServerVersion();

/**
* Returns the legacy data converter if it exists
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,19 +204,19 @@ private enum StatusLine {
PLUGIN_VERSION(plugin -> Component.text("v" + plugin.getPluginVersion().toStringWithoutMetadata())
.appendSpace().append(plugin.getPluginVersion().getMetadata().isBlank() ? Component.empty()
: Component.text("(build " + plugin.getPluginVersion().getMetadata() + ")"))),
PLATFORM_TYPE(plugin -> Component.text(WordUtils.capitalizeFully(plugin.getPlatformType()))),
SERVER_VERSION(plugin -> Component.text(plugin.getServerVersion())),
LANGUAGE(plugin -> Component.text(plugin.getSettings().getLanguage())),
MINECRAFT_VERSION(plugin -> Component.text(plugin.getMinecraftVersion().toString())),
JAVA_VERSION(plugin -> Component.text(System.getProperty("java.version"))),
JAVA_VENDOR(plugin -> Component.text(System.getProperty("java.vendor"))),
SERVER_NAME(plugin -> Component.text(plugin.getServerName())),
CLUSTER_ID(plugin -> Component.text(plugin.getSettings().getClusterId().isBlank() ? "None" : plugin.getSettings().getClusterId())),
SYNC_MODE(plugin -> Component.text(WordUtils.capitalizeFully(
plugin.getSettings().getSynchronization().getMode().toString()
))),
DELAY_LATENCY(plugin -> Component.text(
plugin.getSettings().getSynchronization().getNetworkLatencyMilliseconds() + "ms"
)),
SERVER_NAME(plugin -> Component.text(plugin.getServerName())),
CLUSTER_ID(plugin -> Component.text(plugin.getSettings().getClusterId().isBlank() ? "None" : plugin.getSettings().getClusterId())),
DATABASE_TYPE(plugin ->
Component.text(plugin.getSettings().getDatabase().getType().getDisplayName() +
(plugin.getSettings().getDatabase().getType() == Database.Type.MONGO ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,14 @@ public String getPlatformType() {
return PLATFORM_TYPE_ID;
}

@Override
@NotNull
public String getServerVersion() {
return String.format("%s %s/%s", getPlatformType(), FabricLoader.getInstance()
.getModContainer("fabricloader").map(l -> l.getMetadata().getVersion().getFriendlyString())
.orElse("unknown"), minecraftServer.getVersion());
}

@Override
public Optional<LegacyConverter> getLegacyConverter() {
return Optional.empty();
Expand Down

0 comments on commit 5c234cd

Please sign in to comment.