anshu_here07

make A redstone limter plugin consist RedstoneLimiter detects excessive redstone activity and blocks dangerous machines without disabling legitimate redstone across the entire server.

It independently tracks activity at the individual block, chunk, and configurable region level. This allows small machines to work normally while clocks, piston machines, dispenser spam, and concentrated redstone activity are stopped when they exceed your limits.

Per-block limiting — configure separate activation limits for observers, pistons, sticky pistons, dispensers, droppers, and other redstone blocks.

Per-chunk protection — stop large machines that distribute activity across many individual blocks.

Per-region protection — detect concentrated redstone activity across configurable three-dimensional areas.

Piston protection — limit piston activation speed and the maximum number of blocks pushed at once.

Dispenser and dropper protection — cancel machine-gun-style activation spam.

Configurable periods and thresholds — control how frequently every scope may activate.

Disabled worlds — completely exclude selected worlds from limiting, effects, statistics, and notifications.

Visual block feedback — display a configurable effect when abusive activity is blocked.

Live activation statistics — inspect total activations and blocked events.

Top danger zones — locate the most active blocks, chunks, and regions.

Clickable notifications — authorized staff can teleport directly to blocked machines.

Notification throttling — global, local, and per-player cooldowns prevent alert spam.

Optional Redis networking — share alerts between servers and visit the affected location through your proxy.

Configure limiter scopes, activation periods, material-specific thresholds, region size, piston push limits, disabled worlds, visual effects, messages, notification permissions, cooldowns, and optional Redis cross-server integration.

Kodari AI
KodariSep 23 at 2:51 pm 2
RedstoneLimiter
RedstoneLimiter detects excessive redstone activity and blocks dangerous machines without disabling legitimate redstone across the entire server. It independently tracks activity at the individual block, chunk, and configurable region level, allowing small machines to work normally while clocks, piston machines, dispenser spam, and concentrated redstone activity are stopped when they exceed your limits. Features include per-block limiting for observers, pistons, dispensers, and droppers; per-chunk protection; per-region protection; piston activation speed and push limits; dispenser and dropper spam cancellation; configurable periods and thresholds; disabled worlds; visual block feedback; live activation statistics; top danger zones; clickable notifications for staff teleportation; notification throttling; and optional Redis networking for cross-server alerts.
  • Create the Paper plugin scaffold and configurable limits.

  • Implement block, chunk, and region tracking with piston/dispenser protection, stats, and staff alerts.

  • Add commands, visual feedback, and optional Redis alerts/proxy visits.

Created the RedstoneLimiter Paper plugin with configurable block, chunk, and 3D-region limits; piston push limits; and dispenser/dropper activation protection. It includes disabled-world exclusions, particle feedback, activation and blocked-event statistics, danger-zone rankings, throttled clickable staff alerts, and optional Redis alert sharing with proxy-based visits.

The Redis and proxy features are disabled or optional by configuration; cross-server visits require Redis and a BungeeCord-compatible proxy.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
11 1,174
src/main/java/com/kodari/redstonelimiter/RedstoneLimiterPlugin.java
package com.kodari.redstonelimiter;

import com.cryptomorin.xseries.particles.XParticle;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

public final class RedstoneLimiterPlugin extends JavaPlugin {
    private LimiterSettings settings;
    private ActivityTracker tracker;
    private NotificationManager notifications;
    private RedisBridge redis;
    private final Map<UUID, PendingVisit> pendingVisits = new ConcurrentHashMap<>();

    @Override
    public void onEnable() {
        saveDefaultConfig();
        settings = new LimiterSettings(this);
        tracker = new ActivityTracker(settings);
        notifications = new NotificationManager(settings);
        getServer().getPluginManager().registerEvents(new LimiterListener(this), this);
        getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");

        LimiterCommand command = new LimiterCommand(this);
        getCommand("redstonelimiter").setExecutor(command);
        getCommand("redstonelimiter").setTabCompleter(command);

        redis = new RedisBridge(this, settings);
        redis.start();
        getServer().getScheduler().runTaskTimer(this, () -> tracker.cleanup(), 1200L, 1200L);
    }

    @Override
    public void onDisable() {
        if (redis != null) {
            redis.close();
        }
        getServer().getMessenger().unregisterOutgoingPluginChannel(this, "BungeeCord");
    }

    public void reloadSettings() {
        reloadConfig();
        settings = new LimiterSettings(this);
        tracker.updateSettings(settings);
        notifications.updateSettings(settings);
        if (redis != null) {
            redis.close();
        }
        redis = new RedisBridge(this, settings);
        redis.start();
    }

    public void handleBlocked(Location location, String material, String reason) {
        String world = location.getWorld().getName();
        int x = location.getBlockX();
        int y = location.getBlockY();
        int z = location.getBlockZ();
        if (notifications.notifyAlert(settings.serverName(), world, x, y, z, material, reason) && settings.redisEnabled()) {
            redis.publishAlert(settings.serverName(), world, x, y, z, material, reason);
        }
        if (settings.feedbackEnabled()) {
            Location effectLocation = location.clone().add(0.5, 0.5, 0.5);
            XParticle.of(settings.feedbackParticle()).ifPresent(particle ->
                    location.getWorld().spawnParticle(particle.get(), effectLocation, settings.feedbackCount(), 0.25, 0.25, 0.25, 0.01));
        }
    }

    public void connectToServer(Player player, String server) {
        try {
            ByteArrayOutputStream bytes = new ByteArrayOutputStream();
            DataOutputStream output = new DataOutputStream(bytes);
            output.writeUTF("Connect");
            output.writeUTF(server);
            player.sendPluginMessage(this, "BungeeCord", bytes.toByteArray());
        } catch (IOException exception) {
            getLogger().warning("Could not send proxy connection request: " + exception.getMessage());
        }
    }

    public void acceptRemoteVisit(String targetServer, UUID playerId, String world, double x, double y, double z) {
        if (!targetServer.equalsIgnoreCase(settings.serverName())) {
            return;
        }
        PendingVisit visit = new PendingVisit(world, x, y, z);
        pendingVisits.put(playerId, visit);
        Player player = Bukkit.getPlayer(playerId);
        if (player != null) {
            applyPendingVisit(player);
        }
    }

    public void applyPendingVisit(Player player) {
        PendingVisit visit = pendingVisits.remove(player.getUniqueId());
        if (visit == null) {
            return;
        }
        Bukkit.getScheduler().runTask(this, () -> {
            World world = Bukkit.getWorld(visit.world());
            if (world == null) {
                player.sendMessage(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacyAmpersand()
                        .deserialize(settings.message("visit-world-missing", "&cThat world is not loaded on this server.")));
                return;
            }
            player.teleport(new Location(world, visit.x(), visit.y(), visit.z()));
            player.sendMessage(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacyAmpersand()
                    .deserialize(settings.message("visit-complete", "&aTeleported to the affected location.")));
        });
    }

    public LimiterSettings settings() {
        return settings;
    }

    public ActivityTracker tracker() {
        return tracker;
    }

    public NotificationManager notifications() {
        return notifications;
    }

    public RedisBridge redis() {
        return redis;
    }

    private record PendingVisit(String world, double x, double y, double z) {
    }
}