Hey I'm trying to create a properties file but PropertiesFile doesn't do what I'm looking for. I know i'm supposed to use SQLite but the plugin is more better suited to flatfile. Anyway, I'm trying to create my first plugin in java and heres how it is supposed to be: Code: # Author: Nilaky # # Preface all commented lines with # # All other lines should be in the form: # blockID:drop1,drop2,drop3:probability # CustomDrops is designed to replace existing drops! # For example: # 2:295:0.5 # will make grass(2) drop seeds(295) 50% of the time # but this replaces the dirt that would drop # To keep the old drops, try something like: # 2:295:0.5 # 2:3:1.0 # this makes grass(2) always drop dirt(3) # but have a 50% chance to ALSO drop seeds(295) # Sand 12:12:1.0 12:20:0.001 12:346:0.0001 (from http://forums.bukkit.org/threads/custom-drops-please.1198/) I currently have properties that are more like 12=12 and I dont know how to read more two variables, and I'd rather have old compatibility with the plugin. I have no idea how to create a properties file formatted like that. Here's my current reading format: Code: PropertiesFile myPluginSettings = new PropertiesFile( "blockdrops.properties" ); myPluginSettings.load(); blockddddd = myPluginSettings.getInt( convertSimple(blockid) , blockid ); Any help would be appreciated. Thanks.
You may have to write your own file reader. You could then read a line and use the split command. Code: BufferedReader in = new BufferedReader(new FileReader(new File(directory, "your_filename.txt")); String line; while( (line=in.readLine() ) != null ) { String lineTrim = line.trim(); if( lineTrim.startsWith( "#" ) ) { continue; } String[] split = lineTrim.split(":"); int blockId = Integer.parseInt(split[0])); int dropId = Integer.parseInt(split[1])); double p = Double.parseDouble(split[2])); <your code> } try { in.close(); } catch (IOExeception ioe) { <give error message that you can't close file> } This assumes that directory is the folder that you are given as part of the plugin constructor. The trim will remove white spaces at the start and end of the line and the split will break it into pieces using : as the split point. This does no error checking, so faulty files will throw exceptions. You may also need a try{} catch() {} around the in.close() line. I haven't checked the above, so it may not work.