Using the bukkit tick system?

Discussion in 'Plugin Development' started by ThatBox, Dec 19, 2011.

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

    ThatBox

    How would i use it ? And how many ticks are a minute?
     
  2. Ill outline some key things:
    * Each task has a taskId. Its just a int, nothing special, but if you have to cancel a task you should save its id.
    * Async vs. Sync. Sync means it runs on the main thread, Async means it doesnt. THIS IS IMPORTANT because most Bukkit methods arent threadsafe, meaning you should use them syncly...(is that a word?)
    * 20 ticks = 1 second, but that is not always true. The more lag on the server, the longer 20 ticks takes. This is generally 0.2 seconds off (on my server), so if you need exact precision use the java timer
    To register a task, it looks something like this (note this is a sync task)
    Code:java
    1.  
    2. int id = Bukkit.getScheduler().scheduleSyncTask(pluginInstance, new Runnable() { public void run() {System.out.println("1 min!"); } },60 * 20);
    3.  

    Every minute that will print out "1 min!" to the console :)
    Sorry for mistakes, im on my iphone after exams :D
     
    gogobebe2 likes this.
  3. Offline

    ThatBox

    Thanks tips :D
     
  4. Offline

    croxis

    I think he means most your threads should be sync threads, not async.
     
  5. Oh, duh...Lemme edit that asap
    @ThatBox Most threads should be SYNC, not async
     
    gogobebe2 likes this.
Thread Status:
Not open for further replies.

Share This Page