X-Clearlag API Documentation v1.6
Welcome to the X-Clearlag developer API. This documentation will help you integrate your own plugins with our cleanup engine, or even extend its functionality using our custom Event API.
π¦ Getting Started
To use the API, ensure you have X-Clearlag installed on your server. You can access the API entry point via the XClearlagAPI class.
import com.fabian.xclearlag.api.XClearlagAPI;
XClearlagAPI api = XClearlagAPI.getInstance();π Common Operations
1. Trigger a Cleanup Programmatically
You can trigger any task defined in the config.yml manually via the API.
api.triggerCleanup("items-task", player, (removed) -> {
player.sendMessage("Cleanup finished! Removed " + removed + " entities.");
});2. Get Real-time TPS
Get the serverβs current Ticks Per Second (TPS) as measured by our high-precision monitor.
double tps = api.getTPS();
System.out.println("Current Server Load: " + tps);π Custom Event API
X-Clearlag fires custom events through the standard Bukkit Event Bus. You can listen to them like any other event.
XPreClearEvent
Fired before the discovery phase begins.
[!TIP] This event is Cancellable. You can use it to prevent a cleanup from running under specific conditions.
@EventHandler
public void onPreClear(XPreClearEvent event) {
String taskName = event.getTaskName();
if (taskName.equals("critical-mobs")) {
event.setCancelled(true); // Stop this specific cleanup
}
}XPostClearEvent
Fired after the entities have been removed from the world.
@EventHandler
public void onPostClear(XPostClearEvent event) {
int removed = event.getEntitiesRemoved();
Bukkit.broadcastMessage("X-Clearlag cleared " + removed + " entities!");
}π§© PlaceholderAPI Support
If you have PlaceholderAPI installed, you can use these tags anywhere:
%xclearlag_tps%β Current server TPS.%xclearlag_total_removed%β Historical total of removed entities.%xclearlag_next_clear_<task>%β Seconds until the next run of a specific task.
π οΈ Maven / Dependency
Currently, you should just depend on the JAR or the projectβs artifact if you are building in the same workspace.
[!IMPORTANT] X-Clearlag v1.6 is Universal and Folia-Ready. The API works exactly the same on Spigot, Paper, and Folia.