Class Server
Provides helpers to resolve the running Bukkit/Spigot version into the Version
enum and convenience comparators (higher/equals/lower). The ResolveVersion()
method initializes the static version field by parsing Bukkit's version string.
Also includes the Server.ServerType inner class to detect if the server is Paper or
Spigot, enabling conditional feature support based on server capabilities.
Extends Server to inherit common server utilities.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionfinal classUtility class for detecting the server type (Paper or Spigot).Nested classes/interfaces inherited from class valorless.valorlessutils.Server
valorless.valorlessutils.Server.Version -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static valorless.valorlessutils.Server.VersionCurrent resolved server Version. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic valorless.valorlessutils.Server.VersionRetrieves the highest defined Version in the Version enum.
Used for testing purposes to simulate the latest server version, shouldResolveVersion()fail in to resolve.
Needed for testing on versions not yet added to.invalid reference
valorless.ValorlessUtils.Server.Versionstatic valorless.valorlessutils.Server.VersionResolves and caches the server Version from Bukkit's reported version string.static intVersionCompare(valorless.valorlessutils.Server.Version compareTo) Compares a Version against the Server's current Version to determine their order.static intVersionCompare(valorless.valorlessutils.Server.Version version, valorless.valorlessutils.Server.Version compareTo) Compares two Version enums to determine their order based on their declaration.static BooleanVersionEqualTo(valorless.valorlessutils.Server.Version version) Checks if the current server version is exactly equal to a specified version.static BooleanVersionHigherOrEqualTo(valorless.valorlessutils.Server.Version version) Checks if the current server version is higher than or equal to a specified version.static BooleanVersionHigherThan(valorless.valorlessutils.Server.Version version) Checks if the current server version is strictly higher than a specified version.static BooleanVersionLowerOrEqualTo(valorless.valorlessutils.Server.Version version) Checks if the current server version is lower than or equal to a specified version.static BooleanVersionLowerThan(valorless.valorlessutils.Server.Version version) Checks if the current server version is strictly lower than a specified version.
-
Field Details
-
version
protected static valorless.valorlessutils.Server.Version versionCurrent resolved server Version.
-
-
Constructor Details
-
Server
public Server()
-
-
Method Details
-
VersionCompare
public static int VersionCompare(valorless.valorlessutils.Server.Version version, valorless.valorlessutils.Server.Version compareTo) Compares two Version enums to determine their order based on their declaration.- Parameters:
version- The Version to compare.compareTo- The Version to compare against.- Returns:
- A negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second argument.
-
VersionCompare
public static int VersionCompare(valorless.valorlessutils.Server.Version compareTo) Compares a Version against the Server's current Version to determine their order.- Parameters:
compareTo- The Version to compare against the current server version.- Returns:
- A negative integer, zero, or a positive integer as the current version
is less than, equal to, or greater than
compareTo.
-
ResolveVersion
public static valorless.valorlessutils.Server.Version ResolveVersion()Resolves and caches the server Version from Bukkit's reported version string.Parses
Bukkit.getBukkitVersion()(e.g., "1.20.4-R0.1-SNAPSHOT") to extract the numeric part before the dash, converts it to the corresponding enum constant name (e.g.,v1_20_4), assignsversion, and returns it. On failure, logs an error, setsversiontoServer.Version.NULL, and returnsServer.Version.NULL.- Returns:
- the resolved
Server.Version, orServer.Version.NULLon failure
-
getHighestVersion
@TestOnly("Used for testing purposes, will be removed in production.") @MarkedForRemoval("Remove once ValorlessUtils is updated with latest versions.") public static valorless.valorlessutils.Server.Version getHighestVersion()Retrieves the highest defined Version in the Version enum.
Used for testing purposes to simulate the latest server version, shouldResolveVersion()fail in to resolve.
Needed for testing on versions not yet added to.invalid reference
valorless.ValorlessUtils.Server.Version- Returns:
- The highest Version constant.
-
VersionHigherOrEqualTo
Checks if the current server version is higher than or equal to a specified version.- Parameters:
version- The version to compare against.- Returns:
trueif the current server version is higher than or equal toversion;falseotherwise.
-
VersionHigherThan
Checks if the current server version is strictly higher than a specified version.- Parameters:
version- The version to compare against.- Returns:
trueif the current server version is higher thanversion;falseotherwise.
-
VersionLowerOrEqualTo
Checks if the current server version is lower than or equal to a specified version.- Parameters:
version- The version to compare against.- Returns:
trueif the current server version is lower than or equal toversion;falseotherwise.
-
VersionLowerThan
Checks if the current server version is strictly lower than a specified version.- Parameters:
version- The version to compare against.- Returns:
trueif the current server version is lower thanversion;falseotherwise.
-
VersionEqualTo
Checks if the current server version is exactly equal to a specified version.- Parameters:
version- The version to compare against.- Returns:
trueif the current server version equalsversion;falseotherwise.
-