Class AnimatedHatData

java.lang.Object
me.gamercoder215.starcosmetics.api.cosmetics.hat.AnimatedHatData
All Implemented Interfaces:
Cloneable

public final class AnimatedHatData extends Object implements 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.
  • Method Details

    • isStarted

      public boolean isStarted()
      Fetches whether this Animated Hat has been started.
      Returns:
      true if started, false otherwise
    • getPlayer

      @Nullable public @Nullable Player getPlayer()
      Fetches the player that this Animated Hat is started for.
      Returns:
      Player using Animated Hat, or null if not started
    • getFrames

      @NotNull public @NotNull List<Map.Entry<Long,ItemStack>> getFrames()
      Fetches an immutable copy of the frames for this Animated Hat.
      Returns:
      Animated Hat Frames
    • stream

      @NotNull public @NotNull Stream<Map.Entry<Long,ItemStack>> stream()
      Utility method for shortcutting to getFrames() 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

      public void tryStart(@NotNull @NotNull Player p)
      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, making getPlayer() return null and isStarted() return false.
    • clone

      @NotNull public @NotNull AnimatedHatData clone()
      Clones this Animated Hat Data.
      Overrides:
      clone in class Object
      Returns:
      Cloned Animated Hat Data
    • of

      public static AnimatedHatData of(@NotNull @NotNull List<Map.Entry<Long,ItemStack>> frames) throws IllegalArgumentException
      Constructs 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

      @NotNull public static @NotNull AnimatedHatData.Builder builder()
      Constructs a new Builder for Animated Hat Data.
      Returns:
      AnimatedHatData Builder