# Changelogs:
### Added:
- **Dry-Run for clears.** `/clearlag clear <items/entity/all> --preview` shows what a clear would remove without removing anything. You get the total, split into items and entities, a ranking of the most common types and a breakdown per world. It uses the exact same rules as a real clear, so exclusions, plugin hooks, WorldGuard regions, death-item protection, mob stacking and per-world profiles all behave identically. `--dry-run` and `-p` work as well.
- **New permission** `clearlag.preview` lets staff run the preview without giving them the right to actually clear.
- **Skip-If-Empty.** New option `auto-clear.skip-if-empty`. When there is nothing worth clearing, the countdown broadcasts and the clear itself are skipped. No more "Clearing in 60 seconds..." followed by "0 entities have been removed" on a quiet server. You can set how many entities count as worthwhile (`min-entities`) and skip the countdown and the clear independently.
- **Villager / AI Throttle.** New section `villager-optimization`. Turns off the AI of villagers while no player is within the configured radius, and turns it back on the moment somebody comes close, right-clicks the villager or hits it. Villagers are the most expensive vanilla mob to tick, and since they must never be removed, this is the only way to get that time back. Other pathfinding-heavy mob types can be added to the list. Frozen mobs are tracked and always restored on enable, reload and shutdown, so nothing stays frozen. Mobs that were disabled by an operator or another plugin are never touched.
Note: while frozen, a villager does not restock trades and does not walk to its bed, so keep the radius large enough for your trading halls.
- **Anti-Crash Item Limits.** New section `anti-crash-items`. Blocks items with metadata large enough to crash a client or stall the server: oversized display names, huge amounts of lore, extreme enchantment levels, books with absurd page counts or page lengths, shulker boxes nested inside each other, and items whose total data size is far beyond anything legitimate. Checked when an item is dropped, renamed in an anvil, or signed as a book. Three modes: `strip` (trim and keep the item), `cancel` (block it) and `log-only` (only report, change nothing) so you can see what your server would catch before enforcing anything. Staff with `clearlag.anticrash.alert` get notified, rate-limited.
- **Performance History.** New section `metrics-history` plus the command `/clearlag history <30m/24h/7d>`. TPS, MSPT, CPU, RAM, entity, item, chunk and player counts are written to a local database and kept for a configurable number of days. The command shows averages, lowest TPS, peaks, the worst period in the window and a coloured trend line, so "was the server laggy last night?" can finally be answered. New permission `clearlag.history`.
The database driver is downloaded by the server automatically. If that fails, only this one feature switches itself off with a warning.
### Fixed:
- Chunk scans no longer freeze the server for a moment. `/clearlag chunkfinder` and the Auto-Unload task used to walk every loaded chunk within a single tick, which on a large server caused exactly the lag spike Auto-Unload is meant to prevent. The scan is now spread over several ticks with a configurable budget (new section `chunk-scan`). Set `chunk-scan.time-sliced: false` to get the old behaviour back.
- `/clearlag chunkfinder` now also shows how many items and how many mobs are in each chunk, so you can tell at a glance whether a hot chunk is a dropped-item pile or a mob farm.
- `/clearlag clear` with an invalid type now shows the correct usage instead of silently doing nothing and reporting "0 entities removed".
### Removed:
- Nothing removed in this version.
Developer information
Projects on Modrinth are automatically available through a Maven repository for use with JVM build tools such as Gradle.
maven { name = "Modrinth"; url = "https://api.modrinth.com/maven" }