How make a pause

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

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

    4z3rty

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

    4z3rty

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

    Jogy34

    You could cancel the PlayerMoveEvent for everyone
     
  3. Offline

    4z3rty

    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 :
    Code:
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    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!
    http://wiki.bukkit.org/Scheduler_Programming
     
    Everdras likes this.
  5. Offline

    4z3rty

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

    desht

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

    LexLaiden

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

    Code:
    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

    FTWin01Gurl

    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

    LexLaiden

    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

    FTWin01Gurl

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

    4z3rty

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

    Thank all !
     
  12. Offline

    4z3rty

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

    r0306

    4z3rty
    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