Class VNC

java.lang.Object
me.croabeast.vnc.VNC

public final class VNC extends Object
Runtime bridge between Bukkit/Paper and the version model provided by this library.

VNC keeps the public surface intentionally simple: it resolves the current server's runtime metadata once, exposes legacy-compatible constants such as SERVER_VERSION, and provides comparison helpers that work with both classic and drop numbering.

The class is designed to replace older ad-hoc server version utilities. For new code, prefer SERVER_MINECRAFT_VERSION and the string-based comparison helpers over raw double checks whenever the boundary includes patch-level changes such as 1.20.5.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Legacy CraftBukkit package suffix such as v1_20_R3.
    static final String
    Raw CraftBukkit package name detected from the running server implementation.
    static final int
    Parsed major Java runtime version, for example 17, 21, or 25.
    static final boolean
    Whether the current runtime appears to be Paper or a Paper-derived fork.
    static final String
    Server version normalized into classic numbering.
    static final String
    Server version normalized into year-based drop numbering.
    static final String
    Human-readable server fork description built from the current Bukkit runtime.
    static final MinecraftVersion
    Parsed server version as a structured value object.
    static final int
    Published protocol of the current server version.
    static final double
    Legacy double representation of SERVER_CLASSIC_VERSION.
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    compare(@NotNull MinecraftVersion left, @NotNull String right)
    Compares a parsed version against a textual version identifier.
    static int
    compare(@NotNull MinecraftVersion left, @NotNull MinecraftVersion right)
    Compares two parsed versions after normalizing both to classic numbering.
    static boolean
    isAtLeast(int minor)
    Convenience overload for classic minor-line comparisons such as 1.16 or 1.21.
    static boolean
    isAtLeast(int minor, int patch)
    Convenience overload for classic patch-level comparisons.
    static boolean
    isAtLeast(@NotNull String version)
    Checks whether the current server is at least the supplied version.
    static boolean
    isBefore(@NotNull String version)
    Checks whether the current server is older than the supplied version.
    static boolean
    isBetween(@NotNull String minInclusive, @NotNull String maxInclusive)
    Checks whether the current server falls inside an inclusive version range.
    static @NotNull MinecraftVersion
    player(@NotNull org.bukkit.entity.Player player)
    Resolves the effective Minecraft version for a specific player.

    Methods inherited from class java.lang.Object

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

    • SERVER_MINECRAFT_VERSION

      public static final MinecraftVersion SERVER_MINECRAFT_VERSION
      Parsed server version as a structured value object.

      This is the preferred source of truth for feature checks, protocol-aware behavior, and version family conversions.

    • SERVER_CLASSIC_VERSION

      public static final String SERVER_CLASSIC_VERSION
      Server version normalized into classic numbering.

      Examples include values such as 1.20.6, 1.21.11, or projected aliases such as 1.22 when the runtime only exposes a drop identifier.

    • SERVER_DROP_VERSION

      public static final String SERVER_DROP_VERSION
      Server version normalized into year-based drop numbering.

      Examples include values such as 24.1, 25.4, or 26.1.1.

    • SERVER_PROTOCOL

      public static final int SERVER_PROTOCOL
      Published protocol of the current server version.

      When the exact runtime version does not have a known protocol mapping, this field is -1.

    • CRAFT_BUKKIT_PACKAGE

      public static final String CRAFT_BUKKIT_PACKAGE
      Raw CraftBukkit package name detected from the running server implementation.
    • BUKKIT_API_VERSION

      public static final String BUKKIT_API_VERSION
      Legacy CraftBukkit package suffix such as v1_20_R3.

      Versionless servers expose an empty string here.

    • SERVER_FORK

      public static final String SERVER_FORK
      Human-readable server fork description built from the current Bukkit runtime.
    • PAPER_ENABLED

      public static final boolean PAPER_ENABLED
      Whether the current runtime appears to be Paper or a Paper-derived fork.
    • JAVA_VERSION

      public static final int JAVA_VERSION
      Parsed major Java runtime version, for example 17, 21, or 25.
    • SERVER_VERSION

      public static final double SERVER_VERSION
      Legacy double representation of SERVER_CLASSIC_VERSION.

      This field exists for compatibility with older plugins that compare server versions as 16.0, 20.5, and similar values. New code should prefer SERVER_MINECRAFT_VERSION or the string-based helper methods in this class.

  • Method Details

    • player

      @NotNull public static @NotNull MinecraftVersion player(@NotNull @NotNull org.bukkit.entity.Player player)
      Resolves the effective Minecraft version for a specific player.

      When ViaVersion is installed, the player's negotiated protocol is translated back into a canonical MinecraftVersion. Without ViaVersion, this falls back to the current server version.

      Parameters:
      player - online player to inspect
      Returns:
      best-known Minecraft version for that player
    • isAtLeast

      public static boolean isAtLeast(@NotNull @NotNull String version)
      Checks whether the current server is at least the supplied version.

      The comparison accepts both classic identifiers such as 1.21.9 and drop identifiers such as 25.3. Cross-family comparisons are normalized through VersionScheme.MOJANG before comparing numeric segments.

      Parameters:
      version - minimum version to compare against
      Returns:
      true when the current server is equal to or newer than the supplied version
    • isAtLeast

      public static boolean isAtLeast(int minor)
      Convenience overload for classic minor-line comparisons such as 1.16 or 1.21.
      Parameters:
      minor - classic minor number to compare against
      Returns:
      true when the current server is at least 1.minor
    • isAtLeast

      public static boolean isAtLeast(int minor, int patch)
      Convenience overload for classic patch-level comparisons.
      Parameters:
      minor - classic minor number
      patch - classic patch number
      Returns:
      true when the current server is at least 1.minor.patch
    • isBefore

      public static boolean isBefore(@NotNull @NotNull String version)
      Checks whether the current server is older than the supplied version.
      Parameters:
      version - exclusive upper bound to compare against
      Returns:
      true when the current server is strictly older than the supplied version
    • isBetween

      public static boolean isBetween(@NotNull @NotNull String minInclusive, @NotNull @NotNull String maxInclusive)
      Checks whether the current server falls inside an inclusive version range.
      Parameters:
      minInclusive - lower inclusive bound
      maxInclusive - upper inclusive bound
      Returns:
      true when the current server is between both supplied versions
    • compare

      public static int compare(@NotNull @NotNull MinecraftVersion left, @NotNull @NotNull String right)
      Compares a parsed version against a textual version identifier.

      The textual identifier may use classic or drop numbering. Both operands are normalized to classic numbering before the numeric comparison is performed.

      Parameters:
      left - parsed left-hand version
      right - textual right-hand version
      Returns:
      negative when left < right, zero when equal, positive when left > right
    • compare

      public static int compare(@NotNull @NotNull MinecraftVersion left, @NotNull @NotNull MinecraftVersion right)
      Compares two parsed versions after normalizing both to classic numbering.

      This is the lowest-level comparison helper used by the string-based overloads and by the runtime bridge methods in this class.

      Parameters:
      left - left-hand version
      right - right-hand version
      Returns:
      negative when left < right, zero when equal, positive when left > right