clear cached skin records when refrshing account state

This commit is contained in:
huanghongxun 2018-02-18 18:35:05 +08:00
parent 2310f6e1c0
commit e5ccc40358
4 changed files with 16 additions and 0 deletions

View File

@ -150,6 +150,8 @@ public final class AccountHelper {
}
private static void downloadSkin(YggdrasilAccount account, GameProfile profile, boolean refresh, Proxy proxy) throws Exception {
account.clearCache();
if (profile == null) return;
String name = profile.getName();
if (name == null) return;

View File

@ -91,4 +91,6 @@ public abstract class Account {
public final Map<Object, Object> getProperties() {
return properties;
}
public abstract void clearCache();
}

View File

@ -93,6 +93,11 @@ public class OfflineAccount extends Account {
);
}
@Override
public void clearCache() {
// Nothing to clear.
}
@Override
public String toString() {
return "OfflineAccount[username=" + username + ", uuid=" + uuid + "]";

View File

@ -319,6 +319,13 @@ public class YggdrasilAccount extends Account {
return Optional.ofNullable(texture.getTextures().get(ProfileTexture.Type.SKIN));
}
@Override
public void clearCache() {
Optional.ofNullable(getSelectedProfile())
.map(GameProfile::getProperties)
.ifPresent(it -> it.remove("texture"));
}
@Override
public String toString() {
return "YggdrasilAccount[username=" + getUsername() + "]";