Well guys while messing with saving stuff i failed to use java i/o on files added this so it will check for the following path http://hastebin.com/izevivahim.mel something\something2\.....\plugins\hometest\homes.yml and write true or false on start but even if i have it deleted or not deleted on load it allways gives me false.. why and for the ones asking for entire code .. its soo messy and buggy but just doing it for test : *done uploading* http://hastebin.com/boqasuwaye.java
You shouldn't ask the operating system for "user.dir," instead ask Bukkit for JavaPlugin#getDataFolder() to get a directory to save in.
well its the same directory "also for the ones asking why do you use / .. java autocorrects it to \" also chat output at start gives correct path but false and also how can i use javaplugin.getdatafolder(); i looked at the page and tried "plugin.getDataFolder();" but didnt worked
Thanks for the replies and the great help i found both ways and how to do it in following and hopefully this will help to the people like me who want to start from 0 1st way ; by getting servers location from windows' own dir "not by bukkit" Code:java File file = new File(System.getProperty("user.dir") +"/plugins/Hometest/homes.yml"); boolean exists = file.exists(); Bukkit.broadcastMessage("File " + file.getPath() + " exists: " + exists); note that System.getProperty("user.dir") gives you the servers folder not the plugins folder so you need to add /plugins again... also hometest was my folder and homes.yml was my file and 2nd way ; With bukkits own method "using bukkit" Code:java File file2 = new File(getDataFolder() +"/homes.yml"); boolean exists2 = file2.exists(); Bukkit.broadcastMessage("File " + file2.getPath() + " exists: " + exists2); getdatafolder will give you the direct folder of your plugin under /plugins/ so you can add your yml to check
You can try a test statement: Code:java if (file.exists()) {Bukkit.broadcastMessage("File " + file.getPath() + " exists: true");} else {Bukkit.broadcastMessage("File " + file.getPath() + " exists: false");}