1
0
mirror of https://github.com/Suiranoil/SkinRestorer.git synced 2026-01-16 04:42:12 +00:00

add mineskin api key to config

This commit is contained in:
2024-11-28 08:31:18 +03:00
parent 8329adc476
commit 8820e3ba3f
2 changed files with 15 additions and 1 deletions

View File

@@ -10,6 +10,7 @@ public class MineskinProviderConfig implements BuiltInProviderConfig, GsonPostPr
private boolean enabled;
private String name;
private CacheConfig cache;
private String apiKey;
public MineskinProviderConfig() {
this.enabled = true;
@@ -29,6 +30,10 @@ public class MineskinProviderConfig implements BuiltInProviderConfig, GsonPostPr
return cache;
}
public String apiKey() {
return apiKey;
}
@Override
public void gsonPostProcess() {
if (this.name == null || this.name.isEmpty()) {
@@ -42,5 +47,10 @@ public class MineskinProviderConfig implements BuiltInProviderConfig, GsonPostPr
} else {
this.cache.validate(DEFAULT_CACHE_VALUE);
}
if (this.apiKey == null) {
SkinRestorer.LOGGER.warn("Mineskin API key is null, defaulting to an empty string");
this.apiKey = "";
}
}
}

View File

@@ -45,11 +45,14 @@ public final class MineskinSkinProvider implements SkinProvider {
}
public static void reload() {
var config = SkinRestorer.getConfig();
var configApiKey = config.providersConfig().mineskin().apiKey();
MINESKIN_CLIENT = MineSkinClient
.builder()
.userAgent(WebUtils.USER_AGENT)
.gson(JsonUtils.GSON)
.timeout((int) Duration.ofSeconds(SkinRestorer.getConfig().requestTimeout()).toMillis())
.timeout((int) Duration.ofSeconds(config.requestTimeout()).toMillis())
.requestHandler((userAgent, apiKey, timeout, gson) -> new Java11RequestHandler(
userAgent,
apiKey,
@@ -57,6 +60,7 @@ public final class MineskinSkinProvider implements SkinProvider {
gson,
SkinRestorer.getConfig().proxy().map(proxy -> new InetSocketAddress(proxy.host(), proxy.port())).orElse(null)
))
.apiKey(configApiKey.isEmpty() ? null : configApiKey)
.build();
createCache();