-
Notifications
You must be signed in to change notification settings - Fork 1
Platform: VersionAccessor
Dani ツ edited this page Jun 1, 2025
·
1 revision
PlatformVersionAccessor is a platform-agnostic interface that provides Minecraft version information in a structured and accessible way — allowing your code to adapt to different versions dynamically.
| Property / Method | Description |
|---|---|
major: Int |
Minecraft major version (usually 1) |
minor: Int |
Minor version (e.g., 20 in 1.20.4) |
patch: Int |
Patch version (e.g., 4 in 1.20.4) |
atLeast(major, minor, patch): Boolean |
Returns true if the current version is greater than or equal to the specified version. |
BukkitVersionAccessor.kt uses PaperLib to detect Minecraft version at runtime.
To get the version accessor:
val versionAccessor = BukkitVersionAccessor.versionAccessor()Internally, this returns PaperLibPlatformVersionAccessor, which uses:
override val major: Int = 1
override val minor: Int = PaperLib.getMinecraftVersion()
override val patch: Int = PaperLib.getMinecraftPatchVersion()
override fun atLeast(major: Int, minor: Int, patch: Int): Boolean =
PaperLib.isVersion(minor, patch)You can also create a custom implementation like this:
class CustomPlatformVersionAccessor : PlatformVersionAccessor {
override val major: Int = 1
override val minor: Int
get() = /* your logic */
override val patch: Int
get() = /* your logic */
override fun atLeast(major: Int, minor: Int, patch: Int): Boolean {
// implement comparison logic here
}
}Anything unclear or inaccurate? Please let it know by creating an issue.