diff --git a/api/src/main/java/org/geysermc/geyser/api/pack/PackCodec.java b/api/src/main/java/org/geysermc/geyser/api/pack/PackCodec.java
index ff9f82c5a..7c123b624 100644
--- a/api/src/main/java/org/geysermc/geyser/api/pack/PackCodec.java
+++ b/api/src/main/java/org/geysermc/geyser/api/pack/PackCodec.java
@@ -26,6 +26,7 @@
package org.geysermc.geyser.api.pack;
import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.api.GeyserApi;
import java.io.IOException;
@@ -84,11 +85,11 @@ public abstract class PackCodec {
* Creates a new pack provider from the given url and content key.
*
* @param url the url to create the pack provider from
- * @param contentKey the content key, leave empty if pack is not encrypted
+ * @param contentKey the content key, leave empty or null if pack is not encrypted
* @return the new pack provider
*/
@NonNull
- public static PackCodec url(@NonNull String url, @NonNull String contentKey) {
+ public static PackCodec url(@NonNull String url, @Nullable String contentKey) {
return GeyserApi.api().provider(UrlPackCodec.class, url, contentKey);
}
}
diff --git a/api/src/main/java/org/geysermc/geyser/api/pack/UrlPackCodec.java b/api/src/main/java/org/geysermc/geyser/api/pack/UrlPackCodec.java
index b98e59355..ee449aa7f 100644
--- a/api/src/main/java/org/geysermc/geyser/api/pack/UrlPackCodec.java
+++ b/api/src/main/java/org/geysermc/geyser/api/pack/UrlPackCodec.java
@@ -34,10 +34,10 @@ import org.checkerframework.checker.nullness.qual.NonNull;
* Due to Bedrock limitations, the URL must:
*
* - be a direct download link to a .zip or .mcpack resource pack
- * - Use application type `application/zip` and set a correct content length
+ * - use the application type `application/zip` and set a correct content length
*
*
- * Additionally, the ResourcePack must be zipped in a folder enclosing the resource pack, instead of the resource pack being at the root of the zip.
+ * Additionally, the resource pack must be zipped in a folder enclosing the resource pack, instead of the resource pack being at the root of the zip.
*/
public abstract class UrlPackCodec extends PackCodec {
@@ -51,7 +51,8 @@ public abstract class UrlPackCodec extends PackCodec {
/**
* If the remote pack has an encryption key, it must be specified here.
- * Otherwise, leave empty.
+ * This will return empty if none is specified.
+ *
* @return the encryption key of the resource pack
*/
@NonNull
diff --git a/core/src/main/java/org/geysermc/geyser/pack/url/GeyserUrlPackCodec.java b/core/src/main/java/org/geysermc/geyser/pack/url/GeyserUrlPackCodec.java
index 224ed4920..04bb70663 100644
--- a/core/src/main/java/org/geysermc/geyser/pack/url/GeyserUrlPackCodec.java
+++ b/core/src/main/java/org/geysermc/geyser/pack/url/GeyserUrlPackCodec.java
@@ -27,6 +27,7 @@ package org.geysermc.geyser.pack.url;
import lombok.Getter;
import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.api.pack.ResourcePack;
import org.geysermc.geyser.api.pack.UrlPackCodec;
@@ -47,9 +48,13 @@ public class GeyserUrlPackCodec extends UrlPackCodec {
this(url, "");
}
- public GeyserUrlPackCodec(String url, String contentKey) throws IllegalArgumentException {
+ public GeyserUrlPackCodec(@NonNull String url, @Nullable String contentKey) throws IllegalArgumentException {
+ //noinspection ConstantValue - need to enforce
+ if (url == null) {
+ throw new IllegalArgumentException("Url cannot be nulL!");
+ }
this.url = url;
- this.contentKey = contentKey;
+ this.contentKey = contentKey == null ? "" : contentKey;
}
@Override
diff --git a/core/src/main/java/org/geysermc/geyser/util/WebUtils.java b/core/src/main/java/org/geysermc/geyser/util/WebUtils.java
index 3a039054f..47f9ec22e 100644
--- a/core/src/main/java/org/geysermc/geyser/util/WebUtils.java
+++ b/core/src/main/java/org/geysermc/geyser/util/WebUtils.java
@@ -155,7 +155,7 @@ public class WebUtils {
String cachedEtag = metadataLines.get(1);
long cachedLastModified = Long.parseLong(metadataLines.get(2));
- if (cachedSize == size && cachedEtag.equals(con.getHeaderField("ETag")) && cachedLastModified == con.getLastModified()) {
+ if (cachedSize == size && cachedEtag.equals(con.getHeaderField("ETag")) && cachedLastModified == con.getLastModified() && !force) {
GeyserImpl.getInstance().getLogger().debug("Using cached pack for " + url);
return packLocation;
}
@@ -168,7 +168,7 @@ public class WebUtils {
Files.copy(in, packLocation, StandardCopyOption.REPLACE_EXISTING);
if (Files.size(packLocation) != size) {
- GeyserImpl.getInstance().getLogger().error("Downloaded pack has " + Files.size(packLocation) + " bytes, expected " + size + " bytes");
+ GeyserImpl.getInstance().getLogger().error(String.format("Size mismatch with resource pack at url: %s. Downloaded pack has %s bytes, expected %s bytes!", url, Files.size(packLocation), size));
Files.delete(packLocation);
return null;
}
@@ -186,7 +186,6 @@ public class WebUtils {
GeyserImpl.getInstance().getLogger().error("Unable to reach URL: " + url + " (" + e.getMessage() + ")");
return null;
} catch (IOException e) {
- e.printStackTrace(); // TODO yeeeeeeeet
throw new RuntimeException("Unable to download and save remote resource pack from: " + url + " (" + e.getMessage() + ")");
}
});
diff --git a/core/src/main/resources/config.yml b/core/src/main/resources/config.yml
index 912d51459..52e0d1ac9 100644
--- a/core/src/main/resources/config.yml
+++ b/core/src/main/resources/config.yml
@@ -178,6 +178,7 @@ force-resource-packs: true
# A list of links to send to the client to download resource packs from.
# These must be direct links to the resource pack, not a link to a page containing the resource pack.
# If you enter a link here, Geyser will download the resource pack once to check if it's in a valid format.
+# See https://wiki.geysermc.org/geyser/packs for more info.
resource-pack-urls:
# Example: GeyserOptionalPack
- "https://ci.opencollab.dev/job/GeyserMC/job/GeyserOptionalPack/job/master/lastSuccessfulBuild/artifact/GeyserOptionalPack.mcpack"