@FunctionalInterface
public interface ResourcePackRequestHandler
Download requests may or may not be executed by Minecraft
clients, this is determined by the nullness of the received
ResourcePackDownloadRequest instance.
| Modifier and Type | Method and Description |
|---|---|
static @NotNull ResourcePackRequestHandler |
fixed(@NotNull team.unnamed.creative.BuiltResourcePack pack)
Creates a new
ResourcePackRequestHandler instance
that will always return the given resource-pack. |
static @NotNull ResourcePackRequestHandler |
fixed(@NotNull team.unnamed.creative.BuiltResourcePack pack,
boolean validOnly)
Creates a new
ResourcePackRequestHandler instance
that will always return the given resource-pack. |
void |
onRequest(@Nullable ResourcePackDownloadRequest request,
@NotNull com.sun.net.httpserver.HttpExchange exchange)
Handles a resource pack request, the resulting resource
pack is written to
HttpExchange.getResponseBody() |
@Contract(value="_, _ -> new") @NotNull static @NotNull ResourcePackRequestHandler fixed(@NotNull @NotNull team.unnamed.creative.BuiltResourcePack pack, boolean validOnly)
ResourcePackRequestHandler instance
that will always return the given resource-pack.pack - The resource-pack to returnvalidOnly - Whether to only return the resource-pack
if the request is valid (has all the values
that a Minecraft vanilla client would send)@Contract(value="_ -> new") @NotNull static @NotNull ResourcePackRequestHandler fixed(@NotNull @NotNull team.unnamed.creative.BuiltResourcePack pack)
ResourcePackRequestHandler instance
that will always return the given resource-pack.pack - The resource-pack to returnvoid onRequest(@Nullable
@Nullable ResourcePackDownloadRequest request,
@NotNull
@NotNull com.sun.net.httpserver.HttpExchange exchange)
throws java.io.IOException
HttpExchange.getResponseBody()
An "application/zip" Content-Type header should be set
when returning a resource-pack, HttpExchange.getResponseHeaders()
request - The resource pack request, null means that the
request couldn't be parsed and the requester is
not a Minecraft clientexchange - The HTTP exchangejava.io.IOException - If writing the response failsHttpExchange