Solved Delay command

Discussion in 'Spigot Plugin Development' started by Havooc, Jan 27, 2020.

  1. Hi,
    I am trying to make /spawn and /tpa command, but I have problem, because I have no idea how to make delay after using command, it should works like this:
    - player type /spawn or /tp on chat;
    - print message with info, that player cannot move for 3 seconds if he want to teleport;
    - if player didnt move, teleport him.
    Can some1 explain me how to make this delay?
     
    #1 Havooc, Jan 27, 2020
    Last edited: Jan 27, 2020
  2. drives_a_ford

    Moderator

    • Useful Useful x 1
  3. If you are using essentials, this is configurable using it.
     
  4. One way (the way I have used in the past) is to schedule a delayed task along with a movement listener. Some pseudo for you:

    - If the player is currently waiting / in the warmup then listen for movements
    - If the player moves, cancel the delayed task
     
    • Useful Useful x 1
  5. And this is the development thread, not configuration thread.
     
  6. Iam not.
     
  7. Then which plugin are you using for /tpa and /spawn
     
  8. Im making plugin that contains /tp and /spawn command, I had just problem with delaying this.
     
  9. You can, for example, send a message to a player, you will be teleported after.
    create a new Bukkit task which will run after 3 seconds, teleporting him, and save the task's id in some map for example
    and create a move event listener which will stop the task if a player moves.
     
    • Useful Useful x 1
  10. Thanks for help!

    Ok, thanks