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

    MAKAPUSH

    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")
    upload_2019-12-17_10-13-33.png
    here is my Code :
    upload_2019-12-17_10-13-6.png

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

    Attached Files:

  2. Offline

    timtower Administrator Administrator Moderator

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

    MAKAPUSH

    yes ! absolutely
     
  4. Offline

    KarimAKL

    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:
    Code:Java
    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:
    Code:Java
    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

    MAKAPUSH

Thread Status:
Not open for further replies.

Share This Page