Platform: VersionAccessor - Dani-error/velar GitHub Wiki
🔢 PlatformVersionAccessor
PlatformVersionAccessor
?
📘 What is 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.
🧩 Interface Properties & Methods
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. |
🎮 Bukkit Support
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)
🧠 Implementing Your Own
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
}
}