Enable NightSync GIF capes by default
This commit is contained in:
1 parent
c73bb5b19a
commit
82da98cc35
4 files changed
+16
-9
No files matched your search
@@ -44,8 +44,8 @@ client's `mods/` folder. Client-side only.
|
||||
|
||||
## Configuration
|
||||
|
||||
On first launch the mod writes `config/skinsg.json` with an **empty** `baseUrl`. Nothing is
|
||||
fetched until you set it.
|
||||
On first launch the NightSync build writes `config/skinsg.json` with
|
||||
`https://nightsync.xyz` as `baseUrl`. Existing empty configs are migrated automatically.
|
||||
|
||||
```json
|
||||
{
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ org.gradle.parallel=true
|
||||
# --- Mod ---
|
||||
mod_id=skinsg
|
||||
mod_name=HD Skin Support (Gravit)
|
||||
mod_version=0.1.1
|
||||
mod_version=0.1.2
|
||||
mod_group_id=xyz.nightsync.skinsg
|
||||
mod_license=All Rights Reserved
|
||||
mod_author=Nghtly
|
||||
|
||||
Reference in new issue
Block a user