iqled.

make me a 1.21.11 paper plugin that upon having any form of broadcasting message that message is then set a radius of 16 chunks from the broadcasting point, so e.g a player dies that death is then broadcasted only to those 16 chunks from that players deathpoint. this applies for any form of broadcasting involving pets dying, leave and joins and ect, have this apply for the death sound effect aswell set on the server which is the wither dying sound effect

Kodari AI
KodariSep 16 at 7:52 pm 2
ChunkLocalBroadcast
Intercepts all server-wide broadcast messages (player deaths, joins, leaves, pet deaths, etc.) and re-broadcasts them only to players within a 16-chunk radius of the origin point. Captures the configured wither death sound effect and plays it only for players within that same radius, creating localized, immersive world events instead of global announcements.
  1. Create the Gradle Paper 1.21.11 plugin project and metadata.

  2. Add a radius service using a 16-chunk horizontal range.

  3. Localize joins, quits, kicks, deaths, tameable-pet deaths, and player chat.

  4. Play the Wither death sound only to recipients within the same radius.

  5. Add a documented API for other plugin code to send location-aware broadcasts.

Created the Paper 1.21.11 plugin project with:

  • 16-chunk / 256-block localized broadcast radius.

  • Localized player join, quit, kick, death, and chat messages.

  • Localized tameable-pet death messages.

  • Wither death sound played to nearby players for player and pet deaths.

  • Configurable radius, sound, and pet-death message.

  • Public RadiusBroadcastService API for other plugin code to send location-based broadcasts.

Arbitrary broadcasts from other plugins cannot automatically be assigned a location because Bukkit’s generic broadcast API does not include a source location. Other plugins can use:

Java
plugin.getBroadcasts().broadcast(location, message);

Configuration is in src/main/resources/config.yml.

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

import org.bukkit.plugin.java.JavaPlugin;

public final class LocalizedBroadcastsPlugin extends JavaPlugin {

    private RadiusBroadcastService broadcasts;

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

        int radiusChunks = Math.max(0, getConfig().getInt("radius-chunks", 16));
        this.broadcasts = new RadiusBroadcastService(this, radiusChunks);

        getServer().getPluginManager().registerEvents(
                new LocalizedBroadcastListener(
                        broadcasts,
                        getConfig().getString("death-sound", "entity.wither.death"),
                        getConfig().getString("pet-death-message", "&c{owner}&7's {pet} died.")
                ),
                this
        );
    }

    /**
     * Broadcasts a message to players within the configured radius of a location.
     * Other plugins can use this instead of a global server broadcast when they
     * have a meaningful world location for the message.
     */
    public RadiusBroadcastService getBroadcasts() {
        return broadcasts;
    }
}