Hi, guys. I need your help again. What I need: There are some Permissions in a Plugin. First Permission can teleport Player to the place "1", second Permission - to the place "2", third Permission - to the place "3"(it might be not a teleportation). Player can Buy some of the Permissions with his own expirience. To save information about Player who owns some of them I want to create 3 files: "First", "Second" and "Third". In every file would be only names of the owners. And it would be cool if you can help me with a command which writes or removes names of the owners in the files. Maybe I want so much from you, but if you can - help me please P.S. I can`t use plugin PermissionEX or something like it.
You'll at least need to have a reader. Take a look at some videos, and store it playernameermission. You shouldn't have the command edit the file immedeatly, but rather a HashMap<String (playername, that is.), String (Permission). Make the HashMap read the information in onEnable, and write in onDisable. Reccomended search: Java Reading and Writing Files. Remember to make the path: File folder = new File(getDataFolder().getParent() + \\NameOfPlugin); File f = new File(fi + \\First.yml); File f2 = new File(fi + \\Second.yml); File f3 = new File(fi + \\Third.yml); Remember to check if the folder and Files exist before you do createNewFile(); and mkdir(); If you have a config file, the folder might be created automatically. Code:java if (!folder.exists()) { log.info("[" + file.getName() + "] INFO: can't find directory file. Attempting to create a new one..."); folder.mkdir(); } if (!f.exists()) { log.info("[" + file.getName() + "] INFO: can't find players file. Attempting to create a new one..."); try { f.createNewFile(); } catch (IOException e) { log.warning("[" + file.getName() + "] ERROR: failed to create file!"); e.printStackTrace(); } }