put skin cache back in the skins folder and clear the internal cache when needed.

This commit is contained in:
Matthew Messinger 2016-12-27 01:57:58 -05:00
parent d5e766aaef
commit 50e29823d7

View file

@ -127,7 +127,7 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
String skinDir = type.toString().toLowerCase() + "s/"; String skinDir = type.toString().toLowerCase() + "s/";
final ResourceLocation skin = new ResourceLocation("hdskins", skinDir + texture.getHash()); final ResourceLocation skin = new ResourceLocation("hdskins", skinDir + texture.getHash());
File file2 = new File(LiteLoader.getAssetsDirectory(), "hd" + skinDir + "/" + texture.getHash().substring(0, 2) + "/" + texture.getHash()); File file2 = new File(LiteLoader.getAssetsDirectory(), "skins/" + skinDir + texture.getHash().substring(0, 2) + "/" + texture.getHash());
final IImageBuffer imagebufferdownload = type == Type.SKIN ? new ImageBufferDownloadHD() : null; final IImageBuffer imagebufferdownload = type == Type.SKIN ? new ImageBufferDownloadHD() : null;
ThreadDownloadImageData threaddownloadimagedata = new ThreadDownloadImageData(file2, texture.getUrl(), ThreadDownloadImageData threaddownloadimagedata = new ThreadDownloadImageData(file2, texture.getUrl(),
DefaultPlayerSkin.getDefaultSkinLegacy(), DefaultPlayerSkin.getDefaultSkinLegacy(),
@ -164,7 +164,7 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
} }
private Map<Type, MinecraftProfileTexture> loadProfileData(final GameProfile profile) { private Map<Type, MinecraftProfileTexture> loadProfileData(final GameProfile profile) {
return getProfileData(profile).orElseGet(() -> { return getProfileData(profile).orElseGet(() -> {
String uuid = UUIDTypeAdapter.fromUUID(profile.getId()); String uuid = UUIDTypeAdapter.fromUUID(profile.getId());
@ -176,9 +176,9 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
builder.put(type, new HDProfileTexture(url, hash, null)); builder.put(type, new HDProfileTexture(url, hash, null));
} }
Map<Type, MinecraftProfileTexture> textures = builder.build(); Map<Type, MinecraftProfileTexture> textures = builder.build();
this.profileTextures.put(profile.getId(), textures); this.profileTextures.put(profile.getId(), textures);
return textures; return textures;
}); });
} }
@ -252,6 +252,12 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
try { try {
FileUtils.deleteDirectory(new File(LiteLoader.getAssetsDirectory(), "skins")); FileUtils.deleteDirectory(new File(LiteLoader.getAssetsDirectory(), "skins"));
TextureManager textures = Minecraft.getMinecraft().getTextureManager();
INSTANCE.skinCache.values().stream()
.flatMap(m -> m.values().stream())
.forEach(textures::deleteTexture);
INSTANCE.skinCache.clear();
INSTANCE.profileTextures.clear();
} catch (IOException var1) { } catch (IOException var1) {
var1.printStackTrace(); var1.printStackTrace();
} }