.seba1982

make a server side plugin that makes you only see chat messeges from 26 chunks (make a gamerule that you can set it custom)

Kodari AI
KodariJul 16 at 8:53 pm 2

I’ll create a proximity chat plugin that limits chat visibility by chunk distance.

ChatChunks
A proximity chat plugin that limits message visibility based on chunk distance. Registers a custom /gamerule chatRange (default 26 chunks) so server admins can configure the radius per-world. Players outside the range won't see each other's messages. Features cross-world blocking, permission-based bypass for staff, and a config fallback for servers without custom gamerule support. Lightweight and server-side only.
Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
5 155
src/main/java/com/example/chatchunks/ChatChunksPlugin.java
package com.example.chatchunks;

import com.example.chatchunks.listener.ChatListener;
import org.bukkit.GameRule;
import org.bukkit.World;
import org.bukkit.plugin.java.JavaPlugin;

public class ChatChunksPlugin extends JavaPlugin {

    private GameRule<Integer> chatRangeRule;
    private boolean gameRuleSupported;
    private int defaultRange;
    private boolean blockCrossWorld;

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

        try {
            chatRangeRule = GameRule.register("chatRange", GameRule.Type.INTEGER, defaultRange);
            gameRuleSupported = true;
            getLogger().info("Registered custom gamerule: /gamerule chatRange <value>");
        } catch (Throwable t) {
            chatRangeRule = null;
            gameRuleSupported = false;
            getLogger().info("Custom gamerule not supported on this server version. Using config value (" + defaultRange + " chunks).");
        }

        getServer().getPluginManager().registerEvents(new ChatListener(this), this);
        getLogger().info("ChatChunks enabled - default range: " + defaultRange + " chunks");
    }

    @Override
    public void reloadConfig() {
        super.reloadConfig();
        reloadConfigValues();
    }

    private void reloadConfigValues() {
        defaultRange = getConfig().getInt("default-range", 26);
        blockCrossWorld = getConfig().getBoolean("block-cross-world", true);
    }

    public int getChatRange(World world) {
        if (gameRuleSupported && chatRangeRule != null && world != null) {
            try {
                Integer value = world.getGameRuleValue(chatRangeRule);
                if (value != null) return value;
            } catch (Exception ignored) {}
        }
        return defaultRange;
    }

    public boolean isBlockCrossWorld() {
        return blockCrossWorld;
    }
}