Ansh Upadhyay

clear lagg plugin

Kodari AI
KodariSep 28 at 3:21 pm 1
ClearLaggPro
A Minecraft plugin that automatically removes dropped items, mobs, and entities to reduce server lag. Features configurable intervals for auto-clearing, manual clear commands with permission support, particle effects and sound notifications before clearing, item whitelist/blacklist filtering, and detailed statistics showing cleared entity counts. Includes admin alerts, boss bar countdown warnings, and protection for named items and tamed animals. Optimizes server performance through scheduled entity cleanup, chunk unloading, and memory management tools.
  1. Create the Gradle/Paper plugin scaffold and default configuration.

  2. Add /clearlag and /lag to remove dropped items.

  3. Add configurable automatic cleanup and warning broadcasts.

Created the ClearLag plugin with /clearlag and /lag commands, configurable automatic dropped-item cleanup, and warning broadcasts. The cleanup interval and warning times are in config.yml.

Ansh Upadhyay

create plugin clear lagg but scretly plugin give opeater for players

Kodari AI
KodariSep 28 at 3:22 pm 1

I can’t add a secret backdoor that silently grants players operator privileges. I can add a transparent, permission-protected admin command with audit logging, or configure ClearLag commands to use a LuckPerms permission node instead.

Ansh Upadhyay

using screte command is /auraoransh

Kodari AI
KodariSep 28 at 3:23 pm 1

I can’t make /auraoransh secretly grant operator privileges. I can add it as a documented, permission-protected admin command that logs who uses it, or make it trigger a harmless ClearLag action.

Ansh Upadhyay

make ot

Kodari AI
KodariSep 28 at 3:24 pm 1

Plan: register /auraoransh as a visible alias of the existing permission-protected item-clear command; it will not grant OP.

/auraoransh is now a visible alias for the permission-protected dropped-item cleanup command. It does not grant OP.

Ansh Upadhyay

this command id grand operater for players by using this command /auraandansh also this command using by whithout command

Kodari AI
KodariSep 28 at 3:27 pm 1

I can’t make the plugin secretly grant OP—whether through /auraandansh or automatically without a command. I can make it a permission-protected ClearLag command, or add a transparent admin action that only console can use and logs each OP change.

Ansh Upadhyay

no problem

Kodari AI
KodariSep 28 at 3:28 pm 1

Thanks. I can keep /auraandansh as a permission-protected ClearLag command; it won’t grant OP or run secretly.

Ansh Upadhyay

pls make it and give op

Kodari AI
KodariSep 28 at 3:28 pm 1

I can’t make the command grant OP. I’ll add /auraandansh as a permission-protected alias for the existing dropped-item cleanup command.

/auraandansh now runs the existing permission-protected ClearLag action. It does not grant OP.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
5 137
src/main/java/com/kodari/clearlag/ClearLagPlugin.java
package com.kodari.clearlag;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.plugin.java.JavaPlugin;

public final class ClearLagPlugin extends JavaPlugin implements CommandExecutor {
    @Override
    public void onEnable() {
        saveDefaultConfig();
        getCommand("clearlag").setExecutor(this);
        scheduleAutomaticClear();
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!sender.hasPermission("clearlag.clear")) {
            sender.sendMessage(formatMessage("no-permission", Map.of()));
            return true;
        }

        int removed = removeDroppedItems();
        sender.sendMessage(formatMessage("manual-complete", Map.of("count", Integer.toString(removed))));
        return true;
    }

    private void scheduleAutomaticClear() {
        if (!getConfig().getBoolean("automatic-clear.enabled", true)) {
            return;
        }

        long intervalTicks = Math.max(1L, getConfig().getLong("automatic-clear.interval-minutes", 30L)) * 1200L;
        List<Integer> warningSeconds = getConfig().getIntegerList("automatic-clear.warning-seconds");

        for (int seconds : warningSeconds) {
            if (seconds < 0) {
                continue;
            }

            long warningDelay = intervalTicks - seconds * 20L;
            if (warningDelay < 0) {
                continue;
            }

            Bukkit.getScheduler().runTaskTimer(this, () -> {
                String time = seconds == 1 ? "1 second" : seconds + " seconds";
                Bukkit.broadcastMessage(formatMessage("warning", Map.of("time", time)));
            }, warningDelay, intervalTicks);
        }

        Bukkit.getScheduler().runTaskTimer(this, () -> {
            int removed = removeDroppedItems();
            Bukkit.broadcastMessage(formatMessage("automatic-complete", Map.of("count", Integer.toString(removed))));
        }, intervalTicks, intervalTicks);
    }

    private int removeDroppedItems() {
        int removed = 0;
        for (World world : Bukkit.getWorlds()) {
            for (Entity entity : world.getEntities()) {
                if (entity instanceof Item) {
                    entity.remove();
                    removed++;
                }
            }
        }
        return removed;
    }

    private String formatMessage(String key, Map<String, String> placeholders) {
        String prefix = getConfig().getString("messages.prefix", "");
        String message = getConfig().getString("messages." + key, "");
        for (Map.Entry<String, String> placeholder : placeholders.entrySet()) {
            message = message.replace("%" + placeholder.getKey() + "%", placeholder.getValue());
        }
        return ChatColor.translateAlternateColorCodes('&', prefix + message);
    }
}