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 !
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.
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);
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.
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
Excuse for my late reply, but I review my BAC ^^ I have tested the code of LexLaiden and it work ! Thank all !
4z3rty If the variable is inside a method, make it a final. Otherwise, you can also access class variables from the run().