Gamer Boro
πŸ“Ž 1 file 18,610 chars
πŸ“„
pasted-code-1790329558660.txt
txt 969 lines
β–Ά
You are an expert Java and Minecraft Paper plugin developer.

Build a complete, production-ready standalone Paper plugin named:

# EndMobControl

The plugin controls Enderman aggression and configurable mob behavior inside the Minecraft End dimension.

TARGET ENVIRONMENT

* Minecraft: Paper 26.2
* Paper API: `io.papermc.paper:paper-api:26.2.build.121-stable`
* Java: 25
* Standalone plugin
* No external runtime dependencies
* No Vault
* No EssentialsX
* No WorldGuard
* No PlaceholderAPI
* No Citizens
* No ItemsAdder
* No NMS unless absolutely necessary

The final output must compile into:

`EndMobControl-1.0.0.jar`

==================================================

1. ENDERMAN AGGRESSION
   ==================================================

Inside the End dimension, Endermen should automatically target the nearest eligible player.

A player is protected from this automatic Enderman targeting when wearing:

`CARVED_PUMPKIN`

in the helmet slot.

Only the helmet slot counts.

A pumpkin in:

* inventory
* offhand
* hotbar
* ground

does NOT provide protection.

Configuration:

enderman:
enabled: true

detection-radius: 32.0

target-nearest-player: true

pumpkin-protection:
enabled: true
material: CARVED_PUMPKIN

retarget-interval-ticks: 10

ignore:
spectators: true
creative: false
invisible: false

The nearest eligible player should be selected.

Example:

Player A = 10 blocks away, no pumpkin
Player B = 20 blocks away, no pumpkin

Target Player A.

If Player A equips a carved pumpkin:

Target Player B.

If every nearby player is wearing a carved pumpkin:

The Enderman should not intentionally target any of them.

If its current plugin-controlled target becomes invalid, clear the target or find another eligible player.

Do not continuously call `setTarget()` if the target has not changed.

This reduces unnecessary entity updates.

==================================================
2. ENDERMAN TARGET VALIDATION
=============================

Every configured retarget interval:

1. Verify the Enderman is still valid.
2. Verify it is still inside an affected End world.
3. Verify its current target is still eligible.
4. If valid, keep the target.
5. Otherwise find the nearest eligible player.
6. Set the new target.
7. If no eligible player exists, clear the plugin-controlled target.

A player becomes invalid if:

* offline
* dead
* outside the configured radius
* outside the End
* wearing the configured pumpkin
* spectator when spectators are ignored
* creative when creative players are ignored

Do not intentionally override targets that are unrelated to the plugin unless necessary.

The plugin should remember whether it assigned an Enderman's target so it can avoid unnecessarily interfering with normal Minecraft behavior.

==================================================
3. TAMED MOB DAMAGE
===================

Any player-tamed mob entering the End should become subject to End damage.

Examples include:

* Wolf
* Cat
* Parrot
* Horse
* Donkey
* Mule
* Llama
* Trader Llama
* Skeleton Horse
* Zombie Horse
* Other Bukkit/Paper tameable entities

Use the Paper/Bukkit API to determine whether an entity is tameable and whether it has an owner.

Default configuration:

tamed-mobs:
enabled: true

only-player-owned: true

damage:
enabled: true
amount: 2.0
interval-ticks: 40

entry:
damage-immediately: false
grace-period-ticks: 0

stop-damage-when-leaving-end: true

The mob receives the configured damage while inside the End.

Example:

2.0 damage every 40 ticks.

The system must continue until:

* mob dies
* mob leaves the End
* mob becomes invalid
* plugin is disabled

==================================================
4. CUSTOM MOB DAMAGE
====================

Provide an independent configurable list of entity types that should receive End damage.

Example:

custom-damage-mobs:
enabled: true

damage:
amount: 2.0
interval-ticks: 40

entry:
damage-immediately: false
grace-period-ticks: 0

mobs: []

Administrators can add any valid Bukkit EntityType.

Example:

mobs:

* ZOMBIE
* SKELETON
* CREEPER
* WOLF
* CAT
* HORSE

If ZOMBIE is listed:

Every zombie entering or found inside the End is damaged.

If ZOMBIE is not listed:

Normal zombies are unaffected by the custom system.

Invalid entity names must never crash the plugin.

Log:

`[EndMobControl] WARNING: Invalid entity type 'FAKE_MOB' in custom-damage-mobs.mobs`

and ignore only that entry.

==================================================
5. TAMED + CUSTOM DAMAGE OVERLAP
================================

A tamed mob can potentially match both systems.

Example:

Wolf is tamed.

WOLF is also listed in custom-damage-mobs.

Default behavior:

Do NOT double damage.

Add:

damage:
stacking:
enabled: false

When false:

The mob receives damage only once per applicable damage cycle.

When true:

Tamed damage and custom damage can independently apply.

Implement this carefully so the mob cannot accidentally receive duplicate damage simply because two tracking systems reference the same UUID.

==================================================
6. DAMAGE ON ENTRY
==================

Support optional immediate damage when entering the End.

Configuration:

entry:
damage-immediately: false
grace-period-ticks: 0

Examples:

damage-immediately: true

The entity receives damage as soon as it enters.

grace-period-ticks: 100

The entity waits 100 ticks before its periodic damage begins.

If both are enabled:

Apply immediate entry damage, then wait for the grace period before periodic damage.

==================================================
7. END WORLD DETECTION
======================

Support two modes.

Configuration:

end-world:
enabled: true

use-environment-detection: true

world-name: "world_the_end"

When:

use-environment-detection: true

Use:

World.Environment.THE_END

This is the primary method.

When false:

Only the configured world name is affected.

Do not rely exclusively on the world name by default.

==================================================
8. ENTITY ENTRY DETECTION
=========================

Entities may enter the End through:

* End portals
* Nether portals where applicable
* `/tp`
* `/teleport`
* plugin teleportation
* custom plugins
* other entity teleport mechanisms

Therefore use appropriate Bukkit/Paper events such as:

* EntityTeleportEvent
* EntityPortalEvent where useful
* EntitySpawnEvent
* EntityDeathEvent
* WorldUnloadEvent
* WorldLoadEvent

Also implement periodic validation.

Never rely on portal events alone.

==================================================
9. EXISTING ENTITIES
====================

When the plugin starts:

Scan all currently loaded affected End worlds.

Register:

* existing Endermen
* existing applicable tamed mobs
* existing custom-damage mobs

This ensures mobs already present before plugin startup are handled.

Do not load chunks just to find entities.

Only process entities in already-loaded chunks.

==================================================
10. ENTITY TRACKING
===================

Use UUID-based tracking.

Do not store strong references to entities unnecessarily.

Recommended:

TrackedMob:

* UUID
* entity type
* damage reason
* next damage tick
* entry tick
* world UUID where appropriate

Possible reasons:

TAMED
CUSTOM

Use a centralized manager.

Do NOT create one scheduler task for every mob.

Instead use one or a small number of centralized repeating tasks.

==================================================
11. PERFORMANCE
===============

The plugin must be optimized for servers with potentially thousands of entities.

Never:

* scan all worlds every tick
* force-load chunks
* load chunks solely for this plugin
* create one scheduler per entity
* repeatedly search all online players unnecessarily
* repeatedly call Enderman.setTarget() when target has not changed

Configuration:

performance:
entity-scan-interval-ticks: 20
enderman-target-interval-ticks: 10
damage-processing-interval-ticks: 10
maximum-entities-processed-per-cycle: 500

Process work incrementally if necessary.

Use loaded-world entities only.

==================================================
12. CHUNK HANDLING
==================

Do not force chunks to load.

If an entity's chunk is unloaded:

* do not attempt to load it
* safely remove or temporarily suspend tracking
* allow it to be rediscovered when the chunk/entity becomes loaded again

Avoid memory leaks.

==================================================
13. WORLD UNLOAD
================

When a world unloads:

Remove tracked entities belonging to that world.

Do not prevent world unloading.

When the world loads again:

Allow existing entities to be discovered normally.

==================================================
14. ENTITY DEATH
================

Listen for EntityDeathEvent.

Immediately remove the entity from tracking.

Also remove invalid UUIDs during periodic cleanup.

==================================================
15. ENTITY TELEPORTATION
========================

When an entity teleports:

Check the destination.

If destination is inside the End:

Evaluate it for tracking.

If destination leaves the End:

Stop End-specific tracking/damage.

This must work even if another plugin teleports the entity.

==================================================
16. CUSTOM DAMAGE SOURCE
========================

Use normal Bukkit/Paper entity damage:

`entity.damage(amount);`

Do not use:

* console commands
* `/kill`
* `/damage` commands
* NMS damage packets

The damage should interact with normal entity health mechanics.

==================================================
17. DAMAGE SAFETY
=================

Never apply damage to:

* dead entities
* invalid entities
* removed entities
* entities outside affected End worlds
* entities whose tracking reason is no longer valid

Do not apply damage if:

entity.getHealth() <= 0

Handle exceptions safely.

==================================================
18. CONFIGURATION
=================

Everything important must be configurable.

Create a detailed beginner-friendly `config.yml`.

Use comments extensively.

Suggested complete structure:

plugin:
debug: false

end-world:
enabled: true
use-environment-detection: true
world-name: "world_the_end"

enderman:
enabled: true
detection-radius: 32.0
target-nearest-player: true
retarget-interval-ticks: 10

pumpkin-protection:
enabled: true
material: CARVED_PUMPKIN

ignore:
spectators: true
creative: false
invisible: false

tamed-mobs:
enabled: true
only-player-owned: true

damage:
enabled: true
amount: 2.0
interval-ticks: 40

entry:
damage-immediately: false
grace-period-ticks: 0

custom-damage-mobs:
enabled: true

damage:
amount: 2.0
interval-ticks: 40

entry:
damage-immediately: false
grace-period-ticks: 0

mobs: []

damage:
stacking:
enabled: false

performance:
entity-scan-interval-ticks: 20
enderman-target-interval-ticks: 10
damage-processing-interval-ticks: 10
maximum-entities-processed-per-cycle: 500

==================================================
19. CONFIG VALIDATION
=====================

Validate configuration during startup and reload.

Invalid:

* negative damage
* zero intervals
* invalid entity names
* invalid material names
* invalid world configuration
* invalid numeric values

must not crash the server.

Use safe fallback values.

Log clear warnings.

==================================================
20. RELOAD
==========

Command:

`/endmobcontrol reload`

The reload process must:

1. Reload configuration.
2. Validate values.
3. Rebuild entity-type sets.
4. Update runtime settings.
5. Preserve valid tracking where possible.
6. Remove entities that no longer qualify.
7. Avoid creating duplicate tasks.

Repeated reloads must be safe.

==================================================
21. COMMANDS
============

Implement:

`/endmobcontrol`

`/endmobcontrol reload`

`/endmobcontrol status`

`/endmobcontrol debug`

Permissions:

`endmobcontrol.admin`
`endmobcontrol.reload`
`endmobcontrol.status`
`endmobcontrol.debug`

Default permission:

OP.

Provide tab completion.

==================================================
22. STATUS
==========

`/endmobcontrol status`

Display:

* plugin enabled
* Enderman system status
* tamed mob system status
* custom mob system status
* affected End worlds
* tracked tamed mobs
* tracked custom mobs
* managed Endermen

Example:

## EndMobControl Status

Plugin: ENABLED
Enderman Control: ENABLED
Tamed Mob Damage: ENABLED
Custom Mob Damage: ENABLED

Tracked Tamed Mobs: 12
Tracked Custom Mobs: 5
Managed Endermen: 43

Affected Worlds:

* world_the_end

==================================================
23. DEBUG
=========

Debug mode:

plugin:
debug: true

When enabled, log useful information about:

* entity entering End
* entity leaving End
* tracking
* untracking
* Enderman target changes
* damage
* configuration errors
* world detection

Do not spam thousands of identical messages.

Add sensible logging/throttling.

==================================================
24. ADMIN-FRIENDLY CONFIGURATION
================================

The configuration must be easy for a server administrator with little coding experience to understand.

Every option should have comments.

Include examples for:

1. Only Endermen behavior.
2. Tamed mobs taking damage.
3. Zombies taking damage.
4. All configured mobs taking damage quickly.
5. Pumpkin protection disabled.
6. Creative players ignored.
7. Damage disabled but Enderman system enabled.
8. Restricting behavior to one End world.

==================================================
25. EDGE CASES
==============

Correctly handle:

* Enderman already targeting player
* player equips pumpkin
* player removes pumpkin
* player dies
* player disconnects
* player leaves End
* player enters End
* multiple nearby players
* all players wearing pumpkins
* spectator players
* creative players
* invisible players
* tamed wolf
* tamed cat
* tamed horse
* tamed parrot
* untamed wolf
* custom zombie
* custom skeleton
* invalid entity configuration
* entity teleported into End
* entity teleported out
* entity dies
* entity chunk unload
* world unload
* server restart
* plugin reload
* duplicate damage
* large mob populations

==================================================
26. PROJECT ARCHITECTURE
========================

Use clean separation of responsibilities.

Suggested:

src/main/java//

EndMobControl.java

command/
EndMobControlCommand.java
EndMobControlTabCompleter.java

config/
ConfigManager.java
ConfigValidator.java

end/
EndWorldManager.java

enderman/
EndermanManager.java
EndermanTargetManager.java

damage/
MobDamageManager.java
TrackedMob.java
DamageReason.java

listener/
EntityListener.java
TeleportListener.java
WorldListener.java

util/
EntityUtils.java
PlayerUtils.java
DebugLogger.java

Do not over-engineer the plugin.

Keep classes focused.

==================================================
27. BUILD SYSTEM
================

Provide either:

Gradle

or

Maven

with a complete build file.

Use Java 25.

The project must build successfully without external runtime dependencies.

==================================================
28. plugin.yml
==============

Generate a valid plugin.yml.

Use:

name: EndMobControl
version: 1.0.0
main: .EndMobControl
api-version: '26.2'

Include:

* description
* author
* commands
* permissions

==================================================
29. README
==========

Create a complete README.md containing:

* Overview
* Features
* Requirements
* Installation
* Commands
* Permissions
* Configuration
* Explanation of Enderman behavior
* Pumpkin protection
* Tamed mob damage
* Custom mob damage
* Damage stacking
* Grace periods
* Performance
* Troubleshooting
* Example configurations
* Reload instructions

==================================================
30. TESTING
===========

Before finalizing, test/review all of the following:

Enderman:

* nearest target
* pumpkin protection
* target switching
* multiple players
* creative
* spectator
* leaving End
* entering End

Damage:

* tamed mobs
* custom mobs
* overlapping systems
* immediate entry damage
* grace period
* periodic damage
* leaving End
* death
* teleportation

Infrastructure:

* startup
* shutdown
* reload
* world unload
* world load
* invalid config
* invalid entity
* large numbers of mobs
* scheduler duplication
* memory cleanup

==================================================
31. FINAL CODE QUALITY REQUIREMENTS
===================================

The final implementation must:

* compile successfully
* contain no pseudocode
* contain no TODO placeholders
* contain no missing methods
* contain no fake API calls
* contain no unnecessary dependencies
* be compatible with Java 25
* target Paper 26.2
* avoid NMS
* avoid deprecated APIs where possible
* safely handle nulls
* safely handle invalid entities
* avoid memory leaks
* avoid scheduler duplication
* avoid unnecessary entity scans
* be production-ready

Before presenting the final project, perform a complete internal code review.

==================================================
32. FINAL DELIVERABLE
=====================

Return the complete project:

EndMobControl/
β”œβ”€β”€ build.gradle OR pom.xml
β”œβ”€β”€ README.md
└── src/
└── main/
β”œβ”€β”€ java/
β”‚   └── /
β”‚       └── all source files
└── resources/
β”œβ”€β”€ plugin.yml
└── config.yml

Also provide:

* exact build command
* exact JAR output location
* installation instructions
* default configuration explanation
* complete list of commands
* complete permissions list

The plugin must be ready to place directly into:

`plugins/`

on a Paper 26.2 server.
Kodari AI
KodariSep 25 at 9:53 am 2
EndMobControl
Controls Enderman aggression and configurable mob behavior inside the Minecraft End dimension. Automatically targets nearest eligible players with pumpkin protection, applies periodic damage to tamed and custom-configured mobs, and manages entity tracking via UUIDs. Features centralized scheduling, configurable damage intervals, grace periods, and world detection. Includes admin commands for reload, status, and debug, with comprehensive configuration validation and performance optimizations.
  1. Create the Java 25/Paper Gradle project, plugin metadata, and commented default configuration.

  2. Implement validated settings, End-world detection, Enderman targeting, and centralized mob-damage tracking.

  3. Wire lifecycle/events, admin commands, reload/status/debug, and documentation.

Created the EndMobControl project with Paper 26.2 metadata, a commented default config, README, and Java 25 Gradle build.

  • Build: run gradle build from the project directory.

  • JAR: build/libs/EndMobControl-1.0.0.jar

  • Install: copy the JAR into the server’s plugins/ directory and restart. Edit plugins/EndMobControl/config.yml; apply changes with /endmobcontrol reload.

  • Defaults: detects End worlds by environment, protects players wearing the configured pumpkin in the helmet slot, and enables tamed-mob damage. The custom-damage entity list starts empty.

  • Commands: /endmobcontrol, /endmobcontrol reload, /endmobcontrol status, /endmobcontrol debug (also available through /emc).

  • Permissions: endmobcontrol.admin, endmobcontrol.reload, endmobcontrol.status, endmobcontrol.debug; all default to OP, and admin inherits the three subcommand permissions.

The implementation uses one centralized tick task, UUID-based tracking, bounded processing queues, loaded-world scans, and no forced chunk loading or runtime plugin dependencies. I did not run a local build.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
README.md
settings.gradle
Code
15 1,448
src/main/java/com/kodari/endmobcontrol/EndMobControl.java
package com.kodari.endmobcontrol;

import com.kodari.endmobcontrol.command.EndMobControlCommand;
import com.kodari.endmobcontrol.config.ConfigManager;
import com.kodari.endmobcontrol.damage.MobDamageManager;
import com.kodari.endmobcontrol.end.EndWorldManager;
import com.kodari.endmobcontrol.enderman.EndermanManager;
import com.kodari.endmobcontrol.listener.EntityListener;
import com.kodari.endmobcontrol.listener.WorldListener;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.Objects;

public final class EndMobControl extends JavaPlugin {
    private ConfigManager configManager;
    private EndWorldManager endWorldManager;
    private EndermanManager endermanManager;
    private MobDamageManager mobDamageManager;
    private long currentTick;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        configManager = new ConfigManager(this);
        configManager.reload();
        endWorldManager = new EndWorldManager(configManager);
        endermanManager = new EndermanManager(this, configManager, endWorldManager);
        mobDamageManager = new MobDamageManager(this, configManager, endWorldManager);

        Bukkit.getPluginManager().registerEvents(
                new EntityListener(endWorldManager, endermanManager, mobDamageManager), this);
        Bukkit.getPluginManager().registerEvents(
                new WorldListener(endermanManager, mobDamageManager), this);

        EndMobControlCommand command = new EndMobControlCommand(this);
        Objects.requireNonNull(getCommand("endmobcontrol"), "endmobcontrol command missing from plugin.yml")
                .setExecutor(command);
        Objects.requireNonNull(getCommand("endmobcontrol"), "endmobcontrol command missing from plugin.yml")
                .setTabCompleter(command);

        Bukkit.getScheduler().runTaskTimer(this, () -> {
            currentTick++;
            endermanManager.tick(currentTick);
            mobDamageManager.tick(currentTick);
        }, 1L, 1L);
    }

    @Override
    public void onDisable() {
        if (endermanManager != null) {
            endermanManager.shutdown();
        }
        if (mobDamageManager != null) {
            mobDamageManager.shutdown();
        }
    }

    public void reloadPlugin() {
        configManager.reload();
        endermanManager.onReload();
        mobDamageManager.onReload(currentTick);
    }

    public ConfigManager config() {
        return configManager;
    }

    public EndWorldManager endWorlds() {
        return endWorldManager;
    }

    public EndermanManager endermen() {
        return endermanManager;
    }

    public MobDamageManager mobDamage() {
        return mobDamageManager;
    }
}