Help making one delay!

Discussion in 'Plugin Development' started by digitox, Apr 16, 2017.

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

    digitox

    I have this problem where i need a 5 second delay between 3/4 titles.
    Code:
    p.sendTitle(ChatColor.translateAlternateColorCodes('&', ""),ChatColor.translateAlternateColorCodes('&', ""));
    
    p.sendTitle(ChatColor.translateAlternateColorCodes('&', ""),ChatColor.translateAlternateColorCodes('&', ""));
    
    p.sendTitle(ChatColor.translateAlternateColorCodes('&', ""),ChatColor.translateAlternateColorCodes('&', ""));
    
    p.sendTitle(ChatColor.translateAlternateColorCodes('&', ""),ChatColor.translateAlternateColorCodes('&', ""));
    
    i need to make a 5 sec delay between dose titles.

    can someone help me?
     
  2. Offline

    Caedus

    Use bukkit scheduler to schedule a synchronous task.
     
  3. Offline

    GRocksMc

    @digitox

    You would need to do something along the lines of:

    Code:java
    1.  
    2. Bukkit.getScheduler().scheduleSyncDelayedTask(main /*your plugin*/, new Runnable(){
    3. public void run(){
    4. //whatever you want it to do
    5. }
    6. }, 20 /*delay in ticks (20 ticks = 1 second)*/);
    7.  


    Just do several of those, using increments of 100 ticks each time to separate them by 5 seconds.
     
  4. new BukkitRunable() {
    public void run() {
    //code here
    }
    }.runTaskLater(SomeParametersHere)


    Verzonden vanaf mijn iPhone met Tapatalk
     
  5. Offline

    digitox

    Can you please make me an example because i don't know what you mean?
     
  6. Offline

    Zombie_Striker

    @digitox
    That is exactly what they posted. Use the bukkit runnable, add your code inside of the run method, and provide the instance of your main plugin along with the delay in ticks.
     
  7. Offline

    digitox

    Yeah but how do i get multiple like. first the fist title comes then the other etc.
     
  8. Offline

    Zombie_Striker

    @digitox
    For each new title, increase the delay of the task.
     
Thread Status:
Not open for further replies.

Share This Page