package org.inventivetalent.npclib.npc.living.human;

import org.bukkit.entity.HumanEntity;
import org.inventivetalent.npclib.Reflection;
import org.inventivetalent.npclib.entity.living.human.NPCEntityHuman;
import org.inventivetalent.npclib.npc.living.NPCLivingAbstract;
import org.inventivetalent.npclib.skin.ISkinnableEntity;
import org.inventivetalent.npclib.skin.SkinLayer;
import org.inventivetalent.reflection.minecraft.DataWatcher;

public abstract class NPCHumanAbstract<N extends NPCEntityHuman, B extends HumanEntity> extends NPCLivingAbstract<N, B> implements ISkinnableEntity {

	public NPCHumanAbstract(N npcEntity) {
		super(npcEntity);
	}

	@Override
	public void setSkinLayers(SkinLayer... visibleLayers) {
		try {
			DataWatcher.setValue(Reflection.getDataWatcher(getBukkitEntity()), 10, DataWatcher.V1_9.ValueType.ENTITY_HUMAN_SKIN_LAYERS, (byte) SkinLayer.getValue(visibleLayers));
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
}

@@ -77,32 +77,79 @@
 ty.HumanEntity;%0A
+import org.inventivetalent.nbt.annotation.NBT;%0A
 import org.inven
@@ -770,181 +770,647 @@
 %7B%0A%09%09
-try %7B%0A%09%09%09DataWatcher.setValue(Reflection.getDataWatcher(getBukkitEntity()), 10, DataWatcher.V1_9.ValueType.ENTITY_HUMAN_SKIN_LAYERS, (byte) SkinLayer.getValue(visibleLayers)
+setSkinLayerFlag(SkinLayer.getValue(visibleLayers));%0A%09%7D%0A%0A%09@NBT(%7B%0A%09%09%09%09 %22npclib.options%22,%0A%09%09%09%09 %22human%22,%0A%09%09%09%09 %22skinLayers%22 %7D)%0A%09protected void setSkinLayerFlag(@NBT int flag) %7B%0A%09%09try %7B%0A%09%09%09DataWatcher.setValue(Reflection.getDataWatcher(getBukkitEntity()), 10, DataWatcher.V1_9.ValueType.ENTITY_HUMAN_SKIN_LAYERS, (byte) flag);%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09throw new RuntimeException(e);%0A%09%09%7D%0A%09%7D%0A%0A%09@NBT(%7B%0A%09%09%09%09 %22npclib.options%22,%0A%09%09%09%09 %22human%22,%0A%09%09%09%09 %22skinLayers%22 %7D)%0A%09protected int getSkinLayerFlag() %7B%0A%09%09try %7B%0A%09%09%09return (byte) DataWatcher.getValue(Reflection.getDataWatcher(getBukkitEntity()), 10, DataWatcher.V1_9.ValueType.ENTITY_HUMAN_SKIN_LAYERS
 );%0A%09
@@ -1475,10 +1475,11 @@
 %0A%09%09%7D%0A%09%7D%0A
+%0A
 %7D%0A

add NBT for skin layers