Class AbstractAnimation
java.lang.Object
xyz.xenondevs.invui.animation.impl.AbstractAnimation
- All Implemented Interfaces:
Animation
- Direct Known Subclasses:
AbstractSoundAnimation
Abstract base class for
Animation implementations.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFinishHandler(@NotNull Runnable finish) voidaddShowHandler(@NotNull BiConsumer<Integer, Integer> show) Adds a show handler.voidcancel()Cancels theAnimation.protected intconvToIndex(int x, int y) Converts the given x and y coordinates to a slot index.protected voidfinish()Stops theAnimationand runs finish handlers.Set<org.bukkit.entity.Player> Finds all current viewers of thisAnimation.protected intgetSlots()The slots that are being animated.protected intgetWidth()protected abstract voidhandleFrame(int frame) Handles the next frame of theAnimation.voidvoidSets the slots that should be shown.voidsetWindows(@NotNull List<Window> windows) Sets theWindows that will see this animation.protected voidshow(int... slots) Shows the given slots.voidstart()Starts theAnimation.
-
Constructor Details
-
AbstractAnimation
public AbstractAnimation(int tickDelay) Creates a newAbstractAnimation.- Parameters:
tickDelay- The delay between each frame
-
-
Method Details
-
setGui
Description copied from interface:Animation -
setWindows
Description copied from interface:AnimationSets theWindows that will see this animation. Useful for playing sounds in a showHandler. (Animation.addShowHandler(BiConsumer))- Specified by:
setWindowsin interfaceAnimation- Parameters:
windows- TheWindows that will see this animation
-
addShowHandler
Description copied from interface:AnimationAdds a show handler. Can be used to for example play a sound when a slot pops up.- Specified by:
addShowHandlerin interfaceAnimation- Parameters:
show- The show handler as aBiConsumerconsisting of frame number (first int) and slot index to show (second int).
-
addFinishHandler
Description copied from interface:Animation- Specified by:
addFinishHandlerin interfaceAnimation- Parameters:
finish- TheRunnablethat should run after theAnimationis finished.
-
start
public void start()Description copied from interface:AnimationStarts theAnimation. -
cancel
public void cancel()Description copied from interface:AnimationCancels theAnimation. -
finish
protected void finish()Stops theAnimationand runs finish handlers. -
handleFrame
protected abstract void handleFrame(int frame) Handles the next frame of theAnimation.- Parameters:
frame- The current frame
-
getSlots
The slots that are being animated. Animation implementations may or may not remove slots that have been shown from the list.- Returns:
- The slots that are being animated
-
setSlots
Description copied from interface:AnimationSets the slots that should be shown. -
show
protected void show(int... slots) Shows the given slots.- Parameters:
slots- The slots to show
-
convToIndex
protected int convToIndex(int x, int y) Converts the given x and y coordinates to a slot index.- Parameters:
x- The x coordinatey- The y coordinate- Returns:
- The slot index
-
getWidth
protected int getWidth()- Returns:
- The width of the
Gui
-
getHeight
protected int getHeight()- Returns:
- The height of the
Gui
-
getCurrentViewers
Finds all current viewers of thisAnimation.- Returns:
- The current viewers
-