Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BukkitScheduler scheduler = Bukkit.getServer().getScheduler(); //Bukkit Scheduler
- int countDownTimer=0; //the BukkitScheduler task id
- MyPlugin plugin; //the instance of your plugin
- int time=60; //your time in seconds
- int maxTime=60;
- void countDown(final String world) { // the name of your world
- countDownTimer = scheduler.scheduleSyncRepeatingTask(plugin,
- new Runnable() {
- public void run() {
- // set the Bar
- float f = time;
- float percentage = (100 * (f / maxTime));
- for (Player pl : Bukkit.getWorld(world).getPlayers())
- BarAPI.setMessage(pl, "Game starts in " + time, percentage);
- if (time <= 5) {
- // You can add a "Click" sound here
- }
- // when gets to 0
- if (time <= 0) {
- scheduler.cancelTask(countDownTimer);
- for (Player pl : Bukkit.getWorld(world).getPlayers())
- BarAPI.removeBar(pl);
- startGame(); // call your desired method
- }
- time--;
- }
- }, 20, 20);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement