Marius Blanchard

je veux un plugin paper 26.3 qui quand on pose ou detruit un bloc ans un chunk sa fait pareil dans tout les autre

Kodari AI
KodariTue at 5:24 pm 1
ChunkSync
ChunkSync is a Paper 1.26.3 plugin that synchronizes block placement and destruction across all chunks. When a player places or breaks a block in any chunk, the same block modification is replicated in every other chunk on the server. The plugin listens to BlockPlaceEvent and BlockBreakEvent, captures the block type, state, and location relative to the chunk origin, then applies the identical change to all loaded chunks. It handles both placing and breaking symmetrically, supports all block types including tile entities, and maintains a synchronized world state. The plugin provides configurable options to limit synchronization to specific worlds or dimensions, and includes a toggle command for players to enable or disable the effect globally.

Je vais synchroniser les blocs à la même position relative dans les chunks chargés du même monde.

Le placement et la destruction sont reproduits aux mêmes coordonnées relatives dans les chunks chargés du même monde.

Les chunks non chargés ne sont pas modifiés.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
4 70
src/main/java/fr/kodari/chunkmirror/ChunkMirrorPlugin.java
package fr.kodari.chunkmirror;

import com.cryptomorin.xseries.XMaterial;
import org.bukkit.Chunk;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.plugin.java.JavaPlugin;

public final class ChunkMirrorPlugin extends JavaPlugin implements Listener {
    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this);
    }

    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void onPlace(BlockPlaceEvent event) {
        mirror(event.getBlockPlaced(), event.getBlockPlaced().getBlockData());
    }

    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void onBreak(BlockBreakEvent event) {
        XMaterial.matchXMaterial("AIR")
                .map(XMaterial::parseMaterial)
                .ifPresent(material -> mirror(event.getBlock(), material.createBlockData()));
    }

    private void mirror(Block source, BlockData data) {
        int x = source.getX() & 15;
        int z = source.getZ() & 15;
        Chunk original = source.getChunk();
        for (Chunk chunk : source.getWorld().getLoadedChunks()) {
            if (chunk.getX() == original.getX() && chunk.getZ() == original.getZ()) {
                continue;
            }
            chunk.getBlock(x, source.getY(), z).setBlockData(data, false);
        }
    }
}