diff --git a/src/main/java/world/bentobox/bentobox/commands/BentoBoxVersionCommand.java b/src/main/java/world/bentobox/bentobox/commands/BentoBoxVersionCommand.java index 4f9dd1833..db9befa94 100644 --- a/src/main/java/world/bentobox/bentobox/commands/BentoBoxVersionCommand.java +++ b/src/main/java/world/bentobox/bentobox/commands/BentoBoxVersionCommand.java @@ -13,6 +13,7 @@ import world.bentobox.bentobox.api.commands.CompositeCommand; import world.bentobox.bentobox.api.localization.TextVariables; import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.versions.ServerCompatibility; +import world.bentobox.bentobox.versions.ServerCompatibility.ServerSoftware; /** * Displays information about Gamemodes, Addons and versioning. @@ -40,7 +41,7 @@ public class BentoBoxVersionCommand extends CompositeCommand { ServerCompatibility.ServerVersion serverVersion = ServerCompatibility.getInstance().getServerVersion(); user.sendMessage("commands.bentobox.version.server", - TextVariables.NAME, serverSoftware != null ? serverSoftware.toString() : user.getTranslation("general.invalid"), + TextVariables.NAME, serverSoftware.equals(ServerSoftware.UNKNOWN) ? user.getTranslation("general.invalid") + " (" + serverSoftware.getName() + ")" : serverSoftware.toString(), TextVariables.VERSION, serverVersion != null ? serverVersion.toString() : user.getTranslation("general.invalid")); user.sendMessage("commands.bentobox.version.plugin-version", TextVariables.VERSION, getPlugin().getDescription().getVersion()); user.sendMessage("commands.bentobox.version.database", "[database]", getSettings().getDatabaseType().toString()); diff --git a/src/main/java/world/bentobox/bentobox/panels/ManagementPanel.java b/src/main/java/world/bentobox/bentobox/panels/ManagementPanel.java index 7d16612dc..b1f5a0e6e 100644 --- a/src/main/java/world/bentobox/bentobox/panels/ManagementPanel.java +++ b/src/main/java/world/bentobox/bentobox/panels/ManagementPanel.java @@ -18,6 +18,7 @@ import world.bentobox.bentobox.api.panels.builders.PanelBuilder; import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder; import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.versions.ServerCompatibility; +import world.bentobox.bentobox.versions.ServerCompatibility.ServerSoftware; /** * @author Poslovitch @@ -230,7 +231,7 @@ public class ManagementPanel { PanelItemBuilder compatibilityItemBuilder = new PanelItemBuilder() .name(user.getTranslation(LOCALE_REF + "information.state.name")) .description(user.getTranslation(LOCALE_REF + "information.state.description." + compatibility, - TextVariables.NAME, serverSoftware != null ? serverSoftware.toString() : user.getTranslation("general.invalid"), + TextVariables.NAME, serverSoftware.equals(ServerSoftware.UNKNOWN) ? serverSoftware.getName() : serverSoftware.toString(), TextVariables.VERSION, serverVersion != null ? serverVersion.toString() : user.getTranslation("general.invalid"))); switch (compatibility) { diff --git a/src/main/java/world/bentobox/bentobox/versions/ServerCompatibility.java b/src/main/java/world/bentobox/bentobox/versions/ServerCompatibility.java index ce12d85d6..ffd71c2e7 100644 --- a/src/main/java/world/bentobox/bentobox/versions/ServerCompatibility.java +++ b/src/main/java/world/bentobox/bentobox/versions/ServerCompatibility.java @@ -76,14 +76,39 @@ public class ServerCompatibility { SPIGOT(Compatibility.COMPATIBLE), PAPER(Compatibility.SUPPORTED), TACOSPIGOT(Compatibility.NOT_SUPPORTED), - AKARIN(Compatibility.NOT_SUPPORTED); + AKARIN(Compatibility.NOT_SUPPORTED), + /** + * @since 1.14.0 + */ + UNKNOWN(Compatibility.INCOMPATIBLE); private Compatibility compatibility; + /** + * @since 1.14.0 + */ + private String name; ServerSoftware(Compatibility compatibility) { this.compatibility = compatibility; } + /** + * @return the name + * @since 1.14.0 + */ + public String getName() { + return name; + } + + /** + * @param name the name to set + * @since 1.14.0 + */ + public ServerSoftware setName(String name) { + this.name = name; + return this; + } + public Compatibility getCompatibility() { return compatibility; } @@ -182,8 +207,7 @@ public class ServerCompatibility { // Now, check the server software ServerSoftware software = getServerSoftware(); - if (software == null || software.getCompatibility().equals(Compatibility.INCOMPATIBLE)) { - // 'software = null' means that it's not listed. And therefore, it's implicitly incompatible. + if (software.getCompatibility().equals(Compatibility.INCOMPATIBLE)) { result = Compatibility.INCOMPATIBLE; return result; } @@ -211,13 +235,13 @@ public class ServerCompatibility { * @return the {@link ServerSoftware} run by this server or null. * @since 1.3.0 */ - @Nullable + @NonNull public ServerSoftware getServerSoftware() { String serverSoftware = Bukkit.getServer().getVersion().substring(4).split("-")[0]; try { return ServerSoftware.valueOf(serverSoftware.toUpperCase(Locale.ENGLISH)); } catch (IllegalArgumentException e) { - return null; + return ServerSoftware.UNKNOWN.setName(serverSoftware.toUpperCase(Locale.ENGLISH)); } }