/SkinResources.java Secret
Last active
August 27, 2016 08:15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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