1.8.8 MOTD How To Delay A MOTD Message?

Discussion in 'Spigot Plugin Development' started by StabMePlease, Jan 24, 2020.

  1. I need the "Hey" to show up after all of the other messages. Any ideas? :)
    upload_2020-1-24_14-15-16.png
    Code (Text):
    package me.stabmeplease.darksocials;

    import org.bukkit.ChatColor;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;

    public class EventsClass implements Listener {

        @EventHandler
        public void onJoin(PlayerJoinEvent event) {

            Player player = event.getPlayer();

            player.sendMessage(ChatColor.DARK_PURPLE + "Hello");
        }
    }
     
     
  2. Normally you would put your code in a BukkitRunnable and execute it one or two ticks after the event happens.
     
  3. Hey! I know you're probably busy but if you have some time could you give me an example on how to do that?
     
  4. Bukkit Wiki has a great article on that:
    https://bukkit.gamepedia.com/Scheduler_Programming#Anonymous_BukkitRunnable_Example
    As far as I know most people use anonymous runnables like that for small tasks like sending a message. You'd just replace the number 20 at the end there with the number of ticks you want to wait before running it. Remember 1 second is usually about 20 ticks.
     
    • Like Like x 1