Class AnimatedItem.Builder

java.lang.Object
me.gamercoder215.starcosmetics.api.cosmetics.AnimatedItem.Builder
Enclosing class:
AnimatedItem

public static final class AnimatedItem.Builder extends Object
Represents a Builder for Animated Hat Data.
  • Method Details

    • function

      public AnimatedItem.Builder function(@NotNull @NotNull BiConsumer<Player,ItemStack> function)
      Sets the function to run when starting this Animated Hat.
      Parameters:
      function - function to run
      Returns:
      this class, for chaining
    • setFrames

      @NotNull public @NotNull AnimatedItem.Builder setFrames(@NotNull @NotNull Collection<Map.Entry<Long,ItemStack>> frames)
      Clears and sets the frames for this Animated Hat Data.
      Parameters:
      frames - the frames to set
      Returns:
      this class, for chaining
    • addFrames

      @NotNull public @NotNull AnimatedItem.Builder addFrames(@NotNull @NotNull Iterable<? extends Map.Entry<Long,ItemStack>> frames)
      Adds a frame to this Animated Hat Data.
      Parameters:
      frames - list of frames to add
      Returns:
      this class, for chaining
    • addFrame

      @NotNull public @NotNull AnimatedItem.Builder addFrame(long duration, ItemStack item)
      Adds a frame to this Animated Hat Data.
      Parameters:
      duration - duration of frame, in ticks
      item - itemstack hat of frame
      Returns:
      this class, for chaining
    • addFrame

      @NotNull public @NotNull AnimatedItem.Builder addFrame(int index, long duration, ItemStack item)
      Adds a frame to this Animated Hat Data.
      Parameters:
      index - index to add frame at
      duration - duration of frame, in ticks
      item - itemstack hat of frame
      Returns:
      this class, for chaining
    • setFrame

      @NotNull public @NotNull AnimatedItem.Builder setFrame(int index, long duration, ItemStack item)
      Sets a frame in this Animated Hat Data.
      Parameters:
      duration - duration of frame, in ticks
      item - itemstack hat of frame
      index - index to set frame at
      Returns:
      this class, for chaining
    • build

      @NotNull public @NotNull AnimatedItem build() throws IllegalStateException
      Builds a new Animated Hat Data with the given frames.
      Returns:
      Built AnimatedHatData
      Throws:
      IllegalStateException - if there are less than 2 frames