Enable NightSync GIF capes by default

This commit is contained in:
f1den committed 2026-07-11 22:06:36 +03:00
1 parent c73bb5b19a
commit 82da98cc35
4 files changed
+16 -9

No files matched your search

@@ -18,8 +18,9 @@ public final class SkinsgConfig {
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
public static final int DEFAULT_SPEED = 100;
public static final String DEFAULT_BASE_URL = "https://nightsync.xyz";
public String baseUrl = "";
public String baseUrl = DEFAULT_BASE_URL;
public Mode mode = Mode.ALL;
public Set<String> enabled = new LinkedHashSet<>();
public Set<String> blocked = new LinkedHashSet<>();
@@ -41,12 +42,12 @@ public final class SkinsgConfig {
}
cfg.normalize();
cfg.file = f;
if (fresh) cfg.save();
cfg.save();
return cfg;
}
private void normalize() {
if (baseUrl == null) baseUrl = "";
if (baseUrl == null || baseUrl.isBlank()) baseUrl = DEFAULT_BASE_URL;
baseUrl = baseUrl.trim();
while (baseUrl.endsWith("/")) baseUrl = baseUrl.substring(0, baseUrl.length() - 1);
if (mode == null) mode = Mode.ALL;
@@ -6,6 +6,8 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.AbstractTexture;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.resources.ResourceLocation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import xyz.nightsync.skinsg.SkinsgConfig;
import xyz.nightsync.skinsg.gif.GifDecoder;
import xyz.nightsync.skinsg.gif.GifImage;
@@ -35,6 +37,7 @@ public final class CapeManager {
private static final String MODID = "skinsg";
private static final int MAX_CACHE = 96;
private static final int MAX_BYTES = 12 * 1024 * 1024;
private static final Logger LOGGER = LoggerFactory.getLogger("skinsg");
private static SkinsgConfig config;
private static Supplier<UUID> selfProvider = () -> null;
@@ -110,8 +113,9 @@ public final class CapeManager {
return;
}
buildTexture(entry, GifDecoder.decode(bytes, LIMITS));
} catch (Throwable t) {
} catch (Exception | LinkageError t) {
entry.noAnimation = true;
LOGGER.error("[SkinsG/Cape] Failed to load animated cape for uuid={}", uuid, t);
}
});
return entry;
@@ -125,8 +129,9 @@ public final class CapeManager {
ResourceLocation id = new ResourceLocation(MODID, "cape/" + entry.uuid + "/anim");
Minecraft.getInstance().getTextureManager().register(id, tex);
entry.attach(gif, tex, id);
} catch (Throwable t) {
} catch (Exception | LinkageError t) {
entry.noAnimation = true;
LOGGER.error("[SkinsG/Cape] Failed to create animated cape texture for uuid={}", entry.uuid, t);
}
});
}
@@ -140,7 +145,8 @@ public final class CapeManager {
c.setConnectTimeout(7000);
c.setReadTimeout(10000);
c.setRequestProperty("User-Agent", MODID + "/1.0");
if (c.getResponseCode() != 200) return null;
int status = c.getResponseCode();
if (status != 200) throw new IOException("Cape endpoint returned HTTP " + status);
int len = c.getContentLength();
if (len > MAX_BYTES) return null;
try (InputStream in = c.getInputStream()) {