Launcher/LaunchServer/src/main/java/ru/gravit/launchserver/texture/NullTextureProvider.java

45 lines
1.3 KiB
Java
Raw Normal View History

2018-09-17 10:07:32 +03:00
package ru.gravit.launchserver.texture;
import java.io.IOException;
import java.util.Objects;
import java.util.UUID;
import ru.gravit.launcher.LauncherAPI;
import ru.gravit.launcher.helper.VerifyHelper;
import ru.gravit.launcher.profiles.Texture;
import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry;
public final class NullTextureProvider extends TextureProvider {
private volatile TextureProvider provider;
public NullTextureProvider(BlockConfigEntry block) {
super(block);
}
@Override
public void close() throws IOException {
TextureProvider provider = this.provider;
if (provider != null)
provider.close();
}
@Override
public Texture getCloakTexture(UUID uuid, String username, String client) throws IOException {
return getProvider().getCloakTexture(uuid, username, client);
}
private TextureProvider getProvider() {
return VerifyHelper.verify(provider, Objects::nonNull, "Backend texture provider wasn't set");
}
@Override
public Texture getSkinTexture(UUID uuid, String username, String client) throws IOException {
return getProvider().getSkinTexture(uuid, username, client);
}
@LauncherAPI
public void setBackend(TextureProvider provider) {
this.provider = provider;
}
}