Class Server

java.lang.Object
valorless.valorlessutils.Server
valorless.rarespawns.Server

public class Server extends valorless.valorlessutils.Server
Server/version utilities for RareSpawns.

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 Classes
    Modifier and Type
    Class
    Description
    final class 
    Utility class for detecting the server type (Paper or Spigot).

    Nested classes/interfaces inherited from class valorless.valorlessutils.Server

    valorless.valorlessutils.Server.Version
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static valorless.valorlessutils.Server.Version
    Current resolved server Version.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static valorless.valorlessutils.Server.Version
    Retrieves the highest defined Version in the Version enum.
    Used for testing purposes to simulate the latest server version, should ResolveVersion() fail in to resolve.
    Needed for testing on versions not yet added to
    invalid reference
    valorless.ValorlessUtils.Server.Version
    .
    static valorless.valorlessutils.Server.Version
    Resolves and caches the server Version from Bukkit's reported version string.
    static int
    VersionCompare(valorless.valorlessutils.Server.Version compareTo)
    Compares a Version against the Server's current Version to determine their order.
    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.
    static Boolean
    VersionEqualTo(valorless.valorlessutils.Server.Version version)
    Checks if the current server version is exactly equal to a specified version.
    static Boolean
    VersionHigherOrEqualTo(valorless.valorlessutils.Server.Version version)
    Checks if the current server version is higher than or equal to a specified version.
    static Boolean
    VersionHigherThan(valorless.valorlessutils.Server.Version version)
    Checks if the current server version is strictly higher than a specified version.
    static Boolean
    VersionLowerOrEqualTo(valorless.valorlessutils.Server.Version version)
    Checks if the current server version is lower than or equal to a specified version.
    static Boolean
    VersionLowerThan(valorless.valorlessutils.Server.Version version)
    Checks if the current server version is strictly lower than a specified version.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • version

      protected static valorless.valorlessutils.Server.Version version
      Current 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), assigns version, and returns it. On failure, logs an error, sets version to Server.Version.NULL, and returns Server.Version.NULL.

      Returns:
      the resolved Server.Version, or Server.Version.NULL on 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, should ResolveVersion() 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

      public static Boolean VersionHigherOrEqualTo(valorless.valorlessutils.Server.Version version)
      Checks if the current server version is higher than or equal to a specified version.
      Parameters:
      version - The version to compare against.
      Returns:
      true if the current server version is higher than or equal to version; false otherwise.
    • VersionHigherThan

      public static Boolean VersionHigherThan(valorless.valorlessutils.Server.Version version)
      Checks if the current server version is strictly higher than a specified version.
      Parameters:
      version - The version to compare against.
      Returns:
      true if the current server version is higher than version; false otherwise.
    • VersionLowerOrEqualTo

      public static Boolean VersionLowerOrEqualTo(valorless.valorlessutils.Server.Version version)
      Checks if the current server version is lower than or equal to a specified version.
      Parameters:
      version - The version to compare against.
      Returns:
      true if the current server version is lower than or equal to version; false otherwise.
    • VersionLowerThan

      public static Boolean VersionLowerThan(valorless.valorlessutils.Server.Version version)
      Checks if the current server version is strictly lower than a specified version.
      Parameters:
      version - The version to compare against.
      Returns:
      true if the current server version is lower than version; false otherwise.
    • VersionEqualTo

      public static Boolean VersionEqualTo(valorless.valorlessutils.Server.Version version)
      Checks if the current server version is exactly equal to a specified version.
      Parameters:
      version - The version to compare against.
      Returns:
      true if the current server version equals version; false otherwise.