Engine API
The public interfaces another plugin can use — playing animations, registering a model provider, and what each contract actually guarantees.
Everything public lives in :api and carries no server-specific types, so a consumer compiles against the same artifact whatever server it targets.
AnimationsWorksApi
The entry point for playing animations.
AnimationsWorksApi api = /* obtained from the plugin instance */;
boolean started = api.play(playerId, AnimationTrigger.DEATH, "bubble_animation");play(UUID, String) — no trigger
Resolves the id across every trigger and plays the first owner in AnimationTrigger.values() order.
That order is fixed, so the same id previews the same thing on every run. But it is still a guess about which copy was meant: a pack that defines drill_animation under both JOIN and BAN has two different animations, and a bare id cannot say which one is wanted.
Prefer the trigger-scoped overload wherever the trigger is known, which is everywhere except a bare admin command.
play(UUID, AnimationTrigger, String) — the one to use
boolean started = api.play(playerId, AnimationTrigger.DEATH, "bubble_animation");A player's stored preference is only meaningful together with the trigger it was made under. Any consumer reading preferences.yml must use this form.
false is not an error. It means a gate refused the play — wrong world, missing permission, no preference, already animating, or cooldown. Nothing throws.
playNow(UUID, String) / playNow(UUID, AnimationTrigger, String)
The same gates, without the per-player cooldown.
api.playNow(playerId, AnimationTrigger.DEATH, "bubble_animation");Both playNow overloads call straight into the gate chain; the cooldown is only consulted by play. Use playNow for previews and admin tooling. Do not use it on an event path — the cooldown exists to stop a player who rejoins quickly, or whose teleport fires twice, from getting two freezes and two cameras fighting over the same spectator target.
playNow does not record a play either, so previewing does not start your cooldown clock.
Threading
Main server thread only. A play spawns an entity, teleports the player and moves the camera. Calling it from an async task will throw or corrupt state.
All gates
Every play variant checks, in order, and stops at the first failure:
| Gate | Refused when |
|---|---|
| Unknown id | No animation with that id under that trigger |
| Provider unavailable | No model engine is installed |
| Player offline | The player quit between the event and the play |
| Already animating | A second animation would stack two freezes |
| World | The animation's worlds: list or disabled-worlds covers this world |
| Permission | The player lacks any node the animation lists |
| Mob not loaded | No provider knows the mm-id |
| Cooldown | play, not playNow, and the player played recently |
Order is deliberate: nothing touches the player until the last gate passes.
ModelProvider
Implement this to teach the engine about a model source it does not know.
public interface ModelProvider {
String id();
boolean isAvailable();
Optional<String> unavailableReason();
boolean modelExists(String modelId);
Optional<ModelHandle> spawn(String modelId, Location where);
void remove(ModelHandle handle);
}| Method | Contract |
|---|---|
id() |
The name used in provider-priority, e.g. "bettermodel" |
isAvailable() |
Whether this provider can currently resolve models |
unavailableReason() |
Why it is not, when it is not — shown in diagnostics |
modelExists() |
Must be side-effect-free. It is called during scanning |
spawn() |
Optional.empty() on failure, never throw |
remove() |
Must tolerate being called for an already-removed handle |
Resolution order
CompositeAnimationSpawner walks provider-priority and asks each provider modelExists(). The first that says yes plays it. With two engines installed, that list is how you decide who owns a name they both happen to have.
Listing only one provider does not disable the other — a missing entry is appended after the ones you listed. To stop animations resolving through an engine, remove that engine from the server.
ModelHandle
public interface ModelHandle {
Optional<UUID> entityId();
}The entity id is optional, and that is the important part.
At teardown the engine uses it as a guard: only the spawn belonging to this playback is removed, because removing whatever is in the record is right for a single play and wrong if a second animation started first — that would tear down the wrong mob.
A provider whose handle has no entity id degrades that guard to "release it", which is correct: a packet-rendered model cannot be confused with another animation's the way a shared entity id could.
Registering a provider
provider-priority changes need a restart, not a reload. The engine keeps the provider set it was built with, because that set decides what a running animation can be released through.
PlatformBridge
The version seam. :core cannot name Adventure's Component while also satisfying the Spigot API, so text goes through here and each platform supplies its own implementation.
Use it rather than CommandSender#sendMessage(String) — the Spigot path loses colour codes and component formatting.
Reading the source
The API is heavily commented, and the comments describe bugs that were real:
BrigadierAnimationCommand.register()— why the tree is built forObject, and why the handler cast is not a castAnimationEngine.playInternal— why an unqualified id resolves in declaration order and what it logs when the id is ambiguousAnimationEditor.play()— why the play is requested before the menu closesPaperLifecycleCommandRegistrar.register()— why it returnstruebefore the tree is actually installed
Those are accurate as of the current tree. They exist because the alternative is someone reintroducing the bug.