GITHUB: https://github.com/microgeek/XMLConfig I've started on this, and it's coming along nicely. It's essentially mirroring the configuration Api in XML, but it's much more flexible. For example, you can easily serialize and de-serialze ItemStacks, Locations, and more. Syntax for saving a location and itemstack: HTML: <item type="location" key="location_1"> <item key="world" value="world_nether" /> <item key="x" value="90" /> <item key="y" value="90" /> <item key="z" value="90" /> <item key="pitch" value="70" /> <item key="yaw" value="50" /> </item> <item type="itemstack" key="itemstack_1"> <item key="material" value="STICK" /> <item key="meta"> <item key="type" value="unspecific" /> <item key="display-name" value="&lA stick" /> <item key="lore"> <item value="lore1" /> <item value="lore2" /> </item> </item> </item> Loading them: PHP: XMLConfig xc = XMLConfigUtilities.getConfig("testConfig");Location location = xc.getLocation("location_1");ItemStack itemstack = xc.getItemStack("itemstack_1"); If you do not want to call the method getLocation, getString, ect, you can just call get, and it will parse it into the best choice, and cast it into an Object. PHP: XMLConfig xc = XMLConfigUtilities.getConfig("testConfig");Location location = (Location) xc.get("location_1"); Feedback? Status: Finishing reading/parsing primitive types Todo: Add saving Clean up code a bit
I like what you're doing a lot, but why do you prefer XML over YML? I get its more flexible in storing locations, itemstacks, etc, but that's all possible with YML also.
For a two(main) reasons. XML is not dependent on indentation Allows for more flexibility, such as adding attributes or "meta" values to lists, and other datatypes, but still allows for a path.to.value navigation
ferrybig It's as simple as making an instance of the XMLConfig, calling xmlconfig.set(path.to.value, value), and to retrive it, you just call xmlconfig.get<DataType(Integer, Location, String, ect.)>(path.to.value)
When you plan to release it? (Can't wait ) Also this allows for storing more objects like HashMaps or PotionEffects. I hope it will be on github so maybe i'll try to make it better (if it's possible(oh, and i don't mean copy, change author name and compile but PR ofc)).
Of course, I love GitHub(I rarely use it though =/)! I'm not 100% sure when the release is going to be, but within a few days I hope! I need to add options for parsing certain data types(such as lists and maps), and I need to add saving of the files also(should not be too hard ). I'll be sure to update the thread with status updates. Here is a small part of the main file, for pasring and getting values: Code:java public String getNodePath(Node node) {String path = getNodeKey(node);Node parent = node.getParentNode();while(parent != null && getNodeKey(parent) != null) {path = getNodeKey(parent) + "." + path;parent = parent.getParentNode();}return path;} public String getNodeType(Node node) {return getNodeAttribute(node, "type");} public String getNodeKey(Node node) {return getNodeAttribute(node, "key");} public String getNodeValue(Node node) {String attribute = getNodeAttribute(node, "value");if(attribute != null) return attribute;return node.getTextContent();} public String getNodeAttribute(Node node, String attribute) {if(node == null) return null;if(node.getAttributes() == null) return null;Node value = node.getAttributes().getNamedItem(attribute);if(value == null) return null;return value.getTextContent();} public List<Node> getAllNodes() {List<Node> nodes = new ArrayList<Node>();for(Node n : nodeListToList(document.getChildNodes())) {nodes.addAll(getChildNodes(n));}return nodes;} public List<Node> getChildNodes(Node node) {List<Node> nodes = new ArrayList<Node>();nodes.add(node);for(Node n : nodeListToList(node.getChildNodes())) {nodes.addAll(getChildNodes(n));}return nodes;} public List<Node> nodeListToList(NodeList nodeList) {List<Node> nodes = new ArrayList<Node>();for(int i = 0; i < nodeList.getLength(); i++) {Node n = nodeList.item(i);if(n.getNodeType() == Node.TEXT_NODE) continue;nodes.add(n);}return nodes;} Sorry about the indentation =/ I've got parsing of all primitive types, plus locations. I need to do Collections, maps, so then I can add support for itemstacks, potion effectes, ect. EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Will it have simple api for storing other objects? For example i'm creating some magic plugin and I want to store object MagicPlayer which contains 5 simple vars. Will it be able?
Yes, it will be quite easy to do so. You can easily write your own method, like how I did the Locations: Code: public Location getLocation(String path) { World world = plugin.getServer().getWorld(getString(addPath(path, "world"))); double x = getDouble(addPath(path, "x")); double y = getDouble(addPath(path, "y")); double z = getDouble(addPath(path, "z")); float yaw = getFloat(addPath(path, "yaw")); float pitch = getFloat(addPath(path, "pitch")); return new Location(world, x, y, z, yaw, pitch); }
microgeek I know you could be busy but I wanted to use this lib in one of my newest projects so at least I expect status update like "I won't finish it" or anything.
I mean i'm wating with project for this library so if it won't be finished i'll have to continue project but using yml.
I've had 4 custom plugin(quite large) jobs to finish, but I do plan to release this, it might be a week or so.
I don't know when I'll be able to finish this, so I'm throwing what I have on GitHub, feel free to make PRs, give me a few minutes. Just cleaning up some code and adding a few things, expect first commit in about 30 minutes. Added to github, enjoy I guess. https://github.com/microgeek/XMLConfig EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Deciding to pick this back up. I've done a lot of work, and I almost have reading values completely done. setting values and saving them are a bit harder, but I plan on getting it working.
I figured out how to do this, without a lib. Just search up a basic tutorial of JDOM2, and it's really easy, unlike SAX and DOM (it's just a combination of both, but easier to use)
This is more of a mirror of yamlsnake but with XML, more user friendly and removes redundant and repetitive code.
I try to work on it, to get it to a fully working and dev friendly state, but there's a lot of work that still needs to be done. Feel free to contribute to the GitHub.