Problem with the scheduleAsyncRepeatingTask!!!

Discussion in 'Spigot Plugin Development' started by OfirTIM, May 18, 2015.

  1. hey guys... today i am coming with another problem at Plugin Development... soo i am making Minigame plugin... and i am Kinda stuck... because i started to work about if player leave or if there are not enough players its will cancel the task.... and its kinda does'nt works pretty well...
    Pastebin:

    http://pastebin.com/i6gsv1Es

    i am kinda think i need to put:


    @SuppressWarnings("deprecation")
    public void onPlayerQuit(PlayerQuitEvent e){
    if(Bukkit.getOnlinePlayers().length == 2){
    gamestart();
    }
    }

    is it right? tell me at the Replys!

    Thanks for answers!

    Regards, OfirTIM!
     
  2. That's just an idea.
    Try and add Statuses to your arena. something like "JOINABLE, INGAME, STARTING"
    make the default status "JOINABLE" and check every time if there are enough players or not and if there are, change the status to starting, then check if its starting and start the scheduler task, but if there aren't enough players, return the status.
     
  3. What do you intend to do? If you want to start the scheduler again if there are enough users, listen to the PlayerJoinEvent and call gamestart() if there are two players online.

    On a side note: use runTaskTimer rather than scheduleAsyncRepeatingTask (as it's deprecated, and there's no need for asynchronous tasks)
     
    • Agree Agree x 1