DevCountdown: Lightweight Timer API for Minecraft Plugins

DevCountdown is a lightweight API for Minecraft that simplifies countdown timers in plugins. Build minigames, cooldowns, and custom mechanics without Bukkit scheduler hassle.

DevCountdown: Lightweight Countdown API for Minecraft Plugins

If you have ever built a custom game mode or a unique mechanic for a Minecraft server, you know the drill. You need a countdown for the race start, a delay before that explosive surprise, or a timer to cycle through biomes. Without solid time control, your plugin quickly turns into a tangled mess of scheduled tasks and thread-safety headaches. Writing a scheduler from scratch, wrestling with Bukkit tasks, and keeping everything synchronized is a pain, especially when you are just getting started.

That is exactly where DevCountdown: Lightweight Countdown API for Minecraft Plugins steps in. It is not a ready-to-use plugin with a simple /countdown command. Instead, it is a developer-focused library that handles the grunt work for you. Think of it as a clean layer between your code and the server's tick system. With just a few lines, you get a fully functional countdown with all the events you need: start, every tick, cancel, and completion. This approach speeds up development and keeps your codebase tidy, which is a huge win when you are juggling complex mods or server packs.

Getting Started with the API

The first step is straightforward. Head over to the release page and grab the JAR file. The direct download is available without any annoying registrations. Once you have the file, add it to your project's Build Path, just like you did with the Bukkit API when you created your first plugin. In Eclipse, this means right-clicking your project, selecting "Configure Build Path," and adding the external JAR. After that, all the API classes are ready for import.

While you are setting up your development environment, it is worth noting that testing your server-side mechanics often requires a solid client setup. A modern launcher can help you quickly assemble a client build for testing, pulling the right versions and mods directly from its menu, saving you from manual file juggling. This way, you can focus on what matters: writing the code.

Building Your First Countdown

The API is built around an abstract class called Countdown, which you extend with your own logic. Here is the minimal skeleton you will drop into a new class in your plugin:

package your.package;

import io.github.fourohfour.devcountdown.Countdown;
import io.github.fourohfour.devcountdown.Tick;

public class CustomCountdown extends Countdown {
    protected void onRun(int count, int factor) {
        // Code executed at the start
    }

    protected void onCancel() {
        // Code when the countdown is cancelled
    }

    protected void onTick(Tick t) {
        // Called on each "tick" of the timer
    }

    protected void onEnd() {
        // Final action
    }
}

Each method serves a specific purpose. onRun fires once when the countdown starts. This is the perfect spot to give players potion effects or lock down redstone contraptions. onTick is called at every step of the timer. Keep in mind, this is not the server tick (which runs 20 times per second); it is a step you define yourself using the factor parameter. onCancel lets you roll back any changes if the countdown is interrupted. Finally, onEnd triggers when time runs out, ideal for teleporting a winner or spawning mobs.

Launching and Controlling the Timer

To start the countdown, create an instance of your class and call the run method:

CustomCountdown c = new CustomCountdown();
c.run(10, 20, this);

The first argument is the duration in your chosen units. The second is the number of server ticks per unit (20 equals one second). The third parameter is a reference to your plugin, so the API knows who owns the timer. In version 0.2, handy constants were added. You can now write c.run(10, ServerTime.SECOND, this); or use MINUTE, HOUR, and DAY to make your code far more readable.

Cancelling a running countdown is just as easy. A simple call to c.cancel(); stops everything. This is useful when a player leaves a mini-game or an unexpected event occurs. The onCancel method will fire, allowing you to clean up temporary data properly.

Advanced Features: Ticks and Plugin Passing

The onTick method receives a Tick object packed with useful tools. getTickID() returns the current step number. For example, if three seconds remain, the ID will be three. The isMilestone(int[]) method checks if the current tick is a multiple of any of the numbers you pass in. This makes it trivial to send messages at 5, 10, and 15 seconds without building a wall of conditional statements.

What if you need to start a countdown from a different class, not the main plugin class? Simply pass the plugin instance through a constructor:

private Plugin plugin;

public YourSecondClass(Plugin p) {
    this.plugin = p;
}

Then, in the onEnable of your main class, call new YourSecondClass(this);. Inside that second class, you can now use c.run(10, 20, this.plugin);. This is a standard pattern for Bukkit plugins, helping you separate responsibilities across modules cleanly.

Why DevCountdown Simplifies Server Development

The core value of this API lies in how it hides the complexity of Bukkit's scheduler and shields you from common beginner mistakes. You no longer need to manually count ticks, worry about memory leaks, or keep track of stopping repeating tasks. All of that is already implemented inside the library. Your only job is to fill the methods with your own logic.

This approach shines in mini-games. A starting countdown in BedWars, an ability cooldown timer in KitPvP, or a tree growth phase in custom biomes can all be done in a dozen lines of code. The source code for DevCountdown is open and available on GitHub, so you can always dig into the internals or suggest improvements. If you need additional time constants, like a week or a redstone tick, the author welcomes feedback in the release comments.

In the end, DevCountdown: Lightweight Countdown API for Minecraft Plugins is a small but mighty tool that saves hours of development time and makes your plugins more stable. It is perfect for beginners just learning to create mods and server builds, as well as for seasoned developers who value clean code. Whether you are looking to download DevCountdown: Lightweight Countdown API for Minecraft Plugins for your next project or simply exploring options, this library is worth a try. It supports a range of Minecraft versions and integrates seamlessly with your existing Bukkit setup. If you are wondering how to install it, the process is as simple as adding a JAR to your classpath. Give it a shot, and you will notice how much easier time management becomes in the world of Minecraft. For those searching for DevCountdown: Lightweight Countdown API for Minecraft Plugins for Minecraft, this is the solution you have been looking for.

Try it in your next project, and you will see just how much simpler managing time in Minecraft can be.

Download DevCountdown for Minecraft 1.6.4

Original name: DevCountdown

Minecraft: 1.6.4

FileVersionLoaderSize
DevCountdown.jar1.6.44 КБDownload