Solved Deprecated Async Task?

Discussion in 'Plugin Development' started by Nitnelave, Dec 20, 2012.

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

    Nitnelave

    Hello everyone!
    I'm using async tasks in my plugin to do some minor data cleanup, but the bukkit's scheduler's scheduleAsyncDelayedTask has become deprecated with the API change. They didn't say what we should use, though, and I didn't see anything useful.
    I have seen the warning about async tasks, but I still deem them necessary, so how should I go about using them?

    Thanks!
    nitnelave

    EDIT: Oh, is it the runTaskLaterAsynchronously?
     
  2. Offline

    Sagacious_Zed Bukkit Docs

  3. Offline

    chaseoes

    Example?
    It does not take the same arguments as scheduleAsyncDelayedTask did. :|
     
  4. Offline

    EnvisionRed

    Look at the github. There are specialized ones for async, delayed, and repeating
     
  5. Offline

    Sagacious_Zed Bukkit Docs

    Look at the javadocs, im not going to explain every variant of runTask* here
     
  6. Offline

    Ne0nx3r0

    I'll be slightly less of a prick for future readers since I ended up here via Googling...

    Code:
    Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
        @Override
        public void run() {
            //Your async code here
        }
    }, 20*30);
    
    Source

    *edit* updating code
     
    A5H73Y, ndvenckus1, jjacobson and 2 others like this.
  7. Offline

    chaseoes

    That gives me this:
     
  8. Offline

    Ne0nx3r0

    Sorry, remove the second number.

    My IDE is messed up right now so I'm working in notepad++.
     
    fireblast709 likes this.
  9. Offline

    Tirelessly

    That's not even right, if you're running it asynchronously then it's not on the main thread. BroadcastMessage is also not thread safe.
     
  10. Offline

    chaseoes

    Oh.. should have seen that myself.. :p
    I thought it was a problem with the runnable I was giving it.
     
  11. Offline

    Ne0nx3r0

    Everyone's a critic... My apologies, I copied the runnable from another example. I'll update the code accordingly.
     
  12. Offline

    Feaelin

    Thanks Ne0nx3r0, this answered the question I was browsing the web for as well. I needed the ...Timer... version, but your example was sufficient for me to find what I needed in the API.
     
Thread Status:
Not open for further replies.

Share This Page