How to load files from folder in plugins folder?

Discussion in 'Plugin Development' started by pj6444, Mar 24, 2014.

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

    pj6444

    Hi all,

    I am making a plugin and I want to have some files for my plugin outside of the actual jar itself. Does anyone know how I can load in files that are in the same folder as my jar and use them?

    Thanks
     
  2. Offline

    SkyleTyler1337

    huh ? explain a bit more xD
     
  3. Offline

    pj6444

    Ok. So I have a separate folder inside my plugins folder and I want to be able to access the files in there through the jar. But I need to find the path relative to the jar file and not hard code the actual path.
     
  4. Offline

    SkyleTyler1337

    why don't you add it as a build path -_- xD
     
  5. Offline

    Minnymin3

    Check out the Java io API. Not a bukkit related question.
     
  6. Offline

    Shayana

    The path to your plugin folder (/MyPluginName/) inside craftbukkit directory is provided by getDataFolder() from the JavaPlugin class. According to java files api, you can get the parent folder with file.getParent(), that would get the /plugins/ folder, where your jar is stored
     
  7. Offline

    GotRice

    pj6444 Assuming these files are not config files, place the files inside of your eclipse project folder.. And use saveResource method provided by Bukkit API to copy the files from inside the jar to your plugin directory, saveResource will require the file name with the extension and a boolean to replace the files or not.
     
  8. Offline

    pj6444

    Thanks everyone! You've helped me a lot!
     
Thread Status:
Not open for further replies.

Share This Page