Skip to content

API Animations

Jay edited this page Jan 2, 2026 · 1 revision

Getting DisplayAnimations

//Get a DisplayAnimation from an InputStream
DisplayAnimation animationFromStream = DisplayAnimationManager.getAnimation(InputStream);

//Get a DisplayAnimation from a File
DisplayAnimation animationFromFile = DisplayAnimationManager.getAnimation(File);

//Get a DisplayAnimation from a storage location (LOCAL, MONGODB, or MYSQL)
DisplayAnimation animationFromStorage = DisplayAnimationManager.getAnimation(LoadMethod.LOCAL, "animationTag");

//Get a DisplayAnimation stored in a plugin's resources
DisplayAnimation animationFromResources = DisplayAnimationManager.getAnimation(MyPlugin.getInstance(), "animationTag");

Getting SpawnedDisplayAnimations (Conversion from DisplayAnimation or get from cache)

If you want to use an animation for multiple ActiveGroups, you only have to convert a DisplayAnimation to a SpawnedDisplayAnimation ONCE and it can be used repeatedly

//After getting your saved DisplayAnimation convert it into a SpawnedDisplayAnimation
SpawnedDisplayAnimation spawnedAnimation = savedAnimation.toSpawnedDisplayAnimation();

//Get a SpawnedDisplayAnimation from cache or storage (cache prioritized)
SpawnedDisplayAnimation cacheOrStorage = DisplayAnimationManager.getSpawnedDisplayAnimation("animationTag", LoadMethod.LOCAL);

//Get a SpawnedDisplayAnimation ONLY if cached
SpawnedDisplayAnimation cachedOnlyAnimation = DisplayAnimationManager.getCachedAnimation("animationTag");

//Now the SpawnedDisplayAnimation can applied to SpawnedDisplayEntityGroups or be used in DisplayAnimators and/or DisplayAnimatorStateMachines

Playing Animations on ActiveGroups

ActiveGroup<?> group = yourMethodToGetAnActiveGroup();
//This is a quick way to start an animation on an ActiveGroup
group.animate(spawnedAnimation);

//Starts a looping animation on an ActiveGroup
group.animateLooping(spawnedAnimation);

//Both #animate() and #animateLooping() return a DisplayAnimator (discussed further in the next section)
//DisplayAnimators are the object that actually control the animation, and holds what groups are animated by that specific animator
DisplayAnimator displayAnimator = group.animate(spawnedAnimation);

//Display an animation frame on an ActiveGroup
int frameId = 5; //5 is the frame ID (index), but it is the 6th frame of the animation
boolean showAsync = false;

spawnedDisplayEntityGroup.setToFrame(spawnedAnimation, frameId, showAsync)
packetDisplayEntityGroup.setToFrame(spawnedAnimation, frameId);

//Stopping Animations
boolean removeFromStateMachine = false;

group.stopAnimation(displayAnimator); //Stop a DisplayAnimator controlled animation

group.stopAnimations(removeFromStateMachine); //Stop ALL Animations

Play (Packet) Animations with DisplayAnimators

If you want to use a DisplayAnimator for multiple ActiveGroups, you only have create ONE instance for a single SpawnedDisplayAnimation and it can be used repeatedly

//DisplayAnimators provide more control over an animation and the type of animation to be performed (LINEAR or LOOP)

//Create a linear animator (Animates an ActiveGroup once)
DisplayAnimator linearAnimator = new DisplayAnimator(savedAnimation, DisplayAnimator.AnimationType.LINEAR)

int frameId = 5; //5 is the frame ID (index), but it is the 6th frame of the animation
//Start an animation on a group
linearAnimator.play(group, frameId); //0 is the frame ID (index), but it is the first frame of the animation

//Play a packet-based animation for a specific player 
linearAnimator.play(player, group, frameId);

//Play a packet-based animation for a group of players. (This is more efficient than repeatedly using the method above for each player)
linearAnimation.play(players, group, frameId);

//Stop an animation on a group
linearAnimator.stop(group);

//Stop an animation for a specific player on a specific group
linearAnimator.stop(player, group);

//Stop all animations using this animator for a specific player
linearAnimator.stop(player);

//Create a looping animator (Plays repeatedly after DisplayAnimator#start() and runs until DisplayAnimator#stop() is called)
DisplayAnimator loopingAnimator = new DisplayAnimator(savedAnimation, DisplayAnimator.AnimationType.LOOP)

Reverse SpawnedDisplayAnimations

SpawnedDisplayAnimation spawnedAnimation = yourMethodToGetASpawnedDisplayAnimation();

//Reverses the order of frames in a SpawnedDisplayAnimation
spawnedAnimation.reverse();

//Get a copy of a SpawnedDisplayAnimation with reversed frames
spawnedAnimation.getReversedAnimation();

Serialize SpawnedDisplayAnimations

//Convert a SpawnedDisplayAnimation into a DisplayAnimation, which is serializable
SpawnedDisplayAnimation spawnedAnimation = yourMethodToGetASpawnedDisplayAnimation();
spawnedAnimation.toDisplayAnimation();

Clone this wiki locally