Class VersionUtils

java.lang.Object
me.hsgamer.hscore.bukkit.utils.VersionUtils

public final class VersionUtils extends Object
The helper class for server versions
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    compare(int majorVersion)
    Compare the server version with the given version
    static int
    compare(int majorVersion, int minorVersion)
    Compare the server version with the given version
    static int
    compare(int majorVersion, int minorVersion, int patchVersion)
    Compare the server version with the given version
    static String
    Get the CraftBukkit package version
    static int
    Get the major version of the server
    static int
    Get the minor version of the server
    static int
    Get the patch version of the server
    static boolean
    isAt(int majorVersion)
    Check if the server version is at the given version
    static boolean
    isAt(int majorVersion, int minorVersion)
    Check if the server version is at the given version
    static boolean
    isAtLeast(int majorVersion)
    Check if the server major version is at least the given major version
    static boolean
    isAtLeast(int majorVersion, int minorVersion)
    Check if the server version is at least the given version
    static boolean
    Check if the server is using CraftBukkit mappings.
    static boolean
    isLowerThan(int majorVersion)
    Check if the server version is lower than the given version
    static boolean
    isLowerThan(int majorVersion, int minorVersion)
    Check if the server version is lower than the given version
    static boolean
    isNewerThan(int majorVersion)
    Check if the server version is newer than the given version
    static boolean
    isNewerThan(int majorVersion, int minorVersion)
    Check if the server version is newer than the given version

    Methods inherited from class java.lang.Object

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

    • getMajorVersion

      public static int getMajorVersion()
      Get the major version of the server
      Returns:
      the version
    • getMinorVersion

      public static int getMinorVersion()
      Get the minor version of the server
      Returns:
      the version
    • getPatchVersion

      public static int getPatchVersion()
      Get the patch version of the server
      Returns:
      the version
    • compare

      public static int compare(int majorVersion, int minorVersion, int patchVersion)
      Compare the server version with the given version
      Parameters:
      majorVersion - the major version
      minorVersion - the minor version
      patchVersion - the patch version
      Returns:
      0 if the versions are the same, negative if the server version is lower, positive if the server version is higher
    • compare

      public static int compare(int majorVersion, int minorVersion)
      Compare the server version with the given version
      Parameters:
      majorVersion - the major version
      minorVersion - the minor version
      Returns:
      0 if the versions are the same, negative if the server version is lower, positive if the server version is higher
    • compare

      public static int compare(int majorVersion)
      Compare the server version with the given version
      Parameters:
      majorVersion - the major version
      Returns:
      0 if the versions are the same, negative if the server version is lower, positive if the server version is higher
    • isAtLeast

      public static boolean isAtLeast(int majorVersion)
      Check if the server major version is at least the given major version
      Parameters:
      majorVersion - the major version to check
      Returns:
      true if it is
    • isAtLeast

      public static boolean isAtLeast(int majorVersion, int minorVersion)
      Check if the server version is at least the given version
      Parameters:
      majorVersion - the major version to check
      minorVersion - the minor version to check
      Returns:
      true if it is
    • isAt

      public static boolean isAt(int majorVersion)
      Check if the server version is at the given version
      Parameters:
      majorVersion - the major version to check
      Returns:
      true if it is
    • isAt

      public static boolean isAt(int majorVersion, int minorVersion)
      Check if the server version is at the given version
      Parameters:
      majorVersion - the major version to check
      minorVersion - the minor version to check
      Returns:
      true if it is
    • isNewerThan

      public static boolean isNewerThan(int majorVersion)
      Check if the server version is newer than the given version
      Parameters:
      majorVersion - the major version to check
      Returns:
      true if it is
    • isNewerThan

      public static boolean isNewerThan(int majorVersion, int minorVersion)
      Check if the server version is newer than the given version
      Parameters:
      majorVersion - the major version to check
      minorVersion - the minor version to check
      Returns:
      true if it is
    • isLowerThan

      public static boolean isLowerThan(int majorVersion)
      Check if the server version is lower than the given version
      Parameters:
      majorVersion - the major version to check
      Returns:
      true if it is
    • isLowerThan

      public static boolean isLowerThan(int majorVersion, int minorVersion)
      Check if the server version is lower than the given version
      Parameters:
      majorVersion - the major version to check
      minorVersion - the minor version to check
      Returns:
      true if it is
    • isCraftBukkitMapped

      public static boolean isCraftBukkitMapped()
      Check if the server is using CraftBukkit mappings. CraftBukkit mappings are usually used in Spigot and old Paper versions. It's useful to check whether the server is using CraftBukkit mappings (Spigot, old Paper) or new Paper mappings. More info
      Returns:
      true if it is
    • getCraftBukkitPackageVersion

      public static String getCraftBukkitPackageVersion()
      Get the CraftBukkit package version
      Returns:
      the CraftBukkit package version, or empty if isCraftBukkitMapped() returns false