Specify a file path in config?

Discussion in 'Spigot Plugin Development' started by Azmidium, Mar 11, 2016.

  1. How would I go about getting a file path from a config file, do I just grab the path directly from the config with "C:/Whatever" or do I need to set stuff up? Do I need to navigate to the server folder to make sure if they aren't using Multicraft and are using something like MCMyAdmin, it doesn't access like the main-main folder which isn't actually your server. Sorry if this typing was terrible posted at 1 AM after attempting to figure this out all day, I need help getting answers.

    Thanks for reading through that mess ^ (I hope you get the point)

    Sincerely,
    Azmidium
     
  2. If you want to get the plugin's folder (plugins/Your-Plugin), you can just use getDataFolder(). That is guaranteed to return a valid path on any system in any configuration (well, maybe not any, but most)
     
  3. Do you know how I could do it from the main server folder, the directory that holds the worlds and the server properties, etc. :)

    Thanks in advance!! ;)

    Sincerely,
    Azmidium
     
  4. Bukkit.getWorldContainer(). That will return the directory containing all the worlds which is usually, but not always the root folder of the server
     
  5. I will be looking out for a more reliable method, thanks for all the help so far though! :)

    Thanks! ;)

    Sincerely,
    Azmidium
     
  6. File.getAbsolutePath() - Path the where the config will be.
     
  7. Actually, thinking about it, I think "new File(".")" would guarantee the root directory of the minecraft server. The "." stands for the current working directory that the jar is being run from, which, ~99% of the time, is the file with all the configs like ops.json and whitelist.json and stuff like that.
     
    • Agree Agree x 1
  8. I will be using that, there is always that 1% that something won't work anyway.

    Thanks so much for the help MrKirby!

    Sincerely,
    Azmidium

    P.S: I don't know why I write these like letters... xD