Cache bust misbehaving servers

This commit is contained in:
Sollace 2018-06-06 21:05:38 +02:00
parent eba8589963
commit b5d8492b31

View file

@ -38,6 +38,7 @@ import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Collections; import java.util.Collections;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
@ -127,6 +128,10 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
return skin == LOADING ? Optional.empty() : Optional.of(skin); return skin == LOADING ? Optional.empty() : Optional.of(skin);
} }
private String bustCache(String url) {
return (url.indexOf('?') > -1 ? '&' : '?') + Long.toString(new Date().getTime()/1000);
}
private void loadTexture(GameProfile profile, final Type type, final SkinAvailableCallback callback) { private void loadTexture(GameProfile profile, final Type type, final SkinAvailableCallback callback) {
if (profile.getId() != null) { if (profile.getId() != null) {
Map<Type, MinecraftProfileTexture> data = getProfileData(profile); Map<Type, MinecraftProfileTexture> data = getProfileData(profile);
@ -138,7 +143,7 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
final IImageBuffer imagebufferdownload = type == Type.SKIN ? new ImageBufferDownloadHD() : null; final IImageBuffer imagebufferdownload = type == Type.SKIN ? new ImageBufferDownloadHD() : null;
ITextureObject texObject = new ThreadDownloadImageETag(file2, texture.getUrl(), ITextureObject texObject = new ThreadDownloadImageETag(file2, bustCache(texture.getUrl()),
DefaultPlayerSkin.getDefaultSkinLegacy(), DefaultPlayerSkin.getDefaultSkinLegacy(),
new IImageBuffer() { new IImageBuffer() {
@Nonnull @Nonnull