script.exec

make me a minecraft plugin that removes enderman spawn inside a certain radius that i can set up through configs in files and with commands in-game. people with permissions for example endermanguard.admin can set up the radius, and the radius can be both a sphere or a rectangle. prevent only natural spawning in the radius, but the enderman still can teleport inside of it.

Kodari AI
KodariAug 23 at 8:45 am 1
EndermanGuard
Minecraft plugin that prevents natural enderman spawning within configurable protected zones. Admins with endermanguard.admin permission can define zones via in-game commands or config files. Zones support both spherical and rectangular shapes with adjustable radii. The plugin intercepts natural spawn attempts, blocking endermen from appearing inside protected areas while still allowing teleportation into them. Features include dynamic zone management, permission-based command access, and persistent configuration storage. Players can create, remove, and list zones, with each zone having its own shape and size settings. The plugin integrates seamlessly with Bukkit/Spigot servers, offering a lightweight solution for managing enderman spawns in specific areas.
  1. Create the Gradle project and plugin metadata.

  2. Add configurable sphere/rectangle zone storage and in-game admin commands.

  3. Register a listener that cancels only natural Enderman spawns inside the configured zone.

  4. Add tab completion and clear command/config defaults.

Created EndermanGuard, a Minecraft/Paper plugin with:

  • Configurable Enderman protection zone in config.yml

  • sphere and axis-aligned rectangle/cube shapes

  • Cancels only CreatureSpawnEvent.SpawnReason.NATURAL

  • Endermen can still teleport into the zone

  • Admin permission: endermanguard.admin

  • In-game commands:

    • /endermanguard set <radius> [sphere|rectangle]

    • /endermanguard shape <sphere|rectangle>

    • /endermanguard enable

    • /endermanguard disable

    • /endermanguard status

    • /endermanguard reload

  • Alias: /eguard

script.exec

can you make a command that i can see the whole area which im trying to prevent from endermen spawning?

Kodari AI
KodariAug 23 at 8:50 am 2
  1. Add an /endermanguard outline command that draws the configured boundary with particles for the executing player.

  2. Support accurate cube edges for rectangles and an approximated 3D boundary for spheres, with validation and help/tab-completion updates.

Added /endermanguard outline.

  • Displays the configured protected zone using End Rod particles.

  • Shows all 12 edges for rectangle zones.

  • Shows latitude and vertical rings for sphere zones.

  • Only the executing player sees the particles.

  • You must be in the configured zone world.

  • Requires endermanguard.admin.

Usage:

Plain Text
/endermanguard outline

The command is also included in help, tab completion, and plugin usage text.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
8 549
src/main/java/com/kodari/endermanguard/EndermanGuardPlugin.java
package com.kodari.endermanguard;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;

public final class EndermanGuardPlugin extends JavaPlugin {
    private boolean zoneEnabled;
    private String zoneWorld;
    private double centerX;
    private double centerY;
    private double centerZ;
    private double radius;
    private ZoneShape shape;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        loadZone();

        EndermanGuardCommand command = new EndermanGuardCommand(this);
        PluginCommand pluginCommand = getCommand("endermanguard");
        if (pluginCommand != null) {
            pluginCommand.setExecutor(command);
            pluginCommand.setTabCompleter(command);
        }

        Bukkit.getPluginManager().registerEvents(new EndermanSpawnListener(this), this);
    }

    public void loadZone() {
        zoneEnabled = getConfig().getBoolean("zone.enabled", false);
        zoneWorld = getConfig().getString("zone.world", "world");
        centerX = getConfig().getDouble("zone.center.x", 0.0);
        centerY = getConfig().getDouble("zone.center.y", 64.0);
        centerZ = getConfig().getDouble("zone.center.z", 0.0);
        radius = getConfig().getDouble("zone.radius", 32.0);
        shape = ZoneShape.fromConfig(getConfig().getString("zone.shape", "sphere"));

        if (radius < 0.0) {
            radius = 0.0;
        }

        if (Bukkit.getWorld(zoneWorld) == null) {
            getLogger().warning("Configured zone world does not currently exist: " + zoneWorld);
        }
    }

    public void setZone(Location location, double newRadius, ZoneShape newShape) {
        zoneEnabled = true;
        zoneWorld = location.getWorld().getName();
        centerX = location.getX();
        centerY = location.getY();
        centerZ = location.getZ();
        radius = newRadius;
        shape = newShape;

        getConfig().set("zone.enabled", true);
        getConfig().set("zone.world", zoneWorld);
        getConfig().set("zone.center.x", centerX);
        getConfig().set("zone.center.y", centerY);
        getConfig().set("zone.center.z", centerZ);
        getConfig().set("zone.radius", radius);
        getConfig().set("zone.shape", shape.configName());
        saveConfig();
    }

    public void setShape(ZoneShape newShape) {
        shape = newShape;
        getConfig().set("zone.shape", shape.configName());
        saveConfig();
    }

    public void setZoneEnabled(boolean enabled) {
        zoneEnabled = enabled;
        getConfig().set("zone.enabled", enabled);
        saveConfig();
    }

    public boolean isInsideZone(Location location) {
        if (!zoneEnabled || radius <= 0.0 || zoneWorld == null || location.getWorld() == null
                || !zoneWorld.equals(location.getWorld().getName())) {
            return false;
        }

        double deltaX = location.getX() - centerX;
        double deltaY = location.getY() - centerY;
        double deltaZ = location.getZ() - centerZ;

        if (shape == ZoneShape.RECTANGLE) {
            return Math.abs(deltaX) <= radius && Math.abs(deltaY) <= radius && Math.abs(deltaZ) <= radius;
        }

        return deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ <= radius * radius;
    }

    public String getZoneWorld() {
        return zoneWorld;
    }

    public double getCenterX() {
        return centerX;
    }

    public double getCenterY() {
        return centerY;
    }

    public double getCenterZ() {
        return centerZ;
    }

    public double getRadius() {
        return radius;
    }

    public ZoneShape getShape() {
        return shape;
    }

    public boolean isZoneEnabled() {
        return zoneEnabled;
    }

    public String formatStatus() {
        String status = zoneEnabled ? ChatColor.GREEN + "enabled" : ChatColor.RED + "disabled";
        return ChatColor.GRAY + "Status: " + status
                + ChatColor.GRAY + " | world=" + zoneWorld
                + ChatColor.GRAY + " | center=" + format(centerX) + ", " + format(centerY) + ", " + format(centerZ)
                + ChatColor.GRAY + " | radius=" + format(radius)
                + ChatColor.GRAY + " | shape=" + shape.configName();
    }

    private String format(double value) {
        return String.format(java.util.Locale.ROOT, "%.2f", value);
    }
}