Class ResourcePackLoader

java.lang.Object
org.geysermc.geyser.registry.loader.ResourcePackLoader
All Implemented Interfaces:
RegistryLoader<Path,Map<UUID,ResourcePackHolder>>

public class ResourcePackLoader extends Object implements RegistryLoader<Path,Map<UUID,ResourcePackHolder>>
Loads ResourcePacks within a Path directory, firing the GeyserDefineResourcePacksEventImpl.
  • Constructor Details

    • ResourcePackLoader

      public ResourcePackLoader()
  • Method Details

    • load

      public Map<UUID,ResourcePackHolder> load(Path directory)
      Loop through the packs directory and locate valid resource pack files
      Specified by:
      load in interface RegistryLoader<Path,Map<UUID,ResourcePackHolder>>
      Parameters:
      directory - the input
      Returns:
      the output
    • readPack

      public static GeyserResourcePack.Builder readPack(Path path) throws IllegalArgumentException
      Reads a resource pack builder at the given file. Also searches for a file in the same directory, with the same name but suffixed by ".key", containing the content key. If such file does not exist, no content key is stored.
      Parameters:
      path - the file to read from, in ZIP format
      Returns:
      a ResourcePack.Builder representation
      Throws:
      IllegalArgumentException - if the pack manifest was invalid or there was any processing exception
    • readPack

      Reads a Resource pack from a URL codec, and returns a resource pack. Unlike readPack(Path) this method reads content keys differently.
      Parameters:
      codec - the URL pack codec with the url to download the pack from
      Returns:
      a GeyserResourcePack representation
      Throws:
      IllegalArgumentException - if there was an error reading the pack.
    • testRemotePack

      public static void testRemotePack(GeyserSession session, org.geysermc.geyser.api.pack.UrlPackCodec codec, UUID packId, String packVersion)
      Used when a Bedrock client requests a Bedrock resource pack from the server when it should be downloading it from a remote provider. Since this would be called each time a Bedrock client requests a piece of the Bedrock pack, this uses a cache to ensure we aren't re-checking a dozen times.
      Parameters:
      codec - the codec of the resource pack that wasn't successfully downloaded by a Bedrock client.
    • downloadPack

      public static CompletableFuture<@Nullable org.geysermc.geyser.api.pack.PathPackCodec> downloadPack(String url, boolean testing) throws IllegalArgumentException
      Throws:
      IllegalArgumentException
    • clear

      public static void clear()
    • cleanupRemotePacks

      public static void cleanupRemotePacks()