mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-10-31 15:59:48 +01:00
Show unknown versions (#1379)
Co-authored-by: Florian CUNY <poslovitch@bentobox.world>
This commit is contained in:
parent
6fa89b0b4d
commit
9df54ff07f
@ -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());
|
||||
|
@ -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) {
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user