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

+2 -2
View File
@@ -44,8 +44,8 @@ client's `mods/` folder. Client-side only.
## Configuration ## Configuration
On first launch the mod writes `config/skinsg.json` with an **empty** `baseUrl`. Nothing is On first launch the NightSync build writes `config/skinsg.json` with
fetched until you set it. `https://nightsync.xyz` as `baseUrl`. Existing empty configs are migrated automatically.
```json ```json
{ {
@@ -18,8 +18,9 @@ public final class SkinsgConfig {
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
public static final int DEFAULT_SPEED = 100; 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 Mode mode = Mode.ALL;
public Set<String> enabled = new LinkedHashSet<>(); public Set<String> enabled = new LinkedHashSet<>();
public Set<String> blocked = new LinkedHashSet<>(); public Set<String> blocked = new LinkedHashSet<>();
@@ -41,12 +42,12 @@ public final class SkinsgConfig {
} }
cfg.normalize(); cfg.normalize();
cfg.file = f; cfg.file = f;
if (fresh) cfg.save(); cfg.save();
return cfg; return cfg;
} }
private void normalize() { private void normalize() {
if (baseUrl == null) baseUrl = ""; if (baseUrl == null || baseUrl.isBlank()) baseUrl = DEFAULT_BASE_URL;
baseUrl = baseUrl.trim(); baseUrl = baseUrl.trim();
while (baseUrl.endsWith("/")) baseUrl = baseUrl.substring(0, baseUrl.length() - 1); while (baseUrl.endsWith("/")) baseUrl = baseUrl.substring(0, baseUrl.length() - 1);
if (mode == null) mode = Mode.ALL; 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.AbstractTexture;
import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import xyz.nightsync.skinsg.SkinsgConfig; import xyz.nightsync.skinsg.SkinsgConfig;
import xyz.nightsync.skinsg.gif.GifDecoder; import xyz.nightsync.skinsg.gif.GifDecoder;
import xyz.nightsync.skinsg.gif.GifImage; import xyz.nightsync.skinsg.gif.GifImage;
@@ -35,6 +37,7 @@ public final class CapeManager {
private static final String MODID = "skinsg"; private static final String MODID = "skinsg";
private static final int MAX_CACHE = 96; private static final int MAX_CACHE = 96;
private static final int MAX_BYTES = 12 * 1024 * 1024; private static final int MAX_BYTES = 12 * 1024 * 1024;
private static final Logger LOGGER = LoggerFactory.getLogger("skinsg");
private static SkinsgConfig config; private static SkinsgConfig config;
private static Supplier<UUID> selfProvider = () -> null; private static Supplier<UUID> selfProvider = () -> null;
@@ -110,8 +113,9 @@ public final class CapeManager {
return; return;
} }
buildTexture(entry, GifDecoder.decode(bytes, LIMITS)); buildTexture(entry, GifDecoder.decode(bytes, LIMITS));
} catch (Throwable t) { } catch (Exception | LinkageError t) {
entry.noAnimation = true; entry.noAnimation = true;
LOGGER.error("[SkinsG/Cape] Failed to load animated cape for uuid={}", uuid, t);
} }
}); });
return entry; return entry;
@@ -125,8 +129,9 @@ public final class CapeManager {
ResourceLocation id = new ResourceLocation(MODID, "cape/" + entry.uuid + "/anim"); ResourceLocation id = new ResourceLocation(MODID, "cape/" + entry.uuid + "/anim");
Minecraft.getInstance().getTextureManager().register(id, tex); Minecraft.getInstance().getTextureManager().register(id, tex);
entry.attach(gif, tex, id); entry.attach(gif, tex, id);
} catch (Throwable t) { } catch (Exception | LinkageError t) {
entry.noAnimation = true; 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.setConnectTimeout(7000);
c.setReadTimeout(10000); c.setReadTimeout(10000);
c.setRequestProperty("User-Agent", MODID + "/1.0"); 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(); int len = c.getContentLength();
if (len > MAX_BYTES) return null; if (len > MAX_BYTES) return null;
try (InputStream in = c.getInputStream()) { try (InputStream in = c.getInputStream()) {
+1 -1
View File
@@ -6,7 +6,7 @@ org.gradle.parallel=true
# --- Mod --- # --- Mod ---
mod_id=skinsg mod_id=skinsg
mod_name=HD Skin Support (Gravit) mod_name=HD Skin Support (Gravit)
mod_version=0.1.1 mod_version=0.1.2
mod_group_id=xyz.nightsync.skinsg mod_group_id=xyz.nightsync.skinsg
mod_license=All Rights Reserved mod_license=All Rights Reserved
mod_author=Nghtly mod_author=Nghtly