Move cache busting to legacy server itself

This commit is contained in:
Sollace 2018-08-23 01:26:50 +02:00
parent ee00330c83
commit 68fcde4c2c
4 changed files with 6 additions and 11 deletions

View file

@ -46,7 +46,6 @@ import java.lang.reflect.Modifier;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@ -161,10 +160,6 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
return skin == LOADING ? Optional.empty() : Optional.of(skin);
}
public static String bustCache(String url) {
return url + (url.indexOf('?') > -1 ? '&' : '?') + Long.toString(new Date().getTime() / 1000);
}
private void loadTexture(GameProfile profile, final Type type, final SkinAvailableCallback callback) {
if (profile.getId() == null) {
return;
@ -182,7 +177,7 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
// schedule texture loading on the main thread.
TextureLoader.loadTexture(resource, new ThreadDownloadImageETag(
new File(LiteLoader.getAssetsDirectory(), "hd/" + skinDir + texture.getHash().substring(0, 2) + "/" + texture.getHash()),
bustCache(texture.getUrl()),
texture.getUrl(),
DefaultPlayerSkin.getDefaultSkinLegacy(),
buffs));
}

View file

@ -29,14 +29,13 @@ public class PreviewTextureManager {
}
MinecraftProfileTexture texture = textures.get(type);
String url = HDSkinManager.bustCache(texture.getUrl());
ISkinAvailableCallback buff = new ImageBufferDownloadHD(type, () -> {
if (callback != null) {
callback.skinAvailable(type, location, new MinecraftProfileTexture(url, Maps.newHashMap()));
callback.skinAvailable(type, location, new MinecraftProfileTexture(texture.getUrl(), Maps.newHashMap()));
}
});
PreviewTexture skinTexture = new PreviewTexture(texture.getMetadata("model"), url, def, buff);
PreviewTexture skinTexture = new PreviewTexture(texture.getMetadata("model"), texture.getUrl(), def, buff);
TextureLoader.loadTexture(location, skinTexture);

View file

@ -192,7 +192,7 @@ public class SkinUploader implements Closeable {
}
public CompletableFuture<MoreHttpResponses> downloadSkin() {
String loc = HDSkinManager.bustCache(remotePlayer.getLocal(skinType).getRemote().getUrl());
String loc = remotePlayer.getLocal(skinType).getRemote().getUrl();
return new NetClient("GET", loc).async(HDSkinManager.skinDownloadExecutor);
}

View file

@ -18,6 +18,7 @@ import org.apache.logging.log4j.Logger;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Date;
import java.util.EnumMap;
import java.util.Locale;
import java.util.Map;
@ -141,7 +142,7 @@ public class LegacySkinServer implements SkinServer {
private static String getPath(String address, MinecraftProfileTexture.Type type, GameProfile profile) {
String uuid = UUIDTypeAdapter.fromUUID(profile.getId());
String path = type.toString().toLowerCase() + "s";
return String.format("%s/%s/%s.png", address, path, uuid);
return String.format("%s/%s/%s.png?%s", address, path, uuid, Long.toString(new Date().getTime() / 1000));
}
@Override