How make a pause

Discussion in 'Plugin Development' started by 4z3rty, Jun 15, 2012.

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


    For my plugin, I have need make a pause ; expect to avoid kill the player ;)
    How make ?


    Escuse me for my spelling, I'm french !
  2. Offline


    You could cancel the PlayerMoveEvent for everyone
  3. Offline


    I generate several blocks and if I do not give the player time to leave, he was run over ...

    I have find the solution, use JAVA :
    try {
    } catch (InterruptedException e1) {
        // TODO Auto-generated catch block
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 26, 2016
  4. Never put the main thread to sleep!
    Everdras likes this.
  5. Offline


    Ok... but how can I make ?
  6. Offline


    V10lator already told you - use the scheduler. Hint #2: use a sync delayed task.
  7. Offline


    Put this in your code wher you want to set a pause

    myPlugin.getServer().getScheduler().scheduleSyncDelayedTask(myPlugin, new Runnable() {
      public void run() {
          //Put your code you want run after the pause in here
          // and change the 60L to the pause needed. (sec*20)
    }, 60L);
  8. Offline


    You're assuming you want to make everything paused if I recall. You will have to use a Sync instead of forcing a thread to sleep. However, I do not recommend PlayerMoveEvent because of the massacre of lag it can cause. Think about 100+ players online. Someone dies. It triggers the method. 99 players are immobile for x seconds. This will not only cause lag, but rage among players.

    I'm not saying this is a bad plugin idea, it's just the way you're trying to make it is unstable.
  9. Offline


    He don't want to pause the whole server, he wants to delay doing somthing so the player can run and get out of the way. so use scheduleSyncDelayedTask
  10. Offline


    I'd get the player attacking him... then freeze him. Pardon my misunderstanding.
  11. Offline


    Excuse for my late reply, but I review my BAC ^^
    I have tested the code of LexLaiden and it work !

    Thank all !
  12. Offline


    I want to use a variable that has been said before in my run().
    How make ?
  13. Offline


    If the variable is inside a method, make it a final. Otherwise, you can also access class variables from the run().
Thread Status:
Not open for further replies.

Share This Page