xyz.refineryteam.refinerycore.api.version centralizes version-specific behavior behind a ServerImplementation interface, instead of scattering Bukkit.getMinecraftVersion() string comparisons across your plugin.
Why not just check the version string?
Comparing raw version strings (Bukkit.getMinecraftVersion().startsWith("1.21")) is brittle and gets duplicated across every place that needs a version check. RefineryCore instead models version-dependent behavior as a set of named Feature flags, resolved once per server boot via the currently-running ServerImplementation.
Checking a feature
WolfArmorApplication.java
RefineryPluginImplementation:
EnchantmentManager.java
Feature
Capability flags for behavior that differs between Minecraft versions. Add a new constant here whenever a plugin feature needs to behave differently on a given server version:
ServerImplementation
The interface exposing version info and feature checks:
Resolution — ServerImplementations
ServerImplementations (plural) resolves the correct ServerImplementation for whatever server is currently running:
MyPlugin.java
<= the running server’s version is selected — so new patch releases automatically fall through to the newest compatible implementation without needing a new registration, until a genuine breaking change requires one.
ServerImplementations.java
Adding support for a new version
Only add a new implementation class when a version genuinely changes behavior that matters to the plugin (a renamed enum, a newly added registry entry, an API not present below a certain version) — most versions within a minor line can share a single implementation.- Create a class extending
AbstractServerImplementation:
Server1_22Implementation.java
- Register it in
ServerImplementations’s static block:
ServerImplementations.java
AbstractServerImplementation handles storing/exposing the version string and computing its ordinal — subclasses only implement supports(Feature).
If the running server’s version is older than every registered implementation’s minimum version,
ServerImplementations falls back to the oldest registered implementation rather than throwing, so the plugin can still attempt to load (features will report as whatever that oldest implementation says, which may be incorrect for a truly unsupported version — this is a best-effort fallback, not a guarantee of correctness).
