Thumbs upABC Packets to XML Java Parser

Posts 1–13 of 13 · Page 1 of 1
ABC Packets to XML Java Parser
ABC Packets to XML Java Parser

Convert
trait const QName(PackageNamespace("", "#0"), "FAILURE") slotid 1 type QName(PackageNamespace("", "#0"), "int") value Integer(0) end
To
<Packet id="FAILURE" type="0"/>

from a text file named data.txt from your C drive.

Code:
package games.flappybird; //Le flappybird

import java****.BufferedReader;
import java****.FileReader; //MPGH block these out, but you know what they are anyway.
import java********Exception;

public class AVSMtoXML {

		public static String finalText = "";
		
	    public static void main(String[] agrs) throws IOException {

	    	BufferedReader in = new BufferedReader(new FileReader("C:/data.txt"));

	    	while (in.ready()) {
	    	  String s = in.readLine();
	    	  parse(s);
	    	}
	    	in.close();
	    	
	    	System.out.println("Final string is : "+finalText);

	    }
	
	    
	    
	public static void parse(String parse){
		
		

		/* References : */
		//Initial : trait const QName(PackageNamespace("", "#0"), "ACCEPTTRADE") slotid 58 type QName(PackageNamespace("", "#0"), "int") value Integer(76) end
		//Final : <Packet id="CREATE" type="33"/>
		
		

		/* GET THE NAME */
        int start_pos = (parse.indexOf("(\"\", \"#0\"), \"")+13);
        int	end_pos = parse.indexOf("\") slotid");
           
		String NAME = parse.substring(start_pos, end_pos);
            

			
        /* GET THE ID */
        start_pos = (parse.indexOf("value Integer(")+14);
        end_pos = parse.indexOf(") end");
           
		String ID = parse.substring(start_pos, end_pos);
            
			
			
        /* COMPILE IT TO XML */
		String FinalXML = "<Packet id=\""+NAME+"\" type=\""+ID+"\"/>";
         System.out.println("! PACKET XML is  "+FinalXML);
         
        finalText += FinalXML+" ";

	}
	
}


Here is a test file if you wish to test it :
Code:
 trait const QName(PackageNamespace("", "#0"), "FAILURE") slotid 1 type QName(PackageNamespace("", "#0"), "int") value Integer(0) end
 trait const QName(PackageNamespace("", "#0"), "CREATE_SUCCESS") slotid 2 type QName(PackageNamespace("", "#0"), "int") value Integer(15) end
 trait const QName(PackageNamespace("", "#0"), "CREATE") slotid 3 type QName(PackageNamespace("", "#0"), "int") value Integer(33) end
Version 2:

Code:
package parser;

/* Create a file on C:/ named data.txt and push this inside :


<Packet id="FAILURE" type="0"/>
<Packet id="CREATE_SUCCESS" type="81"/>
<Packet id="CREATE" type="38"/>
<Packet id="PLAYERSHOOT" type="41"/>
<Packet id="MOVE" type="58"/>
<Packet id="PLAYERTEXT" type="87"/>
<Packet id="TEXT" type="93"/>
<Packet id="SHOOT2" type="31"/>
<Packet id="DAMAGE" type="24"/>
<Packet id="UPDATE" type="21"/>


and take a look at the result



*/

import java ****. BufferedReader; //Remove the spaces jackass
import java ****. FileReader;
import java ****. IOException;

public class XMLtoHPP {

public static String finalText = "";

public static void main(String[] agrs) throws IOException {

BufferedReader in = new BufferedReader(new FileReader("C:/data.txt"));

while (in.ready()) {
String s = in.readLine();
parse(s);
}
in.close();

System.out.println("{ " + finalText + " }");

}

public static void parse(String parse) {

/* References : */
// Initial : <Packet id="CREATE_SUCCESS" type="81"/>
// Final : CREATE_SUCCESS = 81,

// System.out.println(parse);

if (parse.contains("<Packet id=\"")) {
// System.out.println("Countains");
} else {
System.err.println("Error.");
System.err.println("Try to remove the first and the last line of the XML.");
}

/* GET THE NAME */
int start_pos = (parse.indexOf("<Packet id=\"") + 12);
int end_pos = parse.indexOf("\" type=");

String NAME = parse.substring(start_pos, end_pos);

/* GET THE ID */
start_pos = (parse.indexOf("type=\"") + 7);
end_pos = parse.indexOf("\"/>");

String ID = parse.substring(start_pos, end_pos);

/* COMPILE IT TO XML */

String FinalXML = NAME + " = " + ID + ", ";
// System.out.println("! PACKET XML is "+FinalXML);

finalText += FinalXML + " ";

}

}
it isn't much work to update it by hand, but i guess that speeds it up a little bit. thanks!
Pretty good for my skrub alde.
<3
Nice, nice.
Good job!
Enumerate all the packet names or something similar, to convert obfuscated names to clear names, and you're set
Quote Originally Posted by Alde. View Post
package games.flappybird; //Le flappybird
Dafuq is this doin' there?
Quote Originally Posted by CrazyJani View Post

Dafuq is this doin' there?
2lazy2change
Quote Originally Posted by Alde. View Post
<Packet id="FAILURE" type="0"/>
What is type? I mean what does it do?
Quote Originally Posted by CrazyJani View Post

What is type? I mean what does it do?
RealmRelay uses packet.xml to get the packet ids and names.
The id is the name and the type is the ID.
Packets changes each build, so having to change the packets ids to make an updated proxy is long.
Quote Originally Posted by Alde. View Post
Packets changes each build, so having to change the packets ids to make an updated proxy is long.
Yeah I knew it. But I had no idea how to update them. I'd hire Cryogen for that job, haha
Update 4.20 : XMLtoHPP.java
May help. I'm sorry but this code is really dirty and stupidly made.
The 420 blazism may have been the cause of this disorder.

 
XMLtoHPP.
package parser;

/* Create a file on C:/ named data.txt and push this inside :


<Packet id="FAILURE" type="0"/>
<Packet id="CREATE_SUCCESS" type="81"/>
<Packet id="CREATE" type="38"/>
<Packet id="PLAYERSHOOT" type="41"/>
<Packet id="MOVE" type="58"/>
<Packet id="PLAYERTEXT" type="87"/>
<Packet id="TEXT" type="93"/>
<Packet id="SHOOT2" type="31"/>
<Packet id="DAMAGE" type="24"/>
<Packet id="UPDATE" type="21"/>


and take a look at the result



*/

import java ****. BufferedReader; //Remove the spaces jackass
import java ****. FileReader;
import java ****. IOException;

public class XMLtoHPP {

public static String finalText = "";

public static void main(String[] agrs) throws IOException {

BufferedReader in = new BufferedReader(new FileReader("C:/data.txt"));

while (in.ready()) {
String s = in.readLine();
parse(s);
}
in.close();

System.out.println("{ " + finalText + " }");

}

public static void parse(String parse) {

/* References : */
// Initial : <Packet id="CREATE_SUCCESS" type="81"/>
// Final : CREATE_SUCCESS = 81,

// System.out.println(parse);

if (parse.contains("<Packet id=\"")) {
// System.out.println("Countains");
} else {
System.err.println("Error.");
System.err.println("Try to remove the first and the last line of the XML.");
}

/* GET THE NAME */
int start_pos = (parse.indexOf("<Packet id=\"") + 12);
int end_pos = parse.indexOf("\" type=");

String NAME = parse.substring(start_pos, end_pos);

/* GET THE ID */
start_pos = (parse.indexOf("type=\"") + 7);
end_pos = parse.indexOf("\"/>");

String ID = parse.substring(start_pos, end_pos);

/* COMPILE IT TO XML */

String FinalXML = NAME + " = " + ID + ", ";
// System.out.println("! PACKET XML is "+FinalXML);

finalText += FinalXML + " ";

}

}
Posts 1–13 of 13 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

Need help?