Leo Flanagan

Make a plugin that clears tripwires dropped on the floor every 5 seconds

Kodari AI
KodariNov 1 at 12:23 am 1
TripwireCleaner
A Minecraft plugin that automatically removes tripwire entities dropped on the ground. Every 5 seconds, the plugin scans the world for tripwire items lying on the floor and clears them to prevent lag and clutter. It uses a repeating task scheduler to check all loaded chunks for tripwire entities, removes them instantly, and optionally logs the cleanup count. Lightweight and configurable, it helps server admins maintain performance by eliminating unwanted tripwire drops.

Plan:

  1. Create a minimal Gradle Paper plugin project.

  2. Add a startup task that removes dropped tripwire-hook items from loaded worlds every 5 seconds.

  3. Keep the item check version-friendly without direct Bukkit material-enum references.

Created TripwireCleaner, which removes dropped tripwire-hook items from loaded worlds every 5 seconds.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
3 53
src/main/java/com/kodari/tripwirecleaner/TripwireCleanerPlugin.java
package com.kodari.tripwirecleaner;

import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.plugin.java.JavaPlugin;

public final class TripwireCleanerPlugin extends JavaPlugin {
    @Override
    public void onEnable() {
        Bukkit.getScheduler().runTaskTimer(this, this::removeDroppedTripwireHooks, 100L, 100L);
    }

    private void removeDroppedTripwireHooks() {
        for (World world : Bukkit.getWorlds()) {
            for (Entity entity : world.getEntities()) {
                if (entity instanceof Item item && item.getItemStack().getType().name().equals("TRIPWIRE_HOOK")) {
                    item.remove();
                }
            }
        }
    }
}