Countdown Timer | Help

Status
This thread has been locked.

Hoppys

Supreme
Feedback score
0
Posts
725
Reactions
250
Resources
0
So i'm making a plugin and i'm a bit rusty with countdowns.. i've looked through tutorials but they're not what i'm looking for, i just need a countdown so when i do /dp start it will come up with a title saying "Teleporting in (Time)" then once it gets to 0 it will obviously teleport them. here is a bit of code that i tried with..



That's not the full .Java it's a snippet of all the countdowns that are involved.
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

Kek123

Feedback score
1
Posts
61
Reactions
34
Resources
0
A lot simpler than you think :p

One method:

Code:
            new BukkitRunnable() {

                int time = 5;

                public void run() {

                    if (time == 0) {

                        player.teleport(location);
                        Bukkit.getServer().broadcastMessage("Teleported!");
                        this.cancel();

                    }

                    else {
                        Bukkit.getServer().broadcastMessage("Teleporting in " + time);
                        time--;

                    }

                }
            }.runTaskTimer(plugin, 0, 20);


Read up on this for more info: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/scheduler/BukkitRunnable.html
 
Last edited:

Hoppys

Supreme
Feedback score
0
Posts
725
Reactions
250
Resources
0
Status
This thread has been locked.
Top