Getting plugin-folder path

Discussion in 'Plugin Development' started by Ikaron, Feb 13, 2012.

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

    Ikaron

    Hey, I want to develop a little economy plugin, and need to save files. I know how to save them, but how can I get the bukkit/plugins folder path?
    Thanks in advance,
    Ikaron
     
  2. in your main class you can use "getDataFolder()" to return the path to the plugins folder.
     
    Ikaron likes this.
  3. Offline

    Ikaron

    Thanks ;D
    But it creates a folder called "null" next to "plugins"... Is that my fault?
     
  4. if you just use getDataFolder() and nothing else, it shouldn't be your fault.
     
  5. Offline

    thehutch

    I get a wierd error when I try using this:

    Code:
    File file = new File(this.getdataFolder(), "randomFile.txt");
    
    For some wierd reason it creates the file inside the mina directory (where craftbukkit is) is this some sort of bug atm or am I doing something wrong?

    I also use this:

    file.createNewFile()
     
  6. Offline

    Ikaron

    In my case (I use getDataFolder() + "/ikColony/accounts/") the same happens. It creates the folder bukkit/null/ikColony/accounts/... Whyever.. So, I looked into it, and saw that dataFolder is set to null, and afterwards set by bukkit (initialize method). So, I'll look into this init method now.. Okey, the PluginLoader sets it to jarfile.getParentFile() + "/pluginName/"; ... So, no idea why it's null.

    @Edit 4021321: You need to set it in onEnabled(); and not in the instance-variables... That worked for me, at least.
     
  7. Offline

    Vandrake

    e (I use getDataFolder() + "/ikColony/accounts/")
    replace this with
    getDataFolder()+File.separator+"accounts"<this will create the folder accounts. provided you save it afterwards
     
Thread Status:
Not open for further replies.

Share This Page