Config - The system cannot find the path specified

Discussion in 'Plugin Development' started by EgyptianKing, Aug 9, 2014.

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

    EgyptianKing

    So I'm trying to create a yaml for every player, but I get the error, "The system cannot find the path specified". I'm not sure what I am doing wrong.

    Here's my code:

    Code:java
    1. @EventHandler
    2. public void onPlayerJoin(PlayerJoinEvent e) throws IOException
    3. {
    4. File file = new File(this.getDataFolder() + File.separator + "users" + File.separator + e.getPlayer().getName() + ".yml");
    5. FileConfiguration config = YamlConfiguration.loadConfiguration(file);
    6.  
    7. if(!file.exists())
    8. {
    9. file.createNewFile();
    10. }
    11. }
    12.  
     
  2. Offline

    xTigerRebornx

    EgyptianKing Load the config after you create the file, you can't load the config of a file that doesn't exist.
    Edit: You should be using UUIDs as well, names will soon be no longer unique and not a valid way of persisting data for Players.
     
  3. Offline

    EgyptianKing

    xTigerRebornx

    Alright, I changed it to:

    Code:java
    1. @EventHandler
    2. public void onPlayerJoin(PlayerJoinEvent e) throws IOException
    3. {
    4. File file = new File(this.getDataFolder() + File.separator + "users" + File.separator + e.getPlayer().getName() + ".yml");
    5.  
    6. if(!file.exists())
    7. {
    8. file.createNewFile();
    9. FileConfiguration config = YamlConfiguration.loadConfiguration(file);
    10. }
    11. }


    But I still get the same error.
     
  4. Offline

    xTigerRebornx

  5. Offline

    EgyptianKing

    xTigerRebornx
    Code:java
    1. Caused by: java.io.IOException: The system cannot find the path specified
    2. at java.io.WinNTFileSystem.createFileExclusively(Native Method) ~[?:1.8.0_05]
    3. at java.io.File.createNewFile(Unknown Source) ~[?:1.8.0_05]
    4. at me.blockcount.Main.onPlayerJoin(Main.java:58) ~[?:?]
    5. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_05]
    6. at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_05]
    7. at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_05]
    8. at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_05]
    9. at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:292) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.2-16-g37c7969-b3105jnks]
    10. ... 15 more
     
  6. Offline

    xTigerRebornx

    EgyptianKing getDataFolder() may not have been made yet, create it if it doesn't.
     
    EgyptianKing likes this.
  7. Offline

    EgyptianKing

    xTigerRebornx

    Alright, I fixed my problem.

    So I'll explain it for the people who want a solution:

    First I had to make the users folder on enable. Afterwards I'd create each yaml in the join event.
     
Thread Status:
Not open for further replies.

Share This Page