Class AnimatedHatData
java.lang.Object
me.gamercoder215.starcosmetics.api.cosmetics.hat.AnimatedHatData
- All Implemented Interfaces:
Cloneable
Utility class for describing instructions creating an Animated Hat
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 AnimatedHatData.Builderbuilder()Constructs a new Builder for Animated Hat Data.@NotNull AnimatedHatDataclone()Clones this Animated Hat Data.Fetches an immutable copy of the frames for this Animated Hat.@Nullable PlayerFetches the player that this Animated Hat is started for.booleanFetches whether this Animated Hat has been started.@NotNull AnimatedHatDataMaps the itemstacks in the frames of this Animated Hat Data to a new Animated Hat Data.static AnimatedHatDataConstructs 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
@NotNull public @NotNull AnimatedHatData map(@NotNull @NotNull Function<ItemStack, ItemStack> mapper) 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
-
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 AnimatedHatData of(@NotNull @NotNull List<Map.Entry<Long, ItemStack>> frames) throws IllegalArgumentExceptionConstructs a new Animated Hat Data with the given frames.- Parameters:
frames- 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
Constructs a new Builder for Animated Hat Data.- Returns:
- AnimatedHatData Builder
-