Haha, this was my ‘improved’ version of the updater, it was actually much cleaner than the original, if you can believe it. It almost makes me want to puke looking at this:
import java.io.*;
import java.util.regex.*;
public class ClientUpdater
{
public static String fileprefix = "output/";
public static String[] clientline = new String[20000];
private static String getRegexString(String regex,String searchstring){
String[] result = searchstring.split(regex);
if(result.length==2)
return (searchstring.substring(result[0].length(),searchstring.length()-result[1].length()));
else
return (searchstring.substring(result[0].length()));
}
private static void renamePrivVar(String regex, String newName){
for (int x=0;x<clientline.length&&clientline[x]!=null; x++)
clientline[x] = clientline[x].replaceAll(regex,newName);
}
private static void renamePrivVar(String[] regex, String[] newName){
if(regex.length!=newName.length)
return;
for (int x=0;x<clientline.length&&clientline[x]!=null; x++)
for(int i = 0; i < regex.length;i++)
clientline[x] = clientline[x].replaceAll(regex[i],newName[i]);
}
public static void renameClassVar(String className, String regex, String newName){
try{
File file2 = new File(fileprefix+className);
FileInputStream fi = new FileInputStream(file2);
byte[] bytes = new byte[(int) file2.length()];
fi.read(bytes);
fi.close();
String content = new String(bytes);
content = content.replaceAll(regex, newName);
FileOutputStream fos = new FileOutputStream(file2);
fos.write(content.getBytes());
fos.close();
}
catch(Exception e){
e.printStackTrace();
}
}
public static void renameClassVar(String className, String[] regex, String[] newName){
try{
File file2 = new File(fileprefix+className);
FileInputStream fi = new FileInputStream(file2);
byte[] bytes = new byte[(int) file2.length()];
fi.read(bytes);
fi.close();
String content = new String(bytes);
for(int i = 0; i < regex.length;i++)
content = content.replaceAll(regex[i], newName[i]);
FileOutputStream fos = new FileOutputStream(file2);
fos.write(content.getBytes());
fos.close();
}
catch(Exception e){
e.printStackTrace();
}
}
public static void renamePubVar(String regex, String newName){
renamePrivVar(regex, newName);
File index = new File("./"+fileprefix);
String[] filet = index.list();
for(int i = 0; i < filet.length;i++)
if(filet[i].trim().endsWith(".java") && (((filet[i].trim().indexOf("Class")>-1)||(filet[i].trim().indexOf("Sub")>-1))))
renameClassVar(filet[i], regex, newName);
}
public static void renamePubVar(String[] regex, String[] newName){
if(regex.length!=newName.length)
return;
renamePrivVar(regex, newName);
File index = new File("./"+fileprefix);
String[] filet = index.list();
for(int i = 0; i < filet.length;i++)
if(filet[i].trim().endsWith(".java") && (((filet[i].trim().indexOf("Class")>-1)||(filet[i].trim().indexOf("Sub")>-1))))
renameClassVar(filet[i], regex, newName);
}
public static void declareMethod(String nameParams){
for (int x=0;x<clientline.length&&clientline[x]!=null; x++)
if ((clientline[x].indexOf("public client()")>-1))
clientline[x] = "public "+nameParams+"{ }\n"+clientline[x];
}
public static void main(String[] args)
{
String writetoscreen = "";
try
{
File file = new File(fileprefix+"client.java");
FileInputStream fistream = new FileInputStream(file);
BufferedReader reader = new BufferedReader(new InputStreamReader(fistream));
int linenumber = 0;
while ((clientline[linenumber] = reader.readLine()) != null)
linenumber++;
fistream.close();
for (int x=0;x<clientline.length&&clientline[x]!=null; x++)
if (clientline[x].indexOf("mapdots")>-1){
// System.out.println(clientline[x]);
String[] classnames = clientline[x].trim().split("\\s");
// System.out.println(classnames[0]);
int aclassnum = Integer.parseInt(getRegexString("_\\d{1,4}",classnames[0]).substring(1));
String aclassname = classnames[0].substring(0,classnames[0].indexOf("_"+aclassnum)+1);
String[] dotNames = {"itemDot", "npcDot", "playerDot", "friendDot", "unknownDot"};
for (int t=0;t<5; t++)
renamePrivVar(aclassname+(aclassnum+t), dotNames[t]);
declareMethod("void ChangeColors()");
declareMethod("void ChangeBack()");
declareMethod("void updateColors()");
declareMethod("void updatePlayers(int otherPlyrLvl)");
aclassname = "dot";
aclassnum = 0;
String intarraystring = "";
String wildyposclass = "";
// System.out.println(aclassnum);
// System.out.println(aclassname);
// System.out.println(getRegexString("_\\d{1,4}",classnames[0]).substring(1));
// System.out.println(classnames[3].substring(0,classnames[3].indexOf("(")));
try{
File pkclass = new File(fileprefix+classnames[3].substring(0,classnames[3].indexOf("("))+".java");
FileInputStream fistreampkclass = new FileInputStream(pkclass);
BufferedReader pkreader = new BufferedReader(new InputStreamReader(fistreampkclass));
String tempstring = "";
while ((tempstring = pkreader.readLine()) != null){
if ((tempstring.indexOf("public int anIntArray")>-1)){
String[] result = tempstring.trim().split("\\s");
intarraystring = result[2].substring(0,result[2].indexOf("["));
renamePubVar(intarraystring, "mapDotArray");
intarraystring = "mapDotArray";
// System.out.println(intarraystring);
}
}
} catch(IOException e) { e.printStackTrace(); }
for (int i=0;i<clientline.length&&clientline[i]!=null; i++)
if ((clientline[i].indexOf(" (level-")>-1)&&(clientline[i].indexOf("aString")==-1)){
wildyposclass = getRegexString("aClass.{1,40}anInt\\d{1,4}",clientline[i]);
// System.out.println(wildyposclass.substring(0,wildyposclass.indexOf(".anInt")));
// System.out.println(wildyposclass.substring(wildyposclass.indexOf("anInt"),wildyposclass.length()));
// System.out.println(wildyposclass.substring(1).toLowerCase().replaceAll("_\\d{1,4}\\.anint\\d{1,4}",""));
renamePubVar(wildyposclass.substring(0,wildyposclass.indexOf(".anInt")),"myPlayer");
renamePrivVar(wildyposclass.substring(1).toLowerCase().replaceAll("_\\d{1,4}\\.anint\\d{1,4}",""),"otherPlayer");
renamePubVar(wildyposclass.substring(wildyposclass.indexOf("anInt"),wildyposclass.length()),"cmbtLvl");
i = clientline.length;
}
for (int z=0;z<clientline.length&&clientline[z]!=null; z++)
if (clientline[z].indexOf("* 4 + 2) -")>-1){
for (int a=z;a>0;a--)
if (clientline[a].indexOf("public void method")>-1){
clientline[a+1] = clientline[a+1]+"\n updateColors();";
a = 0;
}
for (int a=z;a<clientline.length&&clientline[a]!=null; a++)
if(clientline[a].indexOf("otherPlayer")>-1){
clientline[a]=clientline[a]+"\n updatePlayers(otherPlayer.cmbtLvl);";
a = clientline.length;
}
z = clientline.length;
}
x = clientline.length;
}
for (int x=0;x<clientline.length&&clientline[x]!=null; x++)
if (clientline[x].indexOf("\"%5\"")>-1){
clientline[x+4] = clientline[x+4]+"\n if(s.startsWith(\"Level:\"))\n"+
" wildypos = Integer.parseInt(s.substring(7));\n";
x = clientline.length;
}
for (int x=0;x<clientline.length&&clientline[x]!=null; x++)
if(clientline[x].indexOf("getParameter(\"nodeid\")")>-1)
{
String[] result = clientline[x].trim().split("\\s");
renamePrivVar(result[0],"nodeId");
}
for (int x=0;x<clientline.length&&clientline[x]!=null; x++)
if(clientline[x].indexOf("public Socket method")>-1)
{
// String[] result = clientline[x].trim().split("\\s");
// String methodname = result[2].substring(0,result[2].indexOf("int")-1);
// renamePrivVar(methodname,"socketMethod");
clientline[x+3] = "//"+clientline[x+3];
clientline[x+4] = "//"+clientline[x+4];
clientline[x+5] = "//"+clientline[x+5];
}
Pattern pattern3 = Pattern.compile("if\\(super\\.anInt\\d{1,4} == 1 && super\\.anInt\\d{1,4} >= \\w{1,2} - 15 && super\\.anInt\\d{1,4} < \\w\\d?\\)");
for (int x=0;x<clientline.length&&clientline[x]!=null; x++){//adds world switcher
Matcher match2 = pattern3.matcher(clientline[x]);
if(match2.find()){
clientline[x+5] = clientline[x+5]+"\n"+clientline[x]+"\n"+clientline[x+1].replace("0;","2;")+"\n"+clientline[x+2];
String[] result = clientline[x+1].trim().split("\\s");
for (int i=0;i<clientline.length&&clientline[i]!=null; i++)
if(clientline[i].indexOf("if("+result[0]+" == 1)")>-1){
String[] password = clientline[i+3].trim().split("\\s");
clientline[i+10] = clientline[i+10]+"else\nif("+result[0]+" == 2)\n";
for (int z=1;z<10;z++)
clientline[i+10] = ((clientline[i+10]+clientline[i+z]+"\n").replaceAll(password[0],"worldnum")).replaceAll("20\\)","3)");
clientline[i+10] = clientline[i+10]+"}";
clientline[i+5] = clientline[i+5].replace("0;","2;");
i = clientline.length;
for (int y=0;y<clientline.length&&clientline[y]!=null; y++)
if(clientline[y].indexOf("Username: ")>-1){
clientline[y+3] = clientline[y+3]+"\n"+
clientline[y].replaceAll("aString\\d{1,4}","worldnum").replaceAll("Username","World #").replaceAll("== 0\\)","== 2\\)")+
"\n"+clientline[y+3];
y = clientline.length;
}
}
x = clientline.length;
}
}
for (int x=0;x<clientline.length&&clientline[x]!=null; x++)//adds maplock
if ((clientline[x].indexOf("/ 2 & 0x7ff;")>-1))
{
String[] result = clientline[x].trim().split("\\s");
int firstvariable = Integer.parseInt(result[0].replace("anInt",""));
clientline[x] = "if(maplock){\n"+
" anInt"+firstvariable+" = mapface;\n"+
" anInt"+(firstvariable-1)+" = 383;\n"+
" }else{\n"+clientline[x];
clientline[x+1] = clientline[x+1]+"\n}";
}
try{
Pattern pattern = Pattern.compile("int \\w{1,2} = 2048 - \\w{1,2} & 0x7ff;"); //adds zoom and camera movement
for (int x=0;x<clientline.length&&clientline[x]!=null; x++){
Matcher match = pattern.matcher(clientline[x]);
if (match.find())
{
String[] zoomvars = new String[3];
String[] result = clientline[x+2].trim().split("\\s");
zoomvars[0]=result[1];
result = clientline[x+3].trim().split("\\s");
zoomvars[1]=result[1];
result = clientline[x+4].trim().split("\\s");
zoomvars[2]=result[1];
//insertzoomcrap
clientline[x+14] = clientline[x+14]+"if(cameratoggle){\n"+
" if(lftrit == 0)\n"+
" lftrit = "+zoomvars[0]+";\n"+
" if(zoom == 0)\n"+
" zoom = "+zoomvars[1]+";\n"+
" if(fwdbwd == 0)\n"+
" fwdbwd = "+zoomvars[2]+";\n"+
" "+zoomvars[0]+" = lftrit;\n"+
" "+zoomvars[1]+" = zoom;\n"+
" "+zoomvars[2]+" = fwdbwd;\n"+
"}";
x = clientline.length;
}
}
} catch(Exception e) { e.printStackTrace(); }
// 0x3f008edd disables frame check
for (int x=0;x<clientline.length&&clientline[x]!=null; x++) //fixes hp over heads
if ((clientline[x].indexOf("* 30) /")>-1))
{
int anintnumber = 0;
String currenthp = clientline[x].substring(clientline[x].indexOf("=")+1,clientline[x].indexOf("*")).trim()+")";
String totalhp = clientline[x].substring(clientline[x].indexOf("/")+1,clientline[x].indexOf(";")).trim();
Pattern pattern2 = Pattern.compile("anInt\\d+ - 3");
Matcher match2 = pattern2.matcher(clientline[x+3]);
if (match2.find()){
String tempstring =(clientline[x+3].substring(match2.start(),match2.end()));
anintnumber = Integer.parseInt(tempstring.substring(tempstring.indexOf("anInt")+5,tempstring.indexOf(" - 3")));
}
for (int i=0;i<clientline.length&&clientline[i]!=null; i++){
if ((clientline[i].indexOf("Welcome to RuneScape")>-1))
{
Pattern xcoord = Pattern.compile("[a-z] / 2");
Pattern ycoord1 = Pattern.compile(", [a-z],");
Pattern ycoord2 = Pattern.compile(", [a-z]\\)");
Pattern ycoord3 = Pattern.compile("\\([a-z],");
Matcher ymatch1 = ycoord1.matcher(clientline[i]);
Matcher ymatch2 = ycoord2.matcher(clientline[i]);
Matcher ymatch3 = ycoord3.matcher(clientline[i]);
String[] aroundx = xcoord.split(clientline[i]);
writetoscreen = aroundx[0]+"anInt"+(anintnumber-1)+aroundx[1];
if (ymatch1.find()){
aroundx = ycoord1.split(writetoscreen);
writetoscreen = aroundx[0]+", "+"anInt"+anintnumber+"-9, "+aroundx[1];
}
if (ymatch2.find()){
aroundx = ycoord2.split(writetoscreen);
writetoscreen = aroundx[0]+", "+"anInt"+anintnumber+"-9)"+aroundx[1];
}
if (ymatch3.find()){
aroundx = ycoord3.split(writetoscreen);
writetoscreen = aroundx[0]+"("+"anInt"+anintnumber+"-9, "+aroundx[1];
}
writetoscreen = writetoscreen.replace("\"Welcome to RuneScape\"",currenthp+"+\"/\"+"+totalhp);
writetoscreen = writetoscreen.replace("0xffff00","0xFF0000");
}
}
clientline[x] = "if(showhp)\n"+writetoscreen+"\n"+clientline[x];
x = clientline.length;
}
for (int x=0;x<clientline.length&&clientline[x]!=null; x++){//changes names
if ((clientline[x].indexOf("Welcome to RuneScape")>-1))
clientline[x]= clientline[x].replace("RuneScape","MoparScape");
if ((clientline[x].indexOf("New User")>-1))
clientline[x]= clientline[x].replace("New User","Info");
if ((clientline[x].indexOf("Existing User")>-1)){
clientline[x]= clientline[x].replace("Existing User","Play");
clientline[x]= clientline[x].replace("0xffffff","0xFF0000");
}
if ((clientline[x].indexOf("Login")>-1)){
clientline[x]= clientline[x].replace("Login","Enter");
clientline[x]= clientline[x].replace("0xffffff","0xFF0000");
}
if ((clientline[x].indexOf("Cancel")>-1))
clientline[x]= clientline[x].replace("Cancel","Quit");
if ((clientline[x].indexOf("Create a free account")>-1))
clientline[x]= clientline[x].replace("Create a free account","This is MoparScape");
if ((clientline[x].indexOf("To create a new account you need to")>-1))
clientline[x]= clientline[x].replace("To create a new account you need to","For help, more info, suggestions,");
if ((clientline[x].indexOf("go back to the main RuneScape webpage")>-1))
clientline[x]= clientline[x].replace("go back to the main RuneScape webpage","or new versions, visit www.moparisthebest.com");
if ((clientline[x].indexOf("and choose the 'create account'")>-1))
clientline[x]= clientline[x].replace("and choose the 'create account'","and my thread ask anything you want");
if ((clientline[x].indexOf("button near the top of that page.")>-1))
clientline[x]= clientline[x].replace("button near the top of that page.","Have Fun. ~Moparisthebest");
if ((clientline[x].indexOf("RuneScape is loading - please wait...")>-1))
clientline[x]= clientline[x].replace("RuneScape is loading - please wait...","MoparScape is loading - Hold onto your Butts...");
clientline[x] = clientline[x].replaceAll("if\\(aBoolean\\d{1,4} \\|\\| aBoolean\\d{1,4} \\|\\| aBoolean\\d{1,4}\\)","if\\(false\\)");
if(clientline[x].indexOf("/ 2 - 128")>-1)//removes logo
clientline[x] = "//"+clientline[x];
if(clientline[x].indexOf("extends Applet_Sub1")>-1)//adds variables
clientline[x+1] = clientline[x+1]+"public static boolean showhp,cameratoggle,maplock;\n"+
"public static int zoom,lftrit,fwdbwd,mapface,wildypos;\n";
if ((clientline[x].indexOf("jagex.com")>-1))
clientline[x] = "flag = true;\n"+clientline[x];
if ((clientline[x].indexOf("public client()")>-1))
clientline[x] = "public static String worldnum = \"10\";\n"+clientline[x];
}
FileOutputStream fos = new FileOutputStream(file);
for (int x=0;x<clientline.length&&clientline[x]!=null; x++)
fos.write((clientline[x]+"\n").getBytes());
fos.close();
} catch(IOException e) { e.printStackTrace(); }
}
}