Solved [Question] What is onDisable() good for?

Discussion in 'Plugin Development' started by bdubz4552, Jun 3, 2014.

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

    bdubz4552

    I haven't found any outstanding reason to use it; nothing to broadcast to players, or features to kill, but I feel like in the case of reloads, I need to use it to make sure there aren't resource leaks, etc. Is this a legitimate concern? If so, what sort of things should I watch out for? Or is it more of a convenient way of broadcasting plugin shutdown and closing features? Or perhaps both?
     
  2. Offline

    flaaghara

    Memory leaks shouldn't really be a problem because of garbage collection. The main purpose of having that method is to store persistent data that a plugin might need when it's restarted, like locations of players, blocks, etc.
     
  3. Offline

    bdubz4552

    flaaghara Alright, thanks for the clarification!
     
  4. bdubz4552 Another use I've seen for it is for delayed tasks. Sometimes, if you've scheduled some delayed tasks, you might want to execute some (or all) of those before the plugin shuts down, if possible. :)
     
  5. Offline

    AronTheGamer

    Code:java
    1. saveConfig();
     
Thread Status:
Not open for further replies.

Share This Page