package protocolsupportpocketstuff.skin;

import protocolsupport.api.unsafe.peskins.PESkinsProvider;
import protocolsupportpocketstuff.ProtocolSupportPocketStuff;
import protocolsupportpocketstuff.storage.Skins;

import javax.imageio.ImageIO;
import java.io.IOException;
import java.net.URL;
import java.util.UUID;
import java.util.function.Consumer;

public class PcToPeProvider extends PESkinsProvider {

	ProtocolSupportPocketStuff plugin;
	Skins skinCache = Skins.INSTANCE;
	
	public PcToPeProvider(ProtocolSupportPocketStuff plugin) {
		this.plugin = plugin;
	}
	
	@Override
	public byte[] getSkinData(String url) {
		if (skinCache.hasPeSkin(url)) {
			return skinCache.getPeSkin(url);
		}
		return null;
	}

	@Override
	public void scheduleGetSkinData(String url, UUID uuid, Consumer<byte[]> skindataApplyCallback) {
		plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> {
			try {
				if (skinCache.hasPeSkin(url)) {
					skindataApplyCallback.accept(skinCache.getPeSkin(url));
				} else {
					byte[] skin = toData(ImageIO.read(new URL(url)));
					skinCache.cachePeSkin(url, skin);
					skinCache.cacheUUIDUrl(uuid, url);
					skindataApplyCallback.accept(skin);
				}
			} catch (IOException e) { }
		});
		
	}

}

@@ -289,31 +289,8 @@
 RL;%0A
-import java.util.UUID;%0A
 impo
@@ -743,19 +743,8 @@
 url,
- UUID uuid,
  Con
@@ -1073,48 +1073,8 @@
 n);%0A
-%09%09%09%09%09skinCache.cacheUUIDUrl(uuid, url);%0A
 %09%09%09%09

Fix remaining compilation errors.