Package smart.updater.searches

Source Code of smart.updater.searches.NPCLevel

package smart.updater.searches;

import java.util.HashMap;
import java.util.Map.Entry;

import org.apache.bcel.classfile.*;
import org.apache.bcel.generic.*;

import smart.updater.InstructionSearcher2;
import smart.updater.RSClass;
import smart.updater.RSClient;
import smart.updater.Search;

public class NPCLevel extends Search{

  @Override
  public SearchResult run(RSClient data, HashMap<String, ClassGen> classes) {
    RSClass npcDef = data.getProperClass("NPCDef");
    for(Entry<String, ClassGen> c : classes.entrySet()){
      if(c.getValue().getClassName().equals(npcDef.className)){
        ClassGen cg = new ClassGen(c.getValue().getJavaClass());
        ConstantPoolGen cpg = c.getValue().getConstantPool();
        for(Method m : c.getValue().getMethods()){
          if(m.getReturnType().equals(Type.VOID)){
            InstructionSearcher2 search = new InstructionSearcher2(cg, m);
            while(search.nextBIPUSH() != null) {
              Instruction i = search.current();
              if(((BIPUSH)i).getValue().intValue() == -98 || ((BIPUSH)i).getValue().intValue() == 97){
                FieldInstruction npcLevel = search.previousFieldInstruction();
                npcDef.addField("GetLevel", npcLevel.getFieldName(cpg));
                return SearchResult.Success;
              }
            }
          }
        }
      }
    }
    return SearchResult.Failure;
  }

}
TOP

Related Classes of smart.updater.searches.NPCLevel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.