Solved This is probably a dumb question but..

Discussion in 'Plugin Development' started by Eggspurt, Apr 10, 2015.

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

    Eggspurt

    Code:
                  File dataFolder = new File("plugins/CRBlacklist", "CRBlacklist.txt");
                if(!dataFolder.exists())
                {
                    dataFolder.mkdir();
                }
    
    For some reason it makes the folder "CRBlacklist.txt" the folder name..

    Any ideas on what I am doing wrong? I feel like its obvious but I guess I am blind.

    I want to use getDataFolder() but I don't know how I can if its not in the Main Class.
     
  2. Offline

    SuperOriginal

    File#createNewFile()

    Pass the instance of your main class through your constructor to get access to getDataFolder()
     
    Last edited: Apr 10, 2015
  3. Offline

    Eggspurt

    If I do that doesn't it initialize the plugin twice?

    You mean

    Main m = new Main();

    Right?
     
  4. Offline

    1Rogue

  5. Offline

    Eggspurt

    Last edited: Apr 10, 2015
  6. Offline

    Zombie_Striker

    Mark as [Solved] if solved.
     
  7. Offline

    Rocoty

    @Eggspurt For reference, it's called dependency injection. Read about it.
     
Thread Status:
Not open for further replies.

Share This Page