can't get per player specific File

Discussion in 'Plugin Development' started by MAKAPUSH, Dec 17, 2019.

Thread Status:
Not open for further replies.
  1. Offline


    Hello, i am making a PlayerData Folder wich each players have his File.
    i can create a Player File each times they join my server but the problem is i can't get the PlayerFile when more than 2 players come in my server (it make Error : "File cannot be Null")
    here is my Code :

    i would like a File.getFile(Path) Function to get the specified File
    thanks for any Help ;)

    Attached Files:

  2. Online

    timtower Moderator Moderator

    @MAKAPUSH You probably want those variables to be per player instead of global.
  3. Offline


    yes ! absolutely
  4. Offline


    There's no "File.getFile(String path)" method because you just do "new File(String path)" to get a file.

    Btw, you can change this part of your code:
    1. File folder = new File(getDataFolder() + File.separator + "playersData");
    2. if(!folder.exists()) folder.mkdirs();
    3. playerFile = new File(getDataFolder() + File.separator + "playersData" + File.separator + p.getUniqueId() +".yml");

    To this:
    1. File folder = new File(getDataFolder(), "playersData");
    2. if (!folder.exists()) folder.mkdirs();
    3. playerFile = new File(folder, p.getUniqueId() + ".yml");

    Less code, easier to read, and it still functions the same.

    Does that mean you got it working, or do you still need help?
  5. Offline


Thread Status:
Not open for further replies.

Share This Page