Class VNC
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
FieldsModifier and TypeFieldDescriptionstatic final StringLegacy CraftBukkit package suffix such asv1_20_R3.static final StringRaw CraftBukkit package name detected from the running server implementation.static final intParsed major Java runtime version, for example17,21, or25.static final booleanWhether the current runtime appears to be Paper or a Paper-derived fork.static final StringServer version normalized into classic numbering.static final StringServer version normalized into year-based drop numbering.static final StringHuman-readable server fork description built from the current Bukkit runtime.static final MinecraftVersionParsed server version as a structured value object.static final intPublished protocol of the current server version.static final doubleLegacy double representation ofSERVER_CLASSIC_VERSION. -
Method Summary
Modifier and TypeMethodDescriptionstatic intcompare(@NotNull MinecraftVersion left, @NotNull String right) Compares a parsed version against a textual version identifier.static intcompare(@NotNull MinecraftVersion left, @NotNull MinecraftVersion right) Compares two parsed versions after normalizing both to classic numbering.static booleanisAtLeast(int minor) Convenience overload for classic minor-line comparisons such as1.16or1.21.static booleanisAtLeast(int minor, int patch) Convenience overload for classic patch-level comparisons.static booleanChecks whether the current server is at least the supplied version.static booleanChecks whether the current server is older than the supplied version.static booleanChecks whether the current server falls inside an inclusive version range.static @NotNull MinecraftVersionplayer(@NotNull org.bukkit.entity.Player player) Resolves the effective Minecraft version for a specific player.
-
Field Details
-
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
Server version normalized into classic numbering.Examples include values such as
1.20.6,1.21.11, or projected aliases such as1.22when the runtime only exposes a drop identifier. -
SERVER_DROP_VERSION
Server version normalized into year-based drop numbering.Examples include values such as
24.1,25.4, or26.1.1. -
SERVER_PROTOCOL
public static final int SERVER_PROTOCOLPublished 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
Raw CraftBukkit package name detected from the running server implementation. -
BUKKIT_API_VERSION
Legacy CraftBukkit package suffix such asv1_20_R3.Versionless servers expose an empty string here.
-
SERVER_FORK
Human-readable server fork description built from the current Bukkit runtime. -
PAPER_ENABLED
public static final boolean PAPER_ENABLEDWhether the current runtime appears to be Paper or a Paper-derived fork. -
JAVA_VERSION
public static final int JAVA_VERSIONParsed major Java runtime version, for example17,21, or25. -
SERVER_VERSION
public static final double SERVER_VERSIONLegacy double representation ofSERVER_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 preferSERVER_MINECRAFT_VERSIONor 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
Checks whether the current server is at least the supplied version.The comparison accepts both classic identifiers such as
1.21.9and drop identifiers such as25.3. Cross-family comparisons are normalized throughVersionScheme.MOJANGbefore comparing numeric segments.- Parameters:
version- minimum version to compare against- Returns:
truewhen 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 as1.16or1.21.- Parameters:
minor- classic minor number to compare against- Returns:
truewhen the current server is at least1.minor
-
isAtLeast
public static boolean isAtLeast(int minor, int patch) Convenience overload for classic patch-level comparisons.- Parameters:
minor- classic minor numberpatch- classic patch number- Returns:
truewhen the current server is at least1.minor.patch
-
isBefore
Checks whether the current server is older than the supplied version.- Parameters:
version- exclusive upper bound to compare against- Returns:
truewhen 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 boundmaxInclusive- upper inclusive bound- Returns:
truewhen the current server is between both supplied versions
-
compare
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 versionright- textual right-hand version- Returns:
- negative when
left < right, zero when equal, positive whenleft > 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 versionright- right-hand version- Returns:
- negative when
left < right, zero when equal, positive whenleft > right
-