Hi I am using this method to save data to a txt. source: bukkit Code (Text): public void logToFile(String message, String player) { try { File dataFolder = getDataFolder(); if(!dataFolder.exists()) { dataFolder.mkdir(); } File saveTo = new File(getDataFolder(), player + ".txt"); if (!saveTo.exists()) { saveTo.createNewFile(); } FileWriter fw = new FileWriter(saveTo, true); PrintWriter pw = new PrintWriter(fw); pw.println(message); pw.flush(); pw.close(); } catch (IOException e) { e.printStackTrace(); } } which gives me for example: Spoiler: player.txt Freddy // location x y z hans //area x y z x y z xxxxxxx //area x y z .... which is getting really big I would prefer this (below), but I have no idea how to get the data out of the document Spoiler: playerIWhant.txt Freddy x y z hans x y z x y z xxxxxxx x y z x y z ...... or is the first method better than the second? I allsow like this one, but it has a similar result like player.txt could somebody link me or give a code example? or has a better method to bind names to coordinates or areas? it is all about the mbits ^^ Thanks in advance for any help
Sorry for being late, use MySQL databases in a local mode (only for use in your plugin) if you don't want to annoy users to have them set a DB up, they're much easier to use. Tutorial I used (very helpful and up to date): https://bukkit.org/threads/using-mysql-in-your-plugins.132309/
Thx for the reply I was searching for a nice method how to save and compare areas and positions... and think, after trying some, .txt would be the best for me. just the system should go through those files... I was kind of stupid that I did not notice that i was in java and not in bukkit -_- So I was looking for this Code (Text): String string = "x:y:z...."; String[] parts = string.split(":"); String part1 = parts[0]; String part2 = parts[1]; ..... worked all proper with my algorythm until I changed the code, and forgot where I think it has something to do with my BufferedReaders/writers can I use them in that way? could somebody see the error? Code (Text): public String fileManager (String player, String[] message, String info) { try { File dataFolder = getDataFolder(); if(!dataFolder.exists()) { dataFolder.mkdir(); } File villages = new File(getDataFolder(), "villages.txt"); //villagesFile if (!villages.exists()) { villages.createNewFile(); } File personalFile = new File(getDataFolder(), player + ".txt"); //personal File if (!personalFile.exists()) { personalFile.createNewFile(); } BufferedReader villageReader = new BufferedReader (new FileReader (villages)); BufferedWriter villageWriter = new BufferedWriter (new FileWriter (villages)); BufferedReader fileReader = new BufferedReader (new FileReader (personalFile)); BufferedWriter fileWriter = new BufferedWriter (new FileWriter (personalFile)); if (info == "hasVillage?") { String hasVillage = fileReader.readLine(); System.out.println("debug:" + hasVillage); if(hasVillage == null) { fileWriter.close(); fileReader.close(); villageWriter.close(); villageReader.close(); return "noVillage"; } else { fileWriter.close(); fileReader.close(); villageWriter.close(); villageReader.close(); return "hasVillage"; } } } the debug allways gives out null even if the text file has some code in it... help is warmly accepted