mrdangerous_official

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.

---

  1. HEX COLOR SUPPORT

Create one central color utility.

Support both:

&#RRGGBB

and normal:

&0-&9 &a-&f

Example:

&#00FFAAHello &7Player

must display with the correct HEX color.

All configurable messages throughout the plugin must support HEX colors.

---

  1. 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.

---

  1. 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.

---

  1. 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.

---

  1. 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.

---

  1. 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.

---

  1. 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}

---

  1. 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.

---

  1. 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.

---

  1. 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.

---

  1. 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.

---

  1. 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.

---

  1. 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.

---

  1. 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.

---

  1. 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.

---

  1. 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.

---

  1. FINAL TESTING

Before considering the plugin complete, verify:

  1. It compiles with Java 21.
  2. It loads correctly on Paper 1.21.11+.
  3. No startup errors.
  4. No console spam.
  5. HEX colors work.
  6. Automatic item cleanup works.
  7. Whitelisted items are never removed.
  8. Countdown works.
  9. Entity limiter works per loaded chunk.
  10. Players are never removed.
  11. Fast hoppers work safely.
  12. TPS monitoring works.
  13. Emergency cleanup cooldown works.
  14. Automatic redstone disables below the configured TPS.
  15. Automatic redstone enables again at/above the configured TPS.
  16. Automatic redstone state-change messages go ONLY to OP players.
  17. Normal members receive no automatic redstone TPS messages.
  18. Manual redstone commands work.
  19. Chat cooldown works per player.
  20. Duplicate message protection works.
  21. Bypass permissions work.
  22. "/dngrclearlag reload" works without duplicate tasks.
  23. "%clearlag_timer%" shows the real remaining time.
  24. "%clearlag_timer%" counts down with the actual cleanup schedule.
  25. "%clearlag_timer%" resets immediately after cleanup.
  26. "%clearlag_timer%" changes correctly after config reload.
  27. "%clearlag_timer%" shows "Disabled" when automatic cleanup is disabled.
  28. No PlaceholderAPI dependency is required.
  29. No unnecessary per-tick global scans exist.
  30. 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.

Kodari AI
KodariSep 3 at 12:37 pm 2
DNGRClearLag
A comprehensive server performance optimization plugin for Paper 1.21.11+ featuring automatic dropped item cleanup with countdown timers and whitelist protection, per-chunk entity limiting, TPS-based redstone control with manual override commands, configurable fast hoppers, TPS monitoring with emergency cleanup, per-player chat moderation with cooldown and duplicate message blocking, and a synchronized %clearlag_timer% placeholder showing real time until next cleanup. Includes full HEX color support, reload command, and optimized scheduled tasks designed for servers with 50+ players without global per-tick scans.
  1. Create the Java 21 Gradle project and Paper plugin metadata.

  2. Implement shared configuration, color, sound, scheduling, and timer infrastructure.

  3. Add item cleanup, entity limiting, redstone control, hopper acceleration, TPS monitoring, and chat moderation.

  4. Add commands, listeners, optional PlaceholderAPI integration, and the fully commented default configuration.

Created the complete DNGRClearLag Paper plugin project with:

  • Java 21 Gradle build configuration

  • Paper 1.21.11 plugin metadata

  • HEX and legacy color support

  • Automatic dropped-item cleanup with whitelist and countdowns

  • Real synchronized %clearlag_timer% PlaceholderAPI expansion

  • Per-chunk entity limiting

  • TPS monitoring and emergency cleanup cooldown

  • OP-only automatic redstone state messages

  • Manual redstone commands and protection

  • Configurable hopper acceleration

  • Per-player chat cooldown and duplicate-message blocking

  • Bypass permissions

  • Reload-safe scheduled task management

  • Fully commented default config.yml

  • /dngrclearlag, /dcl, and /clearlag command aliases

mrdangerous_official

Remove the entire Hopper system from the DNGRClearLag plugin.

Remove completely

Delete all hopper-related functionality from the plugin, including:

  • Fast Hopper feature
  • Hopper transfer optimization
  • Hopper cooldown
  • Hopper processing
  • Hopper dropped-item pickup modifications
  • Hopper → hopper optimization
  • Hopper → chest/container optimization
  • Container → hopper modifications
  • Any custom hopper event listeners
  • Any hopper-related scheduled tasks
  • Any hopper-related classes
  • Any hopper-related methods
  • Any hopper-related configuration
  • Any hopper-related messages
  • Any hopper-related permissions
  • Any hopper-related code or imports

Configuration

Completely remove this section and anything related to it:

hoppers: enabled: true fast-hoppers: true transfer-cooldown: 1 only-loaded-chunks: true

The final "config.yml" must contain no hopper settings.

IMPORTANT

After removing the hopper system, hoppers must behave exactly according to normal Paper/Minecraft vanilla behavior.

DNGRClearLag must NOT modify hopper behavior in any way.

Do not replace it with another hopper system.

Do not add any new hopper optimization.

Do NOT change anything else

Keep every other existing DNGRClearLag feature exactly as it currently works:

  • Automatic dropped-item cleanup
  • Item whitelist
  • Cleanup countdown
  • "%clearlag_timer%"
  • Per-chunk entity limiter
  • TPS monitor
  • Emergency cleanup
  • Automatic TPS redstone control
  • Manual redstone commands
  • OP-only automatic redstone messages
  • Chat cooldown
  • Duplicate-message protection
  • All existing commands
  • All existing permissions
  • HEX color support
  • Reload system
  • All existing messages and configuration

Only remove the entire Hopper system.

After modification, make sure the plugin compiles successfully and has no unused hopper-related code or configuration.

Kodari AI
KodariSep 17 at 9:04 am 1
  1. Locate every hopper-related class, listener, scheduler, config entry, message, permission, and registration.

  2. Remove only that functionality and its references, preserving all other behavior.

  3. Verify no hopper references remain and inspect the build/config metadata for consistency.

  1. Removed the entire HopperManager, including all hopper event listeners, transfer optimization, cooldown logic, and hopper-specific imports.

  2. Removed hopper manager initialization, registration, and reload handling from DNGRClearLag.

  3. Removed the complete hoppers section from config.yml.

  4. Verified no hopper-related references remain under src.

All other plugin features, configuration, messages, commands, permissions, and listeners were left unchanged.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
17 1,203
src/main/java/com/dngr/clearlag/DNGRClearLag.java
package com.dngr.clearlag;

import com.dngr.clearlag.command.CommandHandler;
import com.dngr.clearlag.integration.ClearLagPlaceholderExpansion;
import com.dngr.clearlag.listener.ChatListener;
import com.dngr.clearlag.listener.RedstoneListener;
import com.dngr.clearlag.manager.ChatModerationManager;
import com.dngr.clearlag.manager.ConfigManager;
import com.dngr.clearlag.manager.EntityLimiterManager;
import com.dngr.clearlag.manager.ItemClearManager;
import com.dngr.clearlag.manager.RedstoneManager;
import com.dngr.clearlag.manager.TPSManager;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

import java.lang.reflect.Method;

public final class DNGRClearLag extends JavaPlugin {
    private ConfigManager configManager;
    private ItemClearManager itemClearManager;
    private EntityLimiterManager entityLimiterManager;
    private RedstoneManager redstoneManager;
    private TPSManager tpsManager;
    private ChatModerationManager chatModerationManager;
    private Object placeholderExpansion;

    @Override
    public void onEnable() {
        configManager = new ConfigManager(this);
        itemClearManager = new ItemClearManager(this, configManager);
        entityLimiterManager = new EntityLimiterManager(this, configManager);
        redstoneManager = new RedstoneManager(this, configManager);
        tpsManager = new TPSManager(this, configManager, itemClearManager);
        chatModerationManager = new ChatModerationManager(this, configManager);

        Bukkit.getPluginManager().registerEvents(new RedstoneListener(redstoneManager), this);
        Bukkit.getPluginManager().registerEvents(new ChatListener(this, chatModerationManager), this);

        CommandHandler commandHandler = new CommandHandler(this);
        if (getCommand("dngrclearlag") != null) {
            getCommand("dngrclearlag").setExecutor(commandHandler);
            getCommand("dngrclearlag").setTabCompleter(commandHandler);
        }

        if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
            placeholderExpansion = new ClearLagPlaceholderExpansion(this);
            try {
                Method register = placeholderExpansion.getClass().getMethod("register");
                register.invoke(placeholderExpansion);
            } catch (ReflectiveOperationException exception) {
                getLogger().warning("Unable to register the optional PlaceholderAPI expansion.");
            }
        }
    }

    public void reloadPlugin() {
        configManager.reload();
        itemClearManager.reload();
        entityLimiterManager.reload();
        redstoneManager.reload();
        tpsManager.reload();
        chatModerationManager.reload();
    }

    @Override
    public void onDisable() {
        itemClearManager.shutdown();
        entityLimiterManager.shutdown();
        redstoneManager.shutdown();
        tpsManager.shutdown();
        if (placeholderExpansion != null) {
            try {
                placeholderExpansion.getClass().getMethod("unregister").invoke(placeholderExpansion);
            } catch (ReflectiveOperationException ignored) {
            }
        }
    }

    public ConfigManager getConfigManager() {
        return configManager;
    }

    public ItemClearManager getItemClearManager() {
        return itemClearManager;
    }

    public RedstoneManager getRedstoneManager() {
        return redstoneManager;
    }

    public TPSManager getTpsManager() {
        return tpsManager;
    }
}