M

Create a Minecraft Paper 1.21 plugin in Java 21 called LagCleaner.

Purpose:

Optimize server performance automatically by removing laggy entities and blocks.

================================================== FEATURES ========

======================== GROUND ITEM CLEANER ===================

Automatically clear:

* dropped items * unused projectiles * arrows * snowballs * tridents * experience or

Kodari AI
KodariMay 17 at 3:38 pm 7,289 (v2)

I’ll create a performance optimization plugin that automatically cleans laggy entities from the server.

LagCleaner
An automatic server performance optimizer that periodically removes lag-causing entities like dropped items, projectiles, and experience orbs. Features configurable entity type filters, cleanup intervals, world exclusions, and warning broadcasts. Includes admin commands for manual cleaning and real-time statistics tracking to maintain optimal server TPS.

LagCleaner is ready! The plugin automatically removes lag-causing entities every 5 minutes (configurable) with a 30-second warning broadcast. Features include:

  • Entity filtering: Dropped items, arrows, snowballs, tridents, experience orbs, and more projectiles

  • Protection system: Exclude specific items, worlds, and custom-named items from cleanup

  • Permission bypass: Players with lagcleaner.bypass permission can drop items that won’t be removed

  • Minimum age: Entities must be at least 60 seconds old before removal

  • Statistics tracking: View total cleaned entities and next cleanup time

  • Admin commands: /lagcleaner clean, /lagcleaner stats, /lagcleaner reload, /lagcleaner toggle

All entity types, intervals, and messages are fully configurable in config.yml.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
8 557
src/main/java/com/lagcleaner/LagCleaner.java
package com.lagcleaner;

import com.lagcleaner.command.LagCleanerCommand;
import com.lagcleaner.config.ConfigManager;
import com.lagcleaner.task.CleanupTask;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public class LagCleaner extends JavaPlugin {
    
    private ConfigManager configManager;
    private CleanupTask cleanupTask;
    private Stats stats;
    
    @Override
    public void onEnable() {
        this.saveDefaultConfig();
        
        this.configManager = new ConfigManager(this);
        this.stats = new Stats();
        this.cleanupTask = new CleanupTask(this);
        
        this.getCommand("lagcleaner").setExecutor(new LagCleanerCommand(this));
        
        if (this.configManager.isEnabled()) {
            this.cleanupTask.start();
        }
        
        this.getLogger().info("LagCleaner has been enabled!");
    }
    
    @Override
    public void onDisable() {
        if (this.cleanupTask != null) {
            this.cleanupTask.stop();
        }
        this.getLogger().info("LagCleaner has been disabled!");
    }
    
    public ConfigManager getConfigManager() {
        return this.configManager;
    }
    
    public CleanupTask getCleanupTask() {
        return this.cleanupTask;
    }
    
    public Stats getStats() {
        return this.stats;
    }
    
    public void reload() {
        this.reloadConfig();
        this.configManager = new ConfigManager(this);
        
        this.cleanupTask.stop();
        this.cleanupTask = new CleanupTask(this);
        
        if (this.configManager.isEnabled()) {
            this.cleanupTask.start();
        }
    }
}