9l_w2

Make me an lag clear plugin that kills all item drops every 1 hour and counts down from 5 to 0 in the chat and shows on everyones actionbar. after the item drops have been cleared it should show a message in chat and on the actionbar.

All messages should be configurable and this plugin should be optimised.

Plugin name should be AbLagClear and the author should be ActualBuca.

Kodari AI
KodariJun 25 at 1:20 pm 1
AbLagClear
A lightweight lag-clearing plugin that automatically removes all dropped item entities on a configurable interval. Features a 5-second countdown displayed in both chat and actionbar before clearing, with fully customizable messages. Designed for performance with minimal overhead and zero impact during idle periods.
9l_w2

It should also show a message in chat + actionbar after theres 10 minutes left and will send another one at 5 minutes left, 1m left, 30s left and should still countdown when it hits 5 seconds

Kodari AI
KodariJun 25 at 1:23 pm 1

Now I’ll rewrite the two Java files to add the multi-stage warning system

Now I’ll rewrite the full LagClearRunnable to add the warning systemThe patch was a no-op because I accidentally set search == replace. I’ll fully rewrite the file with an <update> tag

Read-only mount — I need to use <update> tag instead of bash.

Now update AbLagClear.java to call scheduleWarnings on enable:

9l_w2

Make the config support HEX codes

Kodari AI
KodariJun 25 at 2:34 pm 1

I’ll add HEX support (&#RRGGBB) to the color method and update the config comment to document it

Done. Now &#RRGGBB HEX codes are supported everywhere in the config (chat, actionbar, and prefix). Use them like &#ff5555 or &#00aa00 alongside normal & codes.

9l_w2

Add that you need to add a license key in the config.yml. The license is AJHG-QG23-Z2FF-OP23 and people who use this plugin must put in the license themselves, the plugin should automatically disable itself when no license key is entered.

Kodari AI
KodariJun 25 at 2:47 pm 1

Now update AbLagClear.java to validate the license on startup and disable itself if it’s missing or invalid

Done. Now the plugin:

  1. License key in config.yml — defaults to "" (empty). User must set license-key: "AJHG-QG23-Z2FF-OP23"

  2. Auto-disable on invalid key — on startup, if the key is missing or doesn’t match the hardcoded AJHG-QG23-Z2FF-OP23, the plugin logs two severe messages and calls Bukkit.getPluginManager().disablePlugin(this) immediately, so nothing runs

  3. HEX color support — already working in the color() method (converts &#RRGGBB to Spigot’s §x§R§R§G§G§B§B format)

9l_w2

Add configurable sounds for when the countdown msg appears

Kodari AI
KodariJun 25 at 2:49 pm 2

I’ll add configurable sound support for countdown ticks, warning messages, and clear completion

Now update LagClearRunnable.java with XSound for all event types:

Let me verify the final state:

Everything looks good. Here’s what was added:

New config values in config.yml:

  • countdown-sound — played each second during the 5s countdown (default: BLOCK_NOTE_BLOCK_PLING)

  • warning-10m-sound, warning-5m-sound, warning-1m-sound, warning-30s-sound — played on each warning message (default: BLOCK_NOTE_BLOCK_BASS)

  • clear-sound — played after items are cleared (default: ENTITY_PLAYER_LEVELUP)

  • Set any sound to "" to disable it

New in code:

  • XSound.matchXSound(...) resolves the sound name cross-version (1.8 → 1.21+)

  • playSound(player, soundName) helper skips empty/null config values

  • Sound plays on countdown ticks, warning broadcasts, and clear completion — each configurable independently

9l_w2

The actionbar still does not support hex codes.

Kodari AI
KodariJun 29 at 12:29 pm 1

The issue is new TextComponent(actionbar) treats the string literally — it doesn’t parse §x hex color codes. The fix is TextComponent.fromLegacyText() which does.

Now TextComponent.fromLegacyText(actionbar) is used on all three actionbar sends (countdown, warnings, and clear-completion). It parses §xRRGGBB codes properly, so HEX works in actionbars now. Use &#ff5555 in any actionbar config value and it’ll render as the correct color.

Kodari can make mistakes. Review important code before using.
Files
src
pom.xml
Code
5 358
src/main/java/com/actualbuca/ablagclear/AbLagClear.java
package com.actualbuca.ablagclear;

import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public class AbLagClear extends JavaPlugin {

    private static AbLagClear instance;

    @Override
    public void onEnable() {
        instance = this;
        saveDefaultConfig();

        // License check
        String license = getConfig().getString("license-key", "").trim();
        if (license.isEmpty() || !license.equals("AJHG-QG23-Z2FF-OP23")) {
            getLogger().severe("Invalid or missing license key! Plugin will disable itself.");
            getLogger().severe("Please set a valid license-key in config.yml and restart.");
            Bukkit.getPluginManager().disablePlugin(this);
            return;
        }
        getLogger().info("License key validated successfully.");

        long intervalTicks = getConfig().getLong("clear-interval", 60) * 60L * 20L;

        // Schedule warning messages for the first cycle
        LagClearRunnable.scheduleWarnings(this, intervalTicks);

        // Schedule the repeating clear task
        new LagClearRunnable().runTaskTimer(this, intervalTicks, intervalTicks);

        getLogger().info("AbLagClear enabled — interval: " + getConfig().getInt("clear-interval", 60) + " minutes");
    }

    @Override
    public void onDisable() {
        getLogger().info("AbLagClear disabled");
    }

    public static AbLagClear getInstance() {
        return instance;
    }
}