Hi, how to do a simple timer? (countdown) Yes i know with bukkit Scheduler...But how? But i search about 4 Hours and found nothing... It should look like this: Code: System.out.println(Wait 30 Sekonds); timer(30); System.out.println(Finished!); Greetz -michidk
Code:java System.out.println("Wait 30 Sekonds");this.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() { public void run() { System.out.println("Finished!"); }}, 600L); // (30 seconds * 20 ticks/second = 600)
Coryf88 The Problem is, iam in the Playerlistner. If i use it it looks like this: (eclipse says it must look like this) Code:java Bukkit.getServer().getScheduler().scheduleSyncDelayedTask((Plugin) this, new Runnable() {public void run() {System.out.println("Finished!");}}, 600L); // (30 seconds * 20 ticks/second = 600) But this make that error: Code: [SEVERE] Could not pass event PlayerCommandPreprocessEvent to myplugin org.bukkit.event.EventException anyone a Idea?? EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Why do you cast 'this' to plugin? When you're in the main class you don't need it, otherwise you'll need the instance of your main. Also, please provide THE WHOLE stacktrace
It isnt in the Main Class.. But now it works: Code:java Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() { public void run() { System.out.println("Finished!"); } }, 600L); // (30 seconds * 20 ticks/second = 600) My fail was there: public class playerListener implements Listener, And so it Works: public class playerListener implements Listener, Plugin
But that's not what you want to do. You don't want to create a 'separate plugin', hence you should use the instance of your main class.