import smart.updater.Search.SearchResult;
public class Animation extends Search{
public SearchResult run(RSClient data, HashMap<String, ClassGen> classes) {
RSClass player = data.getProperClass("Player");
RSClass character = data.getProperClass("Character");
for (Entry<String, ClassGen> c : classes.entrySet()) {
for (Method m : c.getValue().getMethods()) {
ClassGen cg = new ClassGen(c.getValue().getJavaClass());
ConstantPoolGen cpg = c.getValue().getConstantPool();
MethodGen gen = new MethodGen(m, c.getValue().getClassName(), cpg);
MethodSearcher mS = new MethodSearcher(m, cg, cpg);
if(m.isFinal() && m.isStatic() && m.getReturnType().equals(Type.VOID) &&
mS.getArgCount() == 4 && mS.getTypeCount(player.className) == 1){
InstructionList il = gen.getInstructionList();
if (il == null) {
continue;
}
InstructionSearcher2 iS = new InstructionSearcher2(cg, m);
while(iS.nextFieldInstruction() != null){
FieldInstruction fi = (FieldInstruction)iS.current();
if(fi.getClassName(cpg).equals(character.className)){
String anim = fi.getFieldName(cpg);
character.addField("Animation", anim);
int count = 0;
while(iS.nextFieldInstruction() != null){
fi = (FieldInstruction)iS.current();
if((fi instanceof GETFIELD) && (fi.getClassName(cpg)+'.'+fi.getFieldName(cpg)).equals(character.className+'.'+anim)){
count++;
if(count==2){
while(iS.nextGETFIELD() != null){
GETFIELD gf = ((GETFIELD)iS.current());
if(gf.getClassName(cpg).equals(character.className)){
character.addField("Motion", gf.getFieldName(cpg));
return SearchResult.Success;
}
}
}
}