Class NmsVersion
This class serves as the foundation for all cross-version compatibility in KamiCommon, providing precise Minecraft version detection and standardized version formatting that enables the provider system to select appropriate implementations across 13+ years of Minecraft evolution. It is fundamental to the entire NMS abstraction architecture.
Core Functionality:
- Version Detection: Extracts precise Minecraft version from Bukkit server
- Version Formatting: Converts semantic versions to comparable integers
- Server Type Detection: Identifies specialized server implementations
- Caching: Optimizes repeated version queries for performance
Version Format Evolution:
This system adapts to Minecraft's changing version identification methods:
- Legacy (1.8-1.12): Uses traditional "vX_XX_RX" package-based detection
- Modern (1.13+): Direct Minecraft version parsing from Bukkit version
- Post-Relocation (1.17+): CB package relocation no longer reliable
- Mojang-Mapped (1.20.5+): New naming conventions require version-based selection
Formatted Integer System:
The formatted integer system enables efficient version comparisons across providers:
Version | Integer | Usage 1.8.9 | 1089 | Legacy comparison base 1.13.2 | 1132 | Flattening update detection 1.16.5 | 1165 | Hex color support detection 1.17.1 | 1171 | NMS restructure detection 1.20.4 | 1204 | Modern API transition 1.21.0 | 1210 | Mojang mapping detection
Critical Dependencies:
This class is used by every provider in the system for version-specific implementation
selection. Any changes to version detection logic directly impact the entire NMS
abstraction layer and should be thoroughly tested across all supported versions.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int
Converts the Minecraft version to a standardized 4-digit integer for efficient comparison.static String
Retrieves the precise Minecraft version of the current server.static boolean
Determines if the current server is running WineSpigot implementation.
-
Constructor Details
-
NmsVersion
public NmsVersion()
-
-
Method Details
-
getMCVersion
Retrieves the precise Minecraft version of the current server.This method extracts the semantic version directly from Bukkit's version string, providing the foundation for all version-specific provider selection throughout the NMS system. The result is cached for optimal performance during provider initialization and repeated version checks.
Version Evolution Context:
Modern Minecraft servers (1.13+) use semantic versioning in the Bukkit version string, making direct version extraction more reliable than legacy package-based detection methods. This approach ensures compatibility with future server implementations and specialized forks.Examples:
Bukkit Version String | Extracted MC Version "1.8.8-R0.1-SNAPSHOT" | "1.8.8" "1.16.5-R0.1-SNAPSHOT" | "1.16.5" "1.20.4-R0.1-SNAPSHOT" | "1.20.4" "1.21-R0.1-SNAPSHOT" | "1.21"
- Returns:
- the Minecraft version string (e.g., "1.8.8", "1.16.5", "1.20.4")
-
getFormattedNmsInteger
public static int getFormattedNmsInteger()Converts the Minecraft version to a standardized 4-digit integer for efficient comparison.This method transforms semantic version strings into comparable integers using a standardized format: major[1]minor[2]patch[1]. This enables efficient version range checking across all providers and supports the complex version logic required for 13+ years of Minecraft compatibility.
Format Specification:
The integer format allocates digits as follows:- Major: 1 digit (covers versions 1.x)
- Minor: 2 digits (handles 1.8 through 1.21+)
- Patch: 1 digit (accommodates point releases)
Version Comparison Examples:
Version | Integer | Provider Selection Use Case 1.8.9 | 1089 | if (ver >= 1089) { ... } 1.13.0 | 1130 | if (ver >= 1130) { ... } 1.16.2 | 1162 | if (ver >= 1162) { ... } 1.17.0 | 1170 | if (ver >= 1170) { ... } 1.20.5 | 1205 | if (ver >= 1205) { ... }
Performance Note:
This value is computed once and cached indefinitely, as the server version cannot change during runtime. All providers rely on this method for version comparisons, making caching essential for optimal performance.- Returns:
- the formatted NMS version as a 4-digit integer
- See Also:
-
isWineSpigot
public static boolean isWineSpigot()Determines if the current server is running WineSpigot implementation.WineSpigot is a specialized Minecraft server implementation that may require specific compatibility adjustments or alternative provider implementations. This detection helps the NMS system adapt to specialized server behaviors and ensure optimal compatibility across different server implementations.
Usage in Provider Selection:
Some providers may need to adjust their behavior for WineSpigot-specific quirks or optimizations. This method enables conditional logic within provider implementations to handle implementation-specific differences.Performance Optimization:
The result is cached after the first query to avoid repeated string comparisons during provider initialization and version-dependent operations.- Returns:
true
if running on WineSpigot,false
otherwise
-