Hello i'm new at creating a plugin but i want to do a game with a countdown before launch it and when the countdown is finish that start a game is that possible ? Like this : //code start countdown while(countdown.isFinish==flase){ continue countdown } delete countdown start the game //code
Definitly not like this. The server will probably crash when the countdown is too long because it blocks the main thread Use a delayed task instead like this Set countdown new BukkitRunnable () -> { (not valid code) start game }.runTaskLater(countdownTime); More information and better examples: https://bukkit.fandom.com/wiki/Scheduler_Programming
It would be much easier to make a synchronous task timer, which runs the code every second as it decreases the countdown variable. There are more things you could add, such as utilizing "this.cancel();" to stop the timer if a player leaves, for example. Code: new BukkitRunnable() { int i = 10; public void run() { if (i > 0) Bukkit.broadcastMessage("§bGame starts in " + i + " seconds!"); else startGame() //your method to start the game here i = i - 1; } }.runTaskTimer(plugin, 0, 20l)