We really don't need any of this

This commit is contained in:
Sollace 2018-07-31 09:45:34 +02:00
parent 43ae93c186
commit fa44676aa7
7 changed files with 22 additions and 27 deletions

View file

@ -204,10 +204,9 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
private Map<Type, MinecraftProfileTexture> loadProfileData(GameProfile profile) { private Map<Type, MinecraftProfileTexture> loadProfileData(GameProfile profile) {
Map<Type, MinecraftProfileTexture> textures = Maps.newEnumMap(Type.class); Map<Type, MinecraftProfileTexture> textures = Maps.newEnumMap(Type.class);
skinServers.forEach(server -> server for (SkinServer server : skinServers) {
.loadProfileData(profile) server.getProfileTextures(profile).forEach(textures::putIfAbsent);
.map(MinecraftTexturesPayload::getTextures) }
.ifPresent(a -> a.forEach(textures::putIfAbsent)));
return textures; return textures;
} }

View file

@ -38,7 +38,7 @@ public class PreviewTextureManager {
@Nullable @Nullable
private PreviewTexture loadPreviewTexture(ResourceLocation location, Type type, ResourceLocation def, @Nullable SkinAvailableCallback callback) { private PreviewTexture loadPreviewTexture(ResourceLocation location, Type type, ResourceLocation def, @Nullable SkinAvailableCallback callback) {
if (textures == null) { if (textures == null) {
textures = HDSkinManager.INSTANCE.getGatewayServer().getPreviewTextures(profile); textures = HDSkinManager.INSTANCE.getGatewayServer().getProfileTextures(profile);
} }
if (!textures.containsKey(type)) { if (!textures.containsKey(type)) {

View file

@ -4,7 +4,6 @@ import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.util.Collections; import java.util.Collections;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -32,15 +31,14 @@ public abstract class AbstractSkinServer implements SkinServer {
} }
@Override @Override
public final Optional<MinecraftTexturesPayload> loadProfileData(GameProfile profile) { public Map<Type, MinecraftProfileTexture> getProfileTextures(GameProfile profile) {
return Optional.ofNullable(getProfileData(profile)); MinecraftTexturesPayload payload = getProfileData(profile);
if (payload != null && payload.getTextures() != null) {
return payload.getTextures();
} }
@Override return Collections.emptyMap();
public Map<Type, MinecraftProfileTexture> getPreviewTextures(GameProfile profile) {
return loadProfileData(profile)
.map(MinecraftTexturesPayload::getTextures)
.orElse(Collections.emptyMap());
} }
@Override @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<String, String> metadata) throws AuthenticationException, IOException; protected abstract SkinUploadResponse doUpload(Session session, URI image, Type type, Map<String, String> metadata) throws AuthenticationException, IOException;
@Override @Override

View file

@ -26,7 +26,7 @@ public class BethlehemSkinServer extends AbstractSkinServer {
} }
@Override @Override
protected MinecraftTexturesPayload getProfileData(GameProfile profile) { public MinecraftTexturesPayload getProfileData(GameProfile profile) {
try (NetClient client = new NetClient("GET", getPath(profile))) { try (NetClient client = new NetClient("GET", getPath(profile))) {
if (client.getResponseCode() == HttpStatus.SC_OK) { if (client.getResponseCode() == HttpStatus.SC_OK) {
return gson.fromJson(client.getResponseText(), MinecraftTexturesPayload.class); return gson.fromJson(client.getResponseText(), MinecraftTexturesPayload.class);

View file

@ -39,7 +39,7 @@ public class LegacySkinServer extends AbstractSkinServer {
} }
@Override @Override
public Map<Type, MinecraftProfileTexture> getPreviewTextures(GameProfile profile) { public Map<Type, MinecraftProfileTexture> getProfileTextures(GameProfile profile) {
Map<Type, MinecraftProfileTexture> map = new EnumMap<>(Type.class); Map<Type, MinecraftProfileTexture> map = new EnumMap<>(Type.class);
for (Type type : Type.values()) { for (Type type : Type.values()) {
@ -51,7 +51,7 @@ public class LegacySkinServer extends AbstractSkinServer {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
protected MinecraftTexturesPayload getProfileData(GameProfile profile) { public MinecraftTexturesPayload getProfileData(GameProfile profile) {
ImmutableMap.Builder<Type, MinecraftProfileTexture> builder = ImmutableMap.builder(); ImmutableMap.Builder<Type, MinecraftProfileTexture> builder = ImmutableMap.builder();
for (Type type : Type.values()) { for (Type type : Type.values()) {

View file

@ -18,7 +18,6 @@ import net.minecraft.util.Session;
import java.net.URI; import java.net.URI;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -34,9 +33,9 @@ public interface SkinServer extends Exposable {
"http://skins.voxelmodpack.com", "http://skins.voxelmodpack.com",
"http://skinmanager.voxelmodpack.com")); "http://skinmanager.voxelmodpack.com"));
Optional<MinecraftTexturesPayload> loadProfileData(GameProfile profile); MinecraftTexturesPayload getProfileData(GameProfile profile);
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> getPreviewTextures(GameProfile profile); Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> getProfileTextures(GameProfile profile);
CompletableFuture<SkinUploadResponse> uploadSkin(Session session, @Nullable URI image, MinecraftProfileTexture.Type type, Map<String, String> metadata); CompletableFuture<SkinUploadResponse> uploadSkin(Session session, @Nullable URI image, MinecraftProfileTexture.Type type, Map<String, String> metadata);

View file

@ -47,12 +47,13 @@ public class ValhallaSkinServer extends AbstractSkinServer {
} }
@Override @Override
protected MinecraftTexturesPayload getProfileData(GameProfile profile) { public MinecraftTexturesPayload getProfileData(GameProfile profile) {
try (CloseableHttpClient client = HttpClients.createSystem(); try (CloseableHttpClient client = HttpClients.createSystem()) {
CloseableHttpResponse response = client.execute(new HttpGet(getTexturesURI(profile)))) { try (CloseableHttpResponse response = client.execute(new HttpGet(getTexturesURI(profile)))) {
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
return readJson(response, MinecraftTexturesPayload.class); return readJson(response, MinecraftTexturesPayload.class);
} }
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();