Skip to content

Instantly share code, notes, and snippets.

@tterrag1098
Forked from mattmess1221/SkinResources.java
Last active August 27, 2016 08:15
private final Map<ResourceLocation, Future<ResourceLocation>> inprogress = Maps.newHashMap();
@Nullable
public ResourceLocation getPlayerTexture(GameProfile profile, Type type) {
if (type != Type.SKIN)
// not supported
return null;
Skin skin = getSkin(profile);
if (skin != null) {
ResourceLocation res = skin.getTexture();
if (res != null) {
ListenableFuture<ResourceLocation> conv = this.inprogress.get(res);
if (conv == null) {
// read and convert in a new thread
conv = executor.submit(new ImageLoader(res));
conv.addListener(() -> converted.put(res, conv.get()));
this.inprogress.put(res, conv);
}
}
return converted.get(res);
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment