title: Iterating through text with a different length delay between them
body: <ul>
  <li><p>Bukkit / Spigot API - <a href="https://hub.spigotmc.org/javadocs/spigot/" rel="nofollow">https://hub.spigotmc.org/javadocs/spigot/</a><br>
  Okay, I'm trying to make a tutorial system for my server. I've often seen people displaying text like this:</p>
  
  <pre><code>public void send(String...strings) {
      for (String string : strings) {
          player.sendMessage(string);
      }
  }
  </code></pre>
  
  <p>.. which is terrible. As you know, it'd spam the chat and make it un-readable.<br>
  So instead, I'm using runnables to display the text in a certain delay. I could easily make a runnable with the same specific delay (i.e 30 ticks), but I'd love the runnable to have the delay based on the length() of the String. </p>
  
  <p>I tried to do it like this:</p>
  
  <pre><code>public void send(String...strings) {
      for (String string : strings) {
          new BukkitRunnable() {
              @Override
              public void run() {
                  player.sendMessage(string);
              }
          }.runTaskLater(my_plugin_instance, (string.length()*2));
      }
  }
  </code></pre>
  
  <p>With this, yes, it takes the lenght of the string, but the <code>for loop</code> continues to the next String before the runnable has displayed the text.<br>
  So If I had these sentences for example (in the correct order):</p>
  
  <ul>
  <li><code>Welcome to the server, player!</code></li>
  <li><code>This server is about blablabla, this and that and a bit more of that and this</code> </li>
  <li><code>Accept the tutorial?</code></li>
  </ul>
  
  <p><br/>
  The order will be  </p>
  
  <ul>
  <li><code>Accept the tutorial?</code></li>
  <li><code>Welcome to the server, player!</code></li>
  <li><code>This server is about blablabla, this and that and a bit more of that and this</code>
  <br/> <br/></li>
  </ul>
  
  <p>What should I do?</p></li>
  </ul>