.matazzz

Create a Minecraft paper 1.21.11 version plugin called “Dragon Egg buff”.

The plugin must detect when a player is holding a Dragon Egg in their hand. When this happens, the plugin should continuously scan for nearby players within a configurable radius (default 150 blocks).

All nearby players (except the holder) must receive the Minecraft glowing outline effect which can only be seen by those who hold the egg. The holder must NOT be affected.

The system should update every 2–3 seconds and continuously refresh the glowing effect while the Dragon Egg is being held. When the player stops holding the Dragon Egg, all previously affected players must have their glowing effect removed.

Kodari AI
KodariJun 14 at 5:59 pm 16
DragonEggBuff
A Paper 1.21.1 plugin that grants the Dragon Egg a unique passive ability. Any player holding a Dragon Egg in their main or off-hand continuously detects all nearby players within a configurable radius (default 150 blocks) and applies a glowing outline effect to them — visible exclusively to the egg holder via NMS metadata packets. The glow refreshes every 2–3 seconds and is cleanly removed when the egg is no longer held or a player leaves.

Plan:

  1. build.gradle + settings.gradle — paperweight-userdev for NMS access

  2. DragonEggBuff.java — main class, wires everything together

  3. GlowManager.java — tick loop, NMS packet sending, state tracking

  4. DragonEggListener.java — cleanup on player quit

  5. plugin.yml + config.yml

How it works:

Concern
Solution
Per-player visibility
ClientboundSetEntityDataPacket
sent only to the holder — the server’s entity state is never modified, so no one else sees the glow
Glow bit
Shared flags byte, bit
0x40
(index 6) is the glowing flag per the Minecraft protocol spec
State tracking
holderGlowMap
stores
holderUUID → Set<glowingUUIDs>
so stale targets (went out of range, logged off, holder dropped egg) are always cleaned up
No effect creep
Every tick re-evaluates who should glow; anyone no longer qualifying gets a
false
glow packet immediately
Reload-safe
stop()
strips all applied glow effects before config is re-read

⚠️ Requires Paper 1.21.1 — the NMS classes (ClientboundSetEntityDataPacket, CraftPlayer, Entity.DATA_SHARED_FLAGS_ID) are Paper internals. The paperweight-userdev Gradle plugin exposes them at compile time. Deploy the reobfuscated jar produced by the reobfJar Gradle task.

.matazzz

“You are not clearing previously applied glow states. You must reset all affected players every update tick before reapplying glow based on current holders.”

Kodari AI
KodariJun 14 at 6:19 pm 6

The current logic tries to diff old vs new sets, but never fully wipes the previous glow state before rebuilding it. The fix: at the start of every tick, remove glow from all currently tracked players first, clear the map, then reapply fresh.

Also clean up the now-unused Iterator import:The wildcard import already covers everything — no change needed there.

What changed and why:

The old approach diffed previouslyGlowing vs nowInRange to remove stragglers, but it never cleared state from the previous tick before building the new set. This meant:

  • A player who moved out of range between ticks could remain glowing if the diff logic had a gap

  • Multiple holders could leave conflicting glow states that removeGlowIfSafe wouldn’t catch cleanly

New approach — full reset each tick:

  1. Strip first — iterate every UUID in holderGlowMap and call setGlowing(false) on each; then clear() the entire map

  2. Reapply fresh — scan current holders, find players in range, call setGlowing(true), rebuild the map from scratch

This guarantees the glow state is always a 100% accurate reflection of the current tick’s holders and radii, with zero stale entries possible.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
7 186
src/main/java/com/kodari/dragoneggbuff/DragonEggBuff.java
package com.kodari.dragoneggbuff;

import org.bukkit.plugin.java.JavaPlugin;

public class DragonEggBuff extends JavaPlugin {

    private GlowManager glowManager;

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

        glowManager = new GlowManager(this);
        glowManager.start();

        getServer().getPluginManager().registerEvents(new DragonEggListener(glowManager), this);

        getLogger().info("DragonEggBuff enabled.");
    }

    @Override
    public void onDisable() {
        if (glowManager != null) {
            glowManager.stop();
        }
        getLogger().info("DragonEggBuff disabled.");
    }
}