Thread: Need help with dumper

Results 1 to 5 of 5
  1. #1 Need help with dumper 
    Registered Member
    Join Date
    Jan 2017
    Posts
    196
    Thanks given
    15
    Thanks received
    22
    Rep Power
    11
    Hey I would like to write only the actions[1] and not all of them and I don't know how to go about it

    Code:
            boolean NpcDefinitionsDUMPER = true;
            if (NpcDefinitionsDUMPER) {
            File f = new File("NpcDefinitions.xml");
            System.out.println("Dumping NpcDefinitions..");
            try {
                f.createNewFile();
                BufferedWriter bf = new BufferedWriter(new FileWriter(f));
                bf.write("<list>");
                bf.newLine();
                for (int index = 0; index < totalNPCs; index++) {
                    EntityDef def = forID(index);
                    String attackable = Arrays.toString(def.actions);
                        bf.write("    <NpcDefinition>");
                        bf.newLine();
                        bf.write("        <attackable>"+attackable+"<attackable>");
                        bf.newLine();
                        bf.write("    </NpcDefinition>");
                        bf.newLine();
                    }
                bf.write("</list>");
                bf.newLine();
                    bf.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                System.out.println("Dumping Complete!");
            }
    Code:
    public String actions[];
    Here is the way it currently write them

    Code:
    [null, Attack, null, null, null]
    I would also like if it find "null" to write false, else if it find "Attack" to write true

    This
    Code:
    <attackable>true</attackable>
    Instead of this
    Code:
    <attackable>[null, Attack, null, null, null]<attackable>
    Any help is appreciated, thanks!
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Jan 2017
    Posts
    196
    Thanks given
    15
    Thanks received
    22
    Rep Power
    11
    Bump
    Reply With Quote  
     

  3. #3  
    Donator

    Join Date
    Feb 2017
    Posts
    16
    Thanks given
    4
    Thanks received
    7
    Rep Power
    13
    Not too sure if this will help you, but you could use https://www.rune-server.ee/runescape...64-openrs.html, just put it in eclipse, it will have errors but it will still work, then in source.net.openrs.cache.tools *CREDIT TO WHOEVER MADE THIS CODE, IT WAS NOT ME I CANT REMEMBER WHO IT WAS THOUGH* make a new java file called 'NpcDefDumper and add this in there
    Code:
    package net.openrs.cache.tools;
    
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileReader;
    import java.io.IOException;
    import java.nio.charset.Charset;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.transform.OutputKeys;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    
    public class NpcDefDumper {
    	
    	public static final String EXPORT = "C:/Users/XXXXX/Desktop/export/NpcDefinitions.xml"; //location you want to export xml file
    	
    	public static final String LISTFILE = "C:/Users/XXXXX/Desktop/ccache/repository/types/npcs.txt";  //location of your npcs.txt
    	
    	static String readFile(String path, Charset encoding) 
    	  throws IOException 
    	{
    	  byte[] encoded = Files.readAllBytes(Paths.get(path));
    	  return new String(encoded, encoding);
    	}
    	
    	static void addAttr(Document doc, Element el, String key, String value) {
    		Element attr = doc.createElement(key);
    		attr.appendChild(doc.createTextNode(value));
    		el.appendChild(attr);
    	}
    
    	public static void main(String[] args) throws Exception {
    		
    		DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
    		DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
    
    		Document doc = docBuilder.newDocument();
    		Element defList = doc.createElement("list");
    		doc.appendChild(defList);
    
    		int id = -1;
    		String name = "null";
    		int walkAnimation = 65535;
    		int standAnimation = 65535;
    		int turn180Animation = 65535;
    		int turn90CWAnimation = 65535;
    		int turn90CCWAnimation = 65535;
    		int level = -1;
    		int size = 1;
    		boolean attackable = false;
    		
    		try (BufferedReader br = new BufferedReader(new FileReader(LISTFILE))) {
    		    String line;
    		    while ((line = br.readLine()) != null) {
    			    if(line.startsWith("case ")) {
    			    	if(id != -1) {
    			    		Element el = doc.createElement("NpcDefinition");
    			    		defList.appendChild(el);			    		
    			    		addAttr(doc, el, "id", Integer.toString(id));
    			    		addAttr(doc, el, "name", name);
    			    		addAttr(doc, el, "walkAnimation", Integer.toString(walkAnimation));
    			    		addAttr(doc, el, "standAnimation", Integer.toString(standAnimation));
    			    		addAttr(doc, el, "turn180Animation", Integer.toString(turn180Animation));
    			    		addAttr(doc, el, "turn90CWAnimation", Integer.toString(turn90CWAnimation));
    			    		addAttr(doc, el, "turn90CCWAnimation", Integer.toString(turn90CCWAnimation));
    			    		addAttr(doc, el, "level", Integer.toString(level));
    			    		addAttr(doc, el, "size", Integer.toString(size));
    			    		addAttr(doc, el, "attackable", Boolean.toString(attackable));
    			    	}
    			    	name = "null";
    					walkAnimation = 65535;
    					standAnimation = 65535;
    					turn180Animation = 65535;
    					turn90CWAnimation = 65535;
    					turn90CCWAnimation = 65535;
    					level = -1;
    					size = 1;
    					attackable = false;
    					line = line.replace("case ", "");
    			    	line = line.replace(":", "");
    			    	id = Integer.parseInt(line);
    			    } else if(line.contains("type.name")) {
    			    	line = line.replace("type.name = \"", "");
    			    	line = line.replace("\";", "");
    			    	if(line.contains("<col"))
    			    		line = line.substring(13, line.length() - 6);
    			    	name = line.trim();	
    			    } else if(line.contains("type.stanceAnimation")) {
    			    	line = line.replace("type.stanceAnimation = ", "");
    			    	line = line.replace(";", "");
    			    	standAnimation = Integer.parseInt(line.trim());	
    			    } else if(line.contains("type.walkAnimation")) {
    			    	line = line.replace("type.walkAnimation = ", "");
    			    	line = line.replace(";", "");
    			    	walkAnimation = Integer.parseInt(line.trim());	
    			    } else if(line.contains("type.rotate180Animation")) {
    			    	line = line.replace("type.rotate180Animation = ", "");
    			    	line = line.replace(";", "");
    			    	turn180Animation = Integer.parseInt(line.trim());	
    			    } else if(line.contains("type.rotate90LeftAnimation")) {
    			    	line = line.replace("type.rotate90LeftAnimation = ", "");
    			    	line = line.replace(";", "");
    			    	turn90CWAnimation = Integer.parseInt(line.trim());	
    			    } else if(line.contains("type.rotate90RightAnimation")) {
    			    	line = line.replace("type.rotate90RightAnimation = ", "");
    			    	line = line.replace(";", "");
    			    	turn90CCWAnimation = Integer.parseInt(line.trim());	
    			    } else if(line.contains("type.combatLevel")) {
    			    	line = line.replace("type.combatLevel = ", "");
    			    	line = line.replace(";", "");
    			    	level = Integer.parseInt(line.trim());	
    			    } else if(line.contains("type.tileSpacesOccupied")) {
    			    	line = line.replace("type.tileSpacesOccupied = ", "");
    			    	line = line.replace(";", "");
    			    	size = Integer.parseInt(line.trim());	
    			    } else if(line.contains("type.options") && line.contains("Attack")) {
    			    	attackable = true;	
    			    }
    			}
    		}
    		
    		Element el = doc.createElement("NpcDefinition");
    		defList.appendChild(el);			    		
    		addAttr(doc, el, "id", Integer.toString(id));
    		addAttr(doc, el, "name", name);
    		addAttr(doc, el, "walkAnimation", Integer.toString(walkAnimation));
    		addAttr(doc, el, "standAnimation", Integer.toString(standAnimation));
    		addAttr(doc, el, "turn180Animation", Integer.toString(turn180Animation));
    		addAttr(doc, el, "turn90CWAnimation", Integer.toString(turn90CWAnimation));
    		addAttr(doc, el, "turn90CCWAnimation", Integer.toString(turn90CCWAnimation));
    		addAttr(doc, el, "level", Integer.toString(level));
    		addAttr(doc, el, "size", Integer.toString(size));
    		addAttr(doc, el, "attackable", Boolean.toString(attackable));
    		
    		TransformerFactory transformerFactory = TransformerFactory.newInstance();
    		Transformer transformer = transformerFactory.newTransformer();
    		DOMSource source = new DOMSource(doc);
    		StreamResult result = new StreamResult(new File(EXPORT));
    
    		transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    		transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
    		transformer.transform(source, result);		
    	}
    }
    just edit that and the constants.java and maybe that'll help you do what youre trying to do.


    if you need help figuring this out, if you decided to use this, message me.
    Attached image
    Attached image
    Honestly i just wanted to be one of the greats
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Jan 2017
    Posts
    196
    Thanks given
    15
    Thanks received
    22
    Rep Power
    11
    Quote Originally Posted by FYLS View Post
    Not too sure if this will help you, but you could use https://www.rune-server.ee/runescape...64-openrs.html, just put it in eclipse, it will have errors but it will still work, then in source.net.openrs.cache.tools *CREDIT TO WHOEVER MADE THIS CODE, IT WAS NOT ME I CANT REMEMBER WHO IT WAS THOUGH* make a new java file called 'NpcDefDumper and add this in there
    Code:
    package net.openrs.cache.tools;
    
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileReader;
    import java.io.IOException;
    import java.nio.charset.Charset;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.transform.OutputKeys;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    
    public class NpcDefDumper {
        
        public static final String EXPORT = "C:/Users/XXXXX/Desktop/export/NpcDefinitions.xml"; //location you want to export xml file
        
        public static final String LISTFILE = "C:/Users/XXXXX/Desktop/ccache/repository/types/npcs.txt";  //location of your npcs.txt
        
        static String readFile(String path, Charset encoding) 
          throws IOException 
        {
          byte[] encoded = Files.readAllBytes(Paths.get(path));
          return new String(encoded, encoding);
        }
        
        static void addAttr(Document doc, Element el, String key, String value) {
            Element attr = doc.createElement(key);
            attr.appendChild(doc.createTextNode(value));
            el.appendChild(attr);
        }
    
        public static void main(String[] args) throws Exception {
            
            DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
    
            Document doc = docBuilder.newDocument();
            Element defList = doc.createElement("list");
            doc.appendChild(defList);
    
            int id = -1;
            String name = "null";
            int walkAnimation = 65535;
            int standAnimation = 65535;
            int turn180Animation = 65535;
            int turn90CWAnimation = 65535;
            int turn90CCWAnimation = 65535;
            int level = -1;
            int size = 1;
            boolean attackable = false;
            
            try (BufferedReader br = new BufferedReader(new FileReader(LISTFILE))) {
                String line;
                while ((line = br.readLine()) != null) {
                    if(line.startsWith("case ")) {
                        if(id != -1) {
                            Element el = doc.createElement("NpcDefinition");
                            defList.appendChild(el);                        
                            addAttr(doc, el, "id", Integer.toString(id));
                            addAttr(doc, el, "name", name);
                            addAttr(doc, el, "walkAnimation", Integer.toString(walkAnimation));
                            addAttr(doc, el, "standAnimation", Integer.toString(standAnimation));
                            addAttr(doc, el, "turn180Animation", Integer.toString(turn180Animation));
                            addAttr(doc, el, "turn90CWAnimation", Integer.toString(turn90CWAnimation));
                            addAttr(doc, el, "turn90CCWAnimation", Integer.toString(turn90CCWAnimation));
                            addAttr(doc, el, "level", Integer.toString(level));
                            addAttr(doc, el, "size", Integer.toString(size));
                            addAttr(doc, el, "attackable", Boolean.toString(attackable));
                        }
                        name = "null";
                        walkAnimation = 65535;
                        standAnimation = 65535;
                        turn180Animation = 65535;
                        turn90CWAnimation = 65535;
                        turn90CCWAnimation = 65535;
                        level = -1;
                        size = 1;
                        attackable = false;
                        line = line.replace("case ", "");
                        line = line.replace(":", "");
                        id = Integer.parseInt(line);
                    } else if(line.contains("type.name")) {
                        line = line.replace("type.name = \"", "");
                        line = line.replace("\";", "");
                        if(line.contains("<col"))
                            line = line.substring(13, line.length() - 6);
                        name = line.trim();    
                    } else if(line.contains("type.stanceAnimation")) {
                        line = line.replace("type.stanceAnimation = ", "");
                        line = line.replace(";", "");
                        standAnimation = Integer.parseInt(line.trim());    
                    } else if(line.contains("type.walkAnimation")) {
                        line = line.replace("type.walkAnimation = ", "");
                        line = line.replace(";", "");
                        walkAnimation = Integer.parseInt(line.trim());    
                    } else if(line.contains("type.rotate180Animation")) {
                        line = line.replace("type.rotate180Animation = ", "");
                        line = line.replace(";", "");
                        turn180Animation = Integer.parseInt(line.trim());    
                    } else if(line.contains("type.rotate90LeftAnimation")) {
                        line = line.replace("type.rotate90LeftAnimation = ", "");
                        line = line.replace(";", "");
                        turn90CWAnimation = Integer.parseInt(line.trim());    
                    } else if(line.contains("type.rotate90RightAnimation")) {
                        line = line.replace("type.rotate90RightAnimation = ", "");
                        line = line.replace(";", "");
                        turn90CCWAnimation = Integer.parseInt(line.trim());    
                    } else if(line.contains("type.combatLevel")) {
                        line = line.replace("type.combatLevel = ", "");
                        line = line.replace(";", "");
                        level = Integer.parseInt(line.trim());    
                    } else if(line.contains("type.tileSpacesOccupied")) {
                        line = line.replace("type.tileSpacesOccupied = ", "");
                        line = line.replace(";", "");
                        size = Integer.parseInt(line.trim());    
                    } else if(line.contains("type.options") && line.contains("Attack")) {
                        attackable = true;    
                    }
                }
            }
            
            Element el = doc.createElement("NpcDefinition");
            defList.appendChild(el);                        
            addAttr(doc, el, "id", Integer.toString(id));
            addAttr(doc, el, "name", name);
            addAttr(doc, el, "walkAnimation", Integer.toString(walkAnimation));
            addAttr(doc, el, "standAnimation", Integer.toString(standAnimation));
            addAttr(doc, el, "turn180Animation", Integer.toString(turn180Animation));
            addAttr(doc, el, "turn90CWAnimation", Integer.toString(turn90CWAnimation));
            addAttr(doc, el, "turn90CCWAnimation", Integer.toString(turn90CCWAnimation));
            addAttr(doc, el, "level", Integer.toString(level));
            addAttr(doc, el, "size", Integer.toString(size));
            addAttr(doc, el, "attackable", Boolean.toString(attackable));
            
            TransformerFactory transformerFactory = TransformerFactory.newInstance();
            Transformer transformer = transformerFactory.newTransformer();
            DOMSource source = new DOMSource(doc);
            StreamResult result = new StreamResult(new File(EXPORT));
    
            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
            transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
            transformer.transform(source, result);        
        }
    }
    just edit that and the constants.java and maybe that'll help you do what youre trying to do.


    if you need help figuring this out, if you decided to use this, message me.
    Thanks however I don't have any npc.txt files to import
    Reply With Quote  
     

  5. #5  
    Donator

    Join Date
    Feb 2017
    Posts
    16
    Thanks given
    4
    Thanks received
    7
    Rep Power
    13
    Quote Originally Posted by Sami2427 View Post
    Thanks however I don't have any npc.txt files to import
    you can use OpenRS to make the txt file, or i can send you one.
    Attached image
    Attached image
    Honestly i just wanted to be one of the greats
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. I need help with pen tool
    By Joe in forum General
    Replies: 6
    Last Post: 01-19-2008, 07:05 PM
  2. Need help with turning something back
    By ftmaster in forum RS2 Server
    Replies: 0
    Last Post: 12-20-2007, 03:11 PM
  3. Need help with DomScape
    By thegreatblob in forum Requests
    Replies: 4
    Last Post: 11-30-2007, 04:25 AM
  4. need help with making a client with new stuff
    By yahoo112 in forum RS2 Client
    Replies: 1
    Last Post: 09-19-2007, 08:06 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •