Class PackBuilder

java.lang.Object
kr.toxicity.model.api.pack.PackBuilder

public final class PackBuilder extends Object
A builder for constructing resource pack contents within a specific path context.

This class simplifies adding resources to a pack by managing the current path and providing methods to resolve sub-paths. It also integrates with PackObfuscator for resource name obfuscation.

Since:
1.15.2
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(@NotNull String[] paths, long size, @NotNull Supplier<byte[]> supplier)
    Adds a resource to the pack at the current path using multiple path components.
    void
    add(@NotNull String[] paths, @NotNull Supplier<byte[]> supplier)
    Adds a resource to the pack at the current path using multiple path components with unknown size.
    void
    add(@NotNull String path, long estimatedSize, @NotNull Supplier<byte[]> supplier)
    Adds a resource to the pack at the current path.
    void
    add(@NotNull String path, @NotNull Supplier<byte[]> supplier)
    Adds a resource to the pack at the current path with unknown size.
    Returns the obfuscator associated with this builder.
    @NotNull PackBuilder
    resolve(@NotNull String... paths)
    Resolves a sub-path and returns a new builder for that path.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PackBuilder

      public PackBuilder()
  • Method Details

    • resolve

      @NotNull public @NotNull PackBuilder resolve(@NotNull @NotNull String... paths)
      Resolves a sub-path and returns a new builder for that path.
      Parameters:
      paths - the sub-path components
      Returns:
      a new PackBuilder for the resolved path
      Since:
      1.15.2
    • add

      public void add(@NotNull @NotNull String path, long estimatedSize, @NotNull @NotNull Supplier<byte[]> supplier)
      Adds a resource to the pack at the current path.
      Parameters:
      path - the relative path of the resource
      estimatedSize - the estimated size of the resource
      supplier - the supplier for the resource content
      Since:
      1.15.2
    • add

      public void add(@NotNull @NotNull String[] paths, long size, @NotNull @NotNull Supplier<byte[]> supplier)
      Adds a resource to the pack at the current path using multiple path components.
      Parameters:
      paths - the relative path components
      size - the estimated size of the resource
      supplier - the supplier for the resource content
      Since:
      1.15.2
    • obfuscator

      @NotNull public @NotNull PackObfuscator obfuscator()
      Returns the obfuscator associated with this builder.
      Returns:
      the obfuscator
      Since:
      1.15.2
    • add

      public void add(@NotNull @NotNull String path, @NotNull @NotNull Supplier<byte[]> supplier)
      Adds a resource to the pack at the current path with unknown size.
      Parameters:
      path - the relative path of the resource
      supplier - the supplier for the resource content
      Since:
      1.15.2
    • add

      public void add(@NotNull @NotNull String[] paths, @NotNull @NotNull Supplier<byte[]> supplier)
      Adds a resource to the pack at the current path using multiple path components with unknown size.
      Parameters:
      paths - the relative path components
      supplier - the supplier for the resource content
      Since:
      1.15.2