Delete/read file with bukkit

Discussion in 'Plugin Development' started by To175, Dec 31, 2014.

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

    To175

    Hi,
    can someone give me information about java with bukkit please ?
    What I want :
    - modify other plugin's .yml
    - delete (worlds') playerdata's .dat

    Can I do that (below) ?
    Code:
    MyFile = new File(getDataFolder(), "/plugins/ThePlugin/TheFile.yml");//Is it the right path ?
    MyFile.set("something."+player+".data",null);
    Code:
    MyFile2 = new File(getDataFolder(), "/World/playerdata/UUID.dat");//Is it the right path ?
    if(MyFile2.delete()){
                getLogger().info("deleted");
    }else{
                getLogger().info("error");
    }
    Is my code correct ? I will implement it to my plugin with loops, can I do loops (for) here ?
    I have maybe 1000 UUID in playerdata... It seems to be huge to create a new File() each time, am I wrong ?

    + does this code below 'return' me a timestamps ?
    Code:
    Date now = new Date();//is "now" a timestamp ?
    Thanks :)
     
  2. Offline

    Rocoty

    What happened when you tried it?
     
  3. Offline

    To175

    You could read before answer, thanks.
     
  4. Offline

    Rocoty

    @To175 Pardon? Have you tried running some of the code you've shown us? In which case, what did you find out about it? If not, maybe that would be a good idea?
     
  5. Offline

    To175

    @Rocoty
    I don't know to do the hole code, so I'm asking for "is it correct" before to launch it. I just send some code I think it is concerned. I don't want all my folders deleted (great bad idea ;) )
    I'm asking for help, you can say "search" to everybody on a forum because every question has an answer.
    You can't because I searched. And I can't find more.
    + I would like to know performance, I can't search for that ! I want to know if a loop with new File/deleting file is bad or not.
     
  6. Offline

    Rocoty

    @To175 You should set up a small test environment, where you have files only for testing purposes...files you don't really care about. I can tell you the code you've shown will not have "all [your] folders deleted".

    If my answer to your question "is it correct" was "yes", would you then test it?
     
Thread Status:
Not open for further replies.

Share This Page