Architecture
How hAnimationsWorks is put together — the module graph, why it is split, and the seams that let one codebase serve three server versions.
The shape of it
One codebase, three distributable jars. The engine, config format, GUI and animation model are identical across all three. Only the entry point and the command registrar differ.
┌─────────┐
│ :api │ public contracts, no server types
└────┬────┘
│
┌────┴─────┐
│ :core │ engine, config, GUI, listeners
└────┬─────┘
│
┌────────────────────┼────────────────────┐
│ │ │
┌────┴─────┐ ┌─────┴──────┐ ┌──────┴──────┐
│ :bukkit │ │ :paper │ │:paper-modern│
│ Spigot │ │ Paper 1.20 │ │ Paper 1.21+ │
│ 1.20.1 │ │ │ │ (Java 25) │
└──────────┘ └────────────┘ └─────────────┘Supporting modules:
| Module | Purpose |
|---|---|
:bridges:paperbridge |
Adventure-native text sending, shared by both Paper jars |
:integration:bettermodel |
The BetterModel model provider |
build-logic |
Convention plugins (haw.java-conventions) |
Why it is split at all
Because :core must compile against Spigot 1.20.1 in order to keep producing a Spigot jar. That constraint is what shapes everything else.
Modern Paper has a command lifecycle API — LifecycleEvents.COMMANDS and a typed CommandSourceStack — that does not exist in spigot-api or paper-api 1.20.1. Putting those types in :core would stop the Spigot jar from compiling at all.
So the command tree is built in :core and installed by a distribution module, meeting at one interface:
public interface CommandRegistrar {
boolean register();
boolean registered();
}| Distribution | How it installs the tree |
|---|---|
:bukkit, :paper |
Reflection: CraftServer → getServer() → getCommands() → getDispatcher() |
:paper-modern |
getLifecycleManager().registerEventHandler(LifecycleEvents.COMMANDS, …) |
:paper-modern is Java 25 because paper-api 26.2 is Java 25 bytecode, and Minecraft 26.x refuses to start below Java 25. That costs nothing: no server old enough to want Java 17 can run 26.2 anyway.
Two seams, same reason
CommandRegistrar and PlatformBridge are the two points where a version-specific type would otherwise leak into :core. Both are interfaces in :api, implemented per distribution.
PlatformBridge exists for the same reason: :core cannot name Adventure's Component if it also has to satisfy the Spigot API, so text goes through a bridge that each platform supplies.
Inside :core
| Package | Responsibility |
|---|---|
engine |
Playback: gates, cooldowns, camera, freeze, visibility, teardown |
engine (providers) |
ModelProvider implementations and CompositeAnimationSpawner |
gui |
Picker, editor, holder, listener |
command |
Brigadier tree (BrigadierAnimationCommand) and the legacy Bukkit fallback |
listener |
Bukkit event handlers — one per trigger |
preference |
Per-player choices, persisted to preferences.yml |
config |
YAML loading and validation |
camera, player |
Camera, freeze and visibility services |
SharedPluginCore owns boot order. Everything is constructed there in dependency order, and it is final precisely so a subclass cannot forget a step — a half-wired plugin is harder to diagnose than a compile error.
The model provider seam
The engine never knows what BetterModel or MythicMobs is. It asks:
public interface ModelProvider {
String id(); // "bettermodel", "mythicmobs"
boolean isAvailable();
Optional<String> unavailableReason();
boolean modelExists(String modelId);
Optional<ModelHandle> spawn(String modelId, Location where);
void remove(ModelHandle handle);
}CompositeAnimationSpawner walks provider-priority and asks each provider "do you know this model?" — the first that does is the one that plays it.
ModelHandle is deliberately thin. It carries an optional entity id:
public interface ModelHandle {
Optional<UUID> entityId();
// ...
}That matters at teardown. A BetterModel handle has no entity id, so the guard in finish() degrades to "release it" — which is correct, because a packet-rendered model cannot be confused with another animation's the way a shared entity id could.
Shading
The plain jar task is disabled in every distribution:
tasks.jar { enabled = false }Without that, a build emits two jars with the same plugin.yml name and main class — the plain one holds only that module's own classes with no shaded dependencies, so it is unloadable. Deploying both makes the server load one and reject the other, and which wins depends on file order.
Each distribution shades the others and Conduit. Third-party plugin APIs stay compileOnly and are never bundled.
Conduit is implementation, not compileOnly, because it is a library a consumer embeds and shades — not a plugin the server supplies. See the module build files for the reasoning on each integration.
Reading the code
Two comments recur and are worth trusting:
BrigadierAnimationCommand.register()— a long note on why the tree is built forObjectand why the cast in the handlers is not a cast.AnimationEngine.finish()— the entity-id guard and what it degrades to for non-entity models.
Several methods carry notes describing bugs that were real and were fixed — an absent field, a wrong reflection chain, a flag that was never set. Those are there because the alternative is someone reintroducing the bug. They are accurate as of the current tree.