Class AnimatedItem
java.lang.Object
me.gamercoder215.starcosmetics.api.cosmetics.AnimatedItem
- All Implemented Interfaces:
Cloneable
Utility class for describing instructions creating an Animated Item
NOTE: Starting this hat will NOT automatically and safely remove/replace existing helmets or hats.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classRepresents a Builder for Animated Hat Data. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull AnimatedItem.Builderbuilder(@NotNull BiConsumer<Player, ItemStack> function) Constructs a new Builder for Animated Hat Data.@NotNull AnimatedItemclone()Clones this Animated Hat Data.Fetches an immutable copy of the frames for this Animated Hat.@NotNull BiConsumer<Player,ItemStack> Fetches the function to run when starting this Animated Hat.@Nullable PlayerFetches the player that this Animated Hat is started for.booleanFetches whether this Animated Hat has been started.@NotNull AnimatedItemMaps the itemstacks in the frames of this Animated Hat Data to a new Animated Hat Data.static AnimatedItemConstructs a new Animated Hat Data with the given frames.voidstop()Stops this Animated Hat, if it is started, makinggetPlayer()return null andisStarted()return false.stream()Utility method for shortcutting togetFrames()stream.voidAttempts to start and finish this Animated Hat for the given player.
-
Method Details
-
isStarted
public boolean isStarted()Fetches whether this Animated Hat has been started.- Returns:
- true if started, false otherwise
-
getPlayer
Fetches the player that this Animated Hat is started for.- Returns:
- Player using Animated Hat, or null if not started
-
getFrames
Fetches an immutable copy of the frames for this Animated Hat.- Returns:
- Animated Hat Frames
-
stream
Utility method for shortcutting togetFrames()stream.- Returns:
- Animated Hat Frames Stream
-
map
Maps the itemstacks in the frames of this Animated Hat Data to a new Animated Hat Data.- Parameters:
mapper- function to map itemstacks in frames- Returns:
- new Animated Hat Data with mapped itemstack hats
-
getFunction
Fetches the function to run when starting this Animated Hat.- Returns:
- Function to run when starting this Animated Hat
-
tryStart
Attempts to start and finish this Animated Hat for the given player. This action performs once cycle of the animated hat, then marks it as stopped.- Parameters:
p- the player to start the Animated Hat for
-
stop
public void stop()Stops this Animated Hat, if it is started, makinggetPlayer()return null andisStarted()return false. -
clone
Clones this Animated Hat Data. -
of
public static AnimatedItem of(@NotNull @NotNull BiConsumer<Player, ItemStack> function, @NotNull @NotNull List<Map.Entry<Long, throws IllegalArgumentExceptionItemStack>> frames) Constructs a new Animated Hat Data with the given frames.- Parameters:
function- Function to run when starting this Animated Hatframes- Frames to use, a list of map entries describing duration (key) and hat item to use (value)- Returns:
- Constructed AnimatedHatData
- Throws:
IllegalArgumentException- if frames is null or less than 2 frames
-
builder
@NotNull public static @NotNull AnimatedItem.Builder builder(@NotNull @NotNull BiConsumer<Player, ItemStack> function) Constructs a new Builder for Animated Hat Data.- Parameters:
function- Function to run when starting this Animated Hat- Returns:
- AnimatedHatData Builder
-