Mineuniverse
Plugins

CountdownLib

PLUGIN
Simple library for timer countdowns
by _ForgeUser9142288
Download Claim this project
3,134 downloads
0 likes
Updated Oct 14, 2026
0 hypes
Developer Tools
Advertisement Remove ads with Premium →

A simple library for easily creating countdowns and cooldowns

A really simple(And I mean really simple :)) plugin that allows developers to create easy countdowns and cooldowns using Event's when the countdown ticks and ends. The source might help if you are using an IDE for intellisense and info.

Implementation

To create a countdown and get its UUID.

public void startCountdown(long time, long interval, boolean intervalToSeconds){
    Countdown c = new Countdown(time, interval, intervalToSeconds, plugin);
    someVariable = c.start(); //or if you want to set the UUID variable on another line use someVariable = c.getID();
}

The time is the amount of countdown ticks before the countdown ends and the interval is the time between the ticks.

To listen to when a countdown ticks.

@EventHandler
public void onCountdownTickEvent(CountdownTickEvent event){
    //do something
}

And to listen when a countdown ends(finishes counting down)

@EventHandler
public void onCountdownEndEvent(CountdownEndEvent event){
    //do something
}

Possible idea of implementation would be to store a hashmap.

HashMap<String, UUID> names = new HashMap<String, UUID>();

So then you can assign names to UUIDs just for your plugin :).

v3 now includes fully automatic command cooldowns! Example:

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
	if(label.equalsIgnoreCase("foobar")){
		sender.sendMessage("foobar");
                //the 10 int is the number of seconds the cooldown lasts
		CommandCooldown ccd = new CommandCooldown(10, label, sender.getName());
		return true;
	}
}

This will mean that the command will work the first time for the user but then they have to wait until the cooldown has ended before they can use it again.

Things to note: This is only good if your cooldown is going to be a matter of seconds or minutes, or if the server is very unlikely to go down during a cooldown because it will reset when the server shuts down. If a player executes a command and a cooldown is still running for that player it will give them a default message(quite a sexy one), if you want to add your own messages there is an extra constructor argument on the overloaded constructor(sorry for lack of commenting on the constructors but look at the source and you will see what I mean) that allows you to change the message(please use %d where you wan't the number of seconds left or don't if you wan't a plain generic message).

TODO

Nothing ATM

ChangeLog

v2. Added UUID checking instead of naming the countdowns(to avoid confusion between plugins(If you are going to employ your own name system i strongly suggest you match name to UUID)).

v3. Added time modification.

v.3. Added CommandCooldown class for super sexy automatic command cooldowns ;).

v.3. Fixed null UUID on CountdownTickEvent's.

v.4. Added command to execute a command after a period of seconds /Countdown <Seconds> <Command> [Arguments...].

v4. Added static method in CommandCountdown class to execute a command after a period of seconds.

Commands

1. /Countdown <Seconds> <Command> [Arguments] count's down a number of seconds and then executes a command.

Permissions

1. cdl.countdown for the /Countdown command.

Github source

https://github.com/tommycake51/CountdownLib/

CountdownLib v4 for CB 1.6.4-R0.1-20130920.192319-3
MC 1.6.4
Release 2013-10-15 Get
CountdownLib v3 for CB 1.6.4-R0.1-20130920.192319-3
MC 1.6.4
Release 2013-10-04 Get
CountdownLib v2 for CB 1.6.2-R0.1
MC CB 1.6.2-R0.1
Release 2013-09-04 Get
CountdownLib v1 for CB 1.6.2-R0.1
MC CB 1.6.2-R0.1
Release 2013-09-03 Get

More from _ForgeUser9142288

Advertisement Remove ads with Premium →

You Might Also Like