Create a NEW Minecraft Plugin — DNGRClearLag
Create a completely new Minecraft Paper plugin from scratch named:
DNGRClearLag
Do NOT reference, copy, modify, depend on, or mention any previous plugin, old JAR, old source code, or previous implementation. This is a completely fresh project.
Platform
- Minecraft: Paper 1.21.11+
- Java: 21
- Plugin name: "DNGRClearLag"
- Main class: "com.dngr.clearlag.DNGRClearLag"
- No external plugin dependencies.
- Do not require Vault.
- Do not require PlaceholderAPI.
- Use Paper/Bukkit APIs only.
- Plugin must compile cleanly with Java 21.
---
- HEX COLOR SUPPORT
Create one central color utility.
Support both:
&#RRGGBB
and normal:
&0-&9 &a-&f
Example:
�FFAAHello &7Player
must display with the correct HEX color.
All configurable messages throughout the plugin must support HEX colors.
---
- AUTOMATIC DROPPED ITEM CLEANUP
Create automatic dropped-item cleanup.
Config:
items: enabled: true
clear-interval: 300
countdown: enabled: true times: - 60 - 30 - 10 - 3 - 2 - 1
actionbar: "&7ᴄʟᴇᴀʀɪɴɢ ɪɴ &b{time}s" sound: "BLOCK_NOTE_BLOCK_PLING"
clear: message: "&7ʀᴇᴍᴏᴠᴇᴅ &b{amount} &7ɪᴛᴇᴍs" sound: "ENTITY_GENERIC_EXPLODE"
whitelist: - DIAMOND - EMERALD - NETHERITE_INGOT - NETHERITE_SCRAP - ANCIENT_DEBRIS - ENCHANTED_GOLDEN_APPLE - TOTEM_OF_UNDYING - ELYTRA - SHULKER_BOX
Requirements:
- "clear-interval" is in seconds.
- Example: "300" = 5 minutes.
- Only remove dropped Item entities from the world.
- NEVER remove items from:
- player inventories - chests - shulkers - hoppers - barrels - furnaces - any other storage
- Never remove whitelisted item types.
- Countdown must use the configured times.
- "{time}" must be replaced with the remaining seconds.
- "{amount}" must show how many dropped items were removed.
- Play the configured sound.
- Do not perform expensive global scans every tick.
- Cleanup should be optimized for servers with 50+ players.
---
- PER-CHUNK ENTITY LIMITER
Create a configurable per-chunk entity limiter.
Config:
entities: enabled: false
check-interval: 10
limits:
VILLAGER: 10 COW: 20 SHEEP: 20 PIG: 20 CHICKEN: 25 ZOMBIE: 50 SKELETON: 50 CREEPER: 30 SPIDER: 40 ENDERMAN: 20
message: "&cRemoved extra entities in chunk to reduce lag!" sound: "ENTITY_ITEM_PICKUP"
Requirements:
- Check chunks periodically, not every tick.
- Only process loaded chunks.
- Never load chunks just to scan them.
- Count only configured entity types.
- If a chunk exceeds its configured limit, remove only the excess entities.
- Keep the configured amount alive.
- Never remove players.
- Never remove entities that are not configured.
- Do not perform a server-wide entity scan every tick.
- Make it safe and optimized.
---
- REDSTONE CONTROL
Create a redstone control system.
Config:
redstone: enabled: true
manual-control: true
auto-tps: enabled: true disable-below: 12.0 enable-above: 12.0 check-interval: 5
messages: disabled: "&cRedstone has been temporarily disabled because TPS is too low!" enabled: "&aRedstone has been enabled again because TPS recovered!" status-on: "&aRedstone is currently ENABLED." status-off: "&cRedstone is currently DISABLED."
Automatic TPS redstone behavior
When automatic TPS protection is enabled:
- If TPS goes below 12.0, disable redstone.
- If TPS goes 12.0 or above, enable redstone again.
- Do not repeatedly send the message every TPS check.
- Send messages only when the redstone state actually changes.
IMPORTANT — OP ONLY
Automatic TPS redstone messages:
messages: disabled: "..." enabled: "..."
must be sent ONLY to online OP players.
Use the equivalent of:
player.isOp()
Do NOT broadcast these automatic TPS messages to normal members.
Normal players must not receive automatic redstone enabled/disabled messages.
Manual command responses are separate and should continue to be shown to the player executing the command.
Do not destroy, break, or remove redstone blocks.
The system should control redstone behavior safely without deleting blocks.
---
- REDSTONE COMMANDS
Command:
/dngrclearlag redstone on /dngrclearlag redstone off /dngrclearlag redstone status
Permission:
dngrclearlag.redstone
Requirements:
- "on" manually enables redstone.
- "off" manually disables redstone.
- "status" displays the current state.
- Respect "manual-control".
- Automatic TPS control must not create conflicting states.
- State changes must be handled safely.
---
- FAST HOPPERS
Add configurable fast-hopper functionality.
Config:
hoppers: enabled: true
fast-hoppers: true
transfer-cooldown: 1
only-loaded-chunks: true
Requirements:
- Make hopper transfers faster than vanilla when enabled.
- "transfer-cooldown" must be configurable.
- Do not create item duplication bugs.
- Do not cause infinite transfer loops.
- Do not scan all hoppers globally.
- Only operate on loaded chunks when configured.
- Keep the implementation lightweight and safe.
---
- TPS MONITOR
Create a TPS monitoring system.
Config:
tps: enabled: true
threshold: 12.0
check-interval: 5
emergency-cleanup: enabled: true cooldown: 15
Requirements:
- Check TPS every configured number of seconds.
- If TPS falls below the threshold:
- detect the lag condition - optionally perform emergency cleanup
- Emergency cleanup must respect its cooldown.
- Never perform emergency cleanup repeatedly every check while TPS remains low.
- "{tps}" placeholder must show current TPS.
- "{cooldown}" must show remaining emergency-cleanup cooldown when applicable.
Example:
&cTPS is low: &e{tps}
---
- CHAT MODERATION
Add lightweight chat protection.
Config:
chat: enabled: true
cooldown: enabled: true seconds: 2 message: "&cPlease wait before sending another message!"
same-message: enabled: true case-sensitive: false trim-whitespace: true message: "&cYou cannot send the same message repeatedly!"
Requirements:
Chat cooldown
Each player has their own cooldown.
Example:
Player A sends a message.
Player A cannot send another message for 2 seconds.
Player B should still be able to chat normally.
Do NOT create a repeating task for every player.
Use timestamps.
Same-message blocker
Block only if the player's new message is exactly the same as their immediately previous message.
Respect:
case-sensitive: false trim-whitespace: true
Example:
Hello hello
should count as the same when case-sensitive is false.
But:
Hello Hello bro
is not the same.
Do not compare against the entire chat history.
Permission:
dngrclearlag.chat.bypass
Players with this permission bypass:
- chat cooldown
- duplicate-message protection
Also support:
dngrclearlag.bypass
as a general bypass permission.
---
- TAB CLEAR-LAG TIMER PLACEHOLDER
This is VERY IMPORTANT.
Create the placeholder:
%clearlag_timer%
It must show the actual remaining time until the next automatic cleanup.
The timer must be synchronized with the real automatic cleanup schedule.
Example
If:
items: clear-interval: 300
then the cleanup interval is 5 minutes.
Immediately after a cleanup:
5m 00s
Then:
4m 59s 4m 58s 4m 57s ...
After 1 minute:
4m 00s
After 2 minutes 30 seconds:
2m 30s
At the end:
1s
Then the automatic cleanup happens.
Immediately after cleanup, reset the timer:
5m 00s
Critical implementation requirements
"%clearlag_timer%" MUST NOT be an independent fake countdown.
It must calculate the remaining time using the actual next scheduled cleanup timestamp.
Conceptually:
remaining = nextCleanupTimestamp - currentTime
Then convert that into seconds/minutes for display.
The placeholder must always represent the real time remaining before the actual cleanup.
If the server lags or the cleanup is delayed, the placeholder must remain synchronized with the actual cleanup scheduler rather than running an unrelated timer.
Do NOT create an expensive separate repeating task only for the placeholder.
Use the existing cleanup scheduling/timestamp system.
Formatting
Format the timer as:
5m 00s 4m 32s 1m 05s 59s 10s 1s
Do not show unnecessary hours unless the configured interval is longer than one hour.
Disabled state
If automatic item cleanup is disabled:
items: enabled: false
the placeholder should return a configurable value such as:
Disabled
Add:
placeholders: clearlag-timer: disabled: "&cDisabled"
TAB compatibility
The placeholder must be usable in TAB and other compatible placeholder systems.
Use:
%clearlag_timer%
Do not make PlaceholderAPI a hard dependency.
If direct PlaceholderAPI integration is implemented, it must be optional and the plugin must still work normally when PlaceholderAPI is not installed.
The plugin's own placeholder system should remain dependency-free.
---
- MAIN COMMAND
Main command:
/dngrclearlag
Aliases:
/dcl /clearlag
Subcommands:
/dngrclearlag reload /dngrclearlag cleanup /dngrclearlag redstone on /dngrclearlag redstone off /dngrclearlag redstone status /dngrclearlag tps
Permissions:
dngrclearlag.use dngrclearlag.reload dngrclearlag.cleanup dngrclearlag.redstone dngrclearlag.bypass dngrclearlag.chat.bypass
Add proper permission checks.
Add a useful help message.
---
- RELOAD SYSTEM
Command:
/dngrclearlag reload
Permission:
dngrclearlag.reload
Reload:
- configuration
- messages
- cleanup interval
- entity settings
- TPS settings
- redstone settings
- hopper settings
- chat settings
- placeholder settings
IMPORTANT:
Reload must safely cancel/recreate scheduled tasks where necessary.
Never create duplicate tasks after multiple reloads.
Never create memory leaks.
Never leave old timers running after reload.
The "%clearlag_timer%" must immediately use the newly configured cleanup interval after reload.
---
- CONFIGURATION
Create a clean, fully commented "config.yml".
All important values must be configurable.
Use sensible defaults.
The configuration should include:
items: enabled: true clear-interval: 300
entities: enabled: false
tps: enabled: true
redstone: enabled: true
hoppers: enabled: true
chat: enabled: true
placeholders: clearlag-timer: disabled: "&cDisabled"
Do not hard-code user-facing messages where they should be configurable.
---
- PROJECT STRUCTURE
Use a clean structure similar to:
com.dngr.clearlag │ ├── DNGRClearLag.java │ ├── command │ └── CommandHandler.java │ ├── manager │ ├── ConfigManager.java │ ├── ItemClearManager.java │ ├── EntityLimiterManager.java │ ├── RedstoneManager.java │ ├── HopperManager.java │ ├── TPSManager.java │ └── ChatModerationManager.java │ ├── listener │ ├── RedstoneListener.java │ └── ChatListener.java │ └── util └── ColorUtil.java
You may add additional classes if they improve code quality.
---
- PERFORMANCE REQUIREMENTS
This plugin is intended for a real server with 50+ players.
Avoid:
- global per-tick entity scans
- global per-tick item scans
- global per-tick hopper scans
- a repeating task for every player
- unnecessary async Bukkit API access
- loading unloaded chunks
- duplicate scheduled tasks
- memory leaks
Use efficient scheduled tasks.
Only inspect what is necessary.
Do not sacrifice server safety for performance.
---
- SAFETY REQUIREMENTS
The plugin must NEVER:
- remove player inventories
- remove container items
- remove protected/whitelisted dropped items
- remove players
- load chunks unnecessarily
- cause hopper item duplication
- break redstone blocks
- spam chat
- create duplicate scheduled tasks
- crash if a configuration value is invalid
Handle invalid configuration values safely and use defaults when possible.
---
- MESSAGE PLACEHOLDERS
Support these placeholders where relevant:
{time} {amount} {tps} {cooldown}
Also support the actual timer placeholder:
%clearlag_timer%
All configurable messages must pass through the central color/HEX utility.
---
- FINAL TESTING
Before considering the plugin complete, verify:
- It compiles with Java 21.
- It loads correctly on Paper 1.21.11+.
- No startup errors.
- No console spam.
- HEX colors work.
- Automatic item cleanup works.
- Whitelisted items are never removed.
- Countdown works.
- Entity limiter works per loaded chunk.
- Players are never removed.
- Fast hoppers work safely.
- TPS monitoring works.
- Emergency cleanup cooldown works.
- Automatic redstone disables below the configured TPS.
- Automatic redstone enables again at/above the configured TPS.
- Automatic redstone state-change messages go ONLY to OP players.
- Normal members receive no automatic redstone TPS messages.
- Manual redstone commands work.
- Chat cooldown works per player.
- Duplicate message protection works.
- Bypass permissions work.
- "/dngrclearlag reload" works without duplicate tasks.
- "%clearlag_timer%" shows the real remaining time.
- "%clearlag_timer%" counts down with the actual cleanup schedule.
- "%clearlag_timer%" resets immediately after cleanup.
- "%clearlag_timer%" changes correctly after config reload.
- "%clearlag_timer%" shows "Disabled" when automatic cleanup is disabled.
- No PlaceholderAPI dependency is required.
- No unnecessary per-tick global scans exist.
- Plugin remains stable with 50+ players.
Build the complete plugin with all required Java source files, "plugin.yml", "config.yml", and build configuration.
Do not leave placeholder/TODO implementations.
Everything described above must be fully implemented and functional.