diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java b/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java index 12719858..16346b16 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java @@ -204,10 +204,9 @@ public final class HDSkinManager implements IResourceManagerReloadListener { private Map loadProfileData(GameProfile profile) { Map textures = Maps.newEnumMap(Type.class); - skinServers.forEach(server -> server - .loadProfileData(profile) - .map(MinecraftTexturesPayload::getTextures) - .ifPresent(a -> a.forEach(textures::putIfAbsent))); + for (SkinServer server : skinServers) { + server.getProfileTextures(profile).forEach(textures::putIfAbsent); + } return textures; } diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/PreviewTextureManager.java b/src/hdskins/java/com/voxelmodpack/hdskins/PreviewTextureManager.java index e01ee425..0b55f3a4 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/PreviewTextureManager.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/PreviewTextureManager.java @@ -38,7 +38,7 @@ public class PreviewTextureManager { @Nullable private PreviewTexture loadPreviewTexture(ResourceLocation location, Type type, ResourceLocation def, @Nullable SkinAvailableCallback callback) { if (textures == null) { - textures = HDSkinManager.INSTANCE.getGatewayServer().getPreviewTextures(profile); + textures = HDSkinManager.INSTANCE.getGatewayServer().getProfileTextures(profile); } if (!textures.containsKey(type)) { diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/skins/AbstractSkinServer.java b/src/hdskins/java/com/voxelmodpack/hdskins/skins/AbstractSkinServer.java index 5196d443..2b8cb9bd 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/skins/AbstractSkinServer.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/skins/AbstractSkinServer.java @@ -4,7 +4,6 @@ import java.io.IOException; import java.net.URI; import java.util.Collections; import java.util.Map; -import java.util.Optional; import java.util.concurrent.CompletableFuture; import javax.annotation.Nullable; @@ -32,15 +31,14 @@ public abstract class AbstractSkinServer implements SkinServer { } @Override - public final Optional loadProfileData(GameProfile profile) { - return Optional.ofNullable(getProfileData(profile)); - } + public Map getProfileTextures(GameProfile profile) { + MinecraftTexturesPayload payload = getProfileData(profile); - @Override - public Map getPreviewTextures(GameProfile profile) { - return loadProfileData(profile) - .map(MinecraftTexturesPayload::getTextures) - .orElse(Collections.emptyMap()); + if (payload != null && payload.getTextures() != null) { + return payload.getTextures(); + } + + return Collections.emptyMap(); } @Override @@ -57,8 +55,6 @@ public abstract class AbstractSkinServer implements SkinServer { } } - protected abstract MinecraftTexturesPayload getProfileData(GameProfile profile); - protected abstract SkinUploadResponse doUpload(Session session, URI image, Type type, Map metadata) throws AuthenticationException, IOException; @Override diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/skins/BethlehemSkinServer.java b/src/hdskins/java/com/voxelmodpack/hdskins/skins/BethlehemSkinServer.java index 8fd33315..eb6f235c 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/skins/BethlehemSkinServer.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/skins/BethlehemSkinServer.java @@ -26,7 +26,7 @@ public class BethlehemSkinServer extends AbstractSkinServer { } @Override - protected MinecraftTexturesPayload getProfileData(GameProfile profile) { + public MinecraftTexturesPayload getProfileData(GameProfile profile) { try (NetClient client = new NetClient("GET", getPath(profile))) { if (client.getResponseCode() == HttpStatus.SC_OK) { return gson.fromJson(client.getResponseText(), MinecraftTexturesPayload.class); diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/skins/LegacySkinServer.java b/src/hdskins/java/com/voxelmodpack/hdskins/skins/LegacySkinServer.java index 1657d17e..1780b31e 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/skins/LegacySkinServer.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/skins/LegacySkinServer.java @@ -39,7 +39,7 @@ public class LegacySkinServer extends AbstractSkinServer { } @Override - public Map getPreviewTextures(GameProfile profile) { + public Map getProfileTextures(GameProfile profile) { Map map = new EnumMap<>(Type.class); for (Type type : Type.values()) { @@ -51,7 +51,7 @@ public class LegacySkinServer extends AbstractSkinServer { @SuppressWarnings("deprecation") @Override - protected MinecraftTexturesPayload getProfileData(GameProfile profile) { + public MinecraftTexturesPayload getProfileData(GameProfile profile) { ImmutableMap.Builder builder = ImmutableMap.builder(); for (Type type : Type.values()) { diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/skins/SkinServer.java b/src/hdskins/java/com/voxelmodpack/hdskins/skins/SkinServer.java index 0428671a..a08a4905 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/skins/SkinServer.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/skins/SkinServer.java @@ -18,7 +18,6 @@ import net.minecraft.util.Session; import java.net.URI; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.UUID; import java.util.concurrent.CompletableFuture; @@ -34,9 +33,9 @@ public interface SkinServer extends Exposable { "http://skins.voxelmodpack.com", "http://skinmanager.voxelmodpack.com")); - Optional loadProfileData(GameProfile profile); + MinecraftTexturesPayload getProfileData(GameProfile profile); - Map getPreviewTextures(GameProfile profile); + Map getProfileTextures(GameProfile profile); CompletableFuture uploadSkin(Session session, @Nullable URI image, MinecraftProfileTexture.Type type, Map metadata); diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/skins/ValhallaSkinServer.java b/src/hdskins/java/com/voxelmodpack/hdskins/skins/ValhallaSkinServer.java index 7bd21324..8870c999 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/skins/ValhallaSkinServer.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/skins/ValhallaSkinServer.java @@ -47,11 +47,12 @@ public class ValhallaSkinServer extends AbstractSkinServer { } @Override - protected MinecraftTexturesPayload getProfileData(GameProfile profile) { - try (CloseableHttpClient client = HttpClients.createSystem(); - CloseableHttpResponse response = client.execute(new HttpGet(getTexturesURI(profile)))) { - if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { - return readJson(response, MinecraftTexturesPayload.class); + public MinecraftTexturesPayload getProfileData(GameProfile profile) { + try (CloseableHttpClient client = HttpClients.createSystem()) { + try (CloseableHttpResponse response = client.execute(new HttpGet(getTexturesURI(profile)))) { + if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { + return readJson(response, MinecraftTexturesPayload.class); + } } } catch (IOException e) {