Solved API saving file problem

Discussion in 'Plugin Development' started by slater96, Aug 11, 2013.

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

    slater96

    Hello, I've started to make an API and used this method to test however I've found a problem.
    Code:
    public void saveFile() {
            File file = new File(this.getDataFolder() + "test" + File.separator, "Test.dat");
            if (file.exists()) {
                try {
                    file.createNewFile();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    It get's the data folder of the API but I need it to access the plugin the API is being implemented on. Is there a way to do this in a constructor as i'll be needing it in more than one method. Thanks in advance.
     
  2. Offline

    xize

    you could make a method in your main class which return your api class file

    Then do in your other plugin something like this

    Code:
    if(Bukkit.getPluginManager().isPluginEnabled("yourplugin")) {
       yourplugin plug = (yourplugin) Bukkit.getPluginManager().getPlugin("yourplugin");
       plug.getApi() // which returns your api class
    }
    
     
Thread Status:
Not open for further replies.

Share This Page