change a file within the plugin

Discussion in 'Plugin Development' started by mrzeapple, Jun 14, 2013.

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

    mrzeapple

    I need my plugin to log a command in a separate file in the plugin how would I do that?
     
  2. Offline

    Sir_Mr_Bman

    How do you mean "log a command"
    Like whenever a user runs it it logs it?
    In that case, I have no idea.
    Explain then I think the comunity will be able to help better.
     
  3. Offline

    mrzeapple

    when someone uses the command it will change the difficulty it will log what the difficulty will be
     
  4. Offline

    metalhedd

    You don't want to store the file INSIDE Your plugin, that's a horrible idea.

    You want to store it in your plugins data folder, which is accessible from Plugin.GetDataFolder() just use standard java code to open a file there and write something to it, there's nothing bukkit-specific about that

    out of curiosity, why do you want it in a separate file and not just in the normal server log? I wouldn't run a plugin that keeps its own logs.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 2, 2016
  5. Offline

    Sir_Mr_Bman

    metalhedd I agree here. This would make me suspicious, what is it doing with all that data? Also, it takes up some space, does it not?
     
  6. Offline

    mrzeapple

    it is so it would keep what the difficulty is set to before a reload or restart
     
  7. Offline

    metalhedd

    i am not concerned about any data he might be gathering, i'm more concerned about the waste of disk space, and the separation of logs.. If i'm debugging a problem i want to look in 1 log file, not one for each plugin.

    that's not the right way to do it then. look into the configuration api

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 2, 2016
  8. Offline

    Sir_Mr_Bman

    It could be done this way, I mean if you want it complicated.
    You could set the text doc to a difficulty, and then in the onEnable() make it set the difficulty to the string it recives from the file, that is possible.
    However, not recomended.
     
  9. Offline

    metalhedd

    possible or not, its less than helpful to teach people the wrong ways of doing things.
     
  10. Offline

    Sir_Mr_Bman

    I don't mean to be argumentative here, but there are more than one way to do certain things. This just happens to be one of them. Sure, it may not be helpful to say what he wanted to do is possible and there is an easier way to do it over here, but it's still something he could do if he's already written some of the code for it.
    Just saying, might be easier to finish what he started then start over.
     
  11. Offline

    metalhedd

    I see your point, but in this case it most definitely isn't, he's going to come back with "now how do I open a file and read the value back"... using the configuration api properly avoids that future problem. suggesting that he should proceed with his current approach is just going to cause him a world of pain that could be avoided with 5 minutes of reading and then doing it right. we're here to HELP, not just answer questions blindly.
     
Thread Status:
Not open for further replies.

Share This Page