Class JarAccess

java.lang.Object
dev.jaxydog.astral.datagen.JarAccess

public final class JarAccess extends Object
Provides safe access to the Minecraft Jar file's assets.

The location of the jar itself should be specified via the "astral.datagen.jar-path" environment variable.

  • Method Details

    • canLoad

      public static boolean canLoad()
      Returns whether the Jar can be loaded.
      Returns:
      If the Jar can load;
    • getJar

      @NotNull public static @NotNull JarFile getJar()
      Returns the handle for the opened Jar file.

      If closed, the jar will automatically re-open itself when requested again.

      Returns:
      The jar file.
    • getJarEntry

      public static Optional<JarEntry> getJarEntry(String path, boolean allowDirs)
      Returns an entry from the Jar, if it exists.
      Parameters:
      path - The requested Jar path.
      allowDirs - Whether directories are allowed to be returned.
      Returns:
      The optional Jar entry.
    • getInputStream

      public static Optional<InputStream> getInputStream(String path)
      Returns an input stream corresponding to an entry within the Jar, if it exists.
      Parameters:
      path - The requested Jar path.
      Returns:
      The optional input stream.