Add 60 tick delay between sending list of hard coded messages????

Discussion in 'Plugin Development' started by ice374, Dec 1, 2013.

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

    ice374

    So, I am having trouble thinking up how to make a delay in between sending a user messages, It would be cool if i could just keep calling the task will different string, and it adds those strings to a list of strings to play when it gets to it (after playing all the messages, and all the 30tick breaks before it).
    I CANNOT use Thread.sleep(); , that will stop the whole plugin :/
    Here is the method that I am using, but I am failing pretty hard, and cant think of a way to make it work properly, ALL help is greatly appreciated :)
    publicstaticvoid speakBegin(finalPlayer p){finalint messageNumber =0;String string1 ="Hey, user! this is message 1!";//30 tick breakString string2 ="msg 2";//30 tick breakString string3 ="msg 3";//30 tick breakString string4 ="msg 4";//30 tick breakString string5 ="msg 5";//30 tick breakString string6 ="msg 6";//30 tick breakString string7 ="msg 7";//30 tick breakString string8 ="msg 8";//30 tick breakString string9 ="msg 9";//30 tick breakString string10 ="this is the final message, user!";//30 tick breakfinalint id = plugin.getServer().getScheduler().runTaskTimer(plugin,newRunnable(){publicvoid run(){//Send user string1, then wait 60 ticks and send string2, ect. ect./* * eg: * p.sendMessage(string + messageNumber); * * <-----I dont know how to do this bit so it plays string1, * then wait, add int to messageNumber, * then play string2 because 'string' + messageNumber would equal 'string2' * *///messageNumber++; ?//after string10 is played call "plugin.getScheduler().cancelTasks(plugin);"}//this just waits 20ticks in beginning, then waits 60 tick between messages},20L,60L).getTaskId();}
     
  2. Offline

    Commander9292

    ice374
    The hell is that giant block of code? Why don't you paste it in as code instead of a giant block of text? It's impossible to read

    Oh and the answer to your question is just to create a repeating task and have it countdown and when it hits 0 have it send another message.
     
  3. Offline

    ice374

    oops, copied my question from stackoverflow, apparntly bukkit .org doesnt support that formatting
     
  4. Offline

    Commander9292

    ice374
    Haha, no problem. Just wondering why you pasted it like that.
     
Thread Status:
Not open for further replies.

Share This Page