package com.mithrilclient.updater.hook;

import java.io.BufferedWriter;
import java.io.IOException;
import java.util.List;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldInsnNode;

import com.mithrilclient.updater.regex.Instruction;
import com.mithrilclient.updater.regex.Regex;

public final class SkillsHook extends Hook {
	public SkillsHook() {
		super(new Regex(
				new Instruction(Opcodes.GETSTATIC, true),
				new Instruction(Opcodes.ALOAD, false),
				new Instruction(Opcodes.ILOAD, false),
				new Instruction(Opcodes.IINC, false),
				new Instruction(Opcodes.IALOAD, false),
				new Instruction(Opcodes.IALOAD, false),
				new Instruction(Opcodes.ISTORE, false),
				new Instruction(Opcodes.ILOAD, false),
				new Instruction(Opcodes.ICONST_2, false),
				new Instruction(Opcodes.IF_ICMPNE, false),
				new Instruction(Opcodes.GETSTATIC, true),
				new Instruction(Opcodes.ALOAD, false),
				new Instruction(Opcodes.ILOAD, false),
				new Instruction(Opcodes.IINC, false),
				new Instruction(Opcodes.IALOAD, false),
				new Instruction(Opcodes.IALOAD, false),
				new Instruction(Opcodes.ISTORE, false),
				new Instruction(Opcodes.ILOAD, false),
				new Instruction(Opcodes.ICONST_3, false),
				new Instruction(Opcodes.IF_ICMPNE, false),
				new Instruction(Opcodes.GETSTATIC, true)
			));
	}

	@Override
	public void write(BufferedWriter writer, ClassNode clazz, List<AbstractInsnNode> match) throws IOException {
		writer.write("		xpLevelsHook = new FieldHook<>(classLoader, \"" + clazz.name + "\", \"" + ((FieldInsnNode) match.get(2)).name + "\");\n");
		writer.write("		levelsHook = new FieldHook<>(classLoader, \"" + clazz.name + "\", \"" + ((FieldInsnNode) match.get(0)).name + "\");\n");
		writer.write("		baseLevelsHook = new FieldHook<>(classLoader, \"" + clazz.name + "\", \"" + ((FieldInsnNode) match.get(1)).name + "\");\n");
		writer.write("\n");
		// TODO Auto-generated method stub
		/*regex.match(method).ifPresent((match) -> {*/
		/*System.out.println(clazz.name);
		System.out.println("levels -> " + ((FieldInsnNode) match.get(0)).name);
		System.out.println("base levels -> " + ((FieldInsnNode) match.get(1)).name);
		System.out.println("xp -> " + ((FieldInsnNode) match.get(2)).name);
		System.out.println();*/
	//});*/
	}
}

@@ -1981,388 +1981,8 @@
 %22);%0A
-%09%09// TODO Auto-generated method stub%0A%09%09/*regex.match(method).ifPresent((match) -%3E %7B*/%0A%09%09/*System.out.println(clazz.name);%0A%09%09System.out.println(%22levels -%3E %22 + ((FieldInsnNode) match.get(0)).name);%0A%09%09System.out.println(%22base levels -%3E %22 + ((FieldInsnNode) match.get(1)).name);%0A%09%09System.out.println(%22xp -%3E %22 + ((FieldInsnNode) match.get(2)).name);%0A%09%09System.out.println();*/%0A%09//%7D);*/%0A
 %09%7D%0A%7D

Remove comment.