kinitolol

Target: Paper 1.21.11 (Java 17+) Build a highly optimized, production-grade Paper plugin that embeds a web server and provides a real-time 3D web visualization of server activity.

Primary Goal:

Create a live-rendered web spectator system suitable for streaming without using a Minecraft client.

Core Requirements:

The plugin must maintain a highly efficient in-memory world state and send real-time updates to connected web clients with minimal performance impact.

Tracking Requirements: • Player movement (rate-limited and threshold-based, not every tiny coordinate change) • Block placement and breaking • Entity spawn/despawn • Optimized entity movement tracking (distance-threshold or interval-based) • Chunk load/unload • Optional combat events Optimization Requirements: • Zero heavy main-thread blocking operations • All mesh building async • Use chunk-based spatial partitioning • Only track loaded chunks • Only send delta updates • Batch WebSocket payloads • Implement adaptive throttling under high entity/player load • Configurable update rate • Configurable web render distance • Movement compression (send only meaningful changes) • Optional entity tracking filters (e.g., ignore passive mobs if configured) Networking: • Embedded high-performance web server • WebSocket endpoint for real-time updates • Efficient binary protocol preferred over JSON if performance benefit is significant • Backpressure handling for slow clients Configuration:

Provide a configuration file that includes at minimum: • Web server port (user-configurable) • Bind address (optional) • Render distance for web visualization • Update rate (ticks or milliseconds) • Entity tracking settings • Combat tracking toggle • Max WebSocket clients • Performance throttling thresholds The plugin must read the port from the configuration file and start the embedded web server using that configured port.

Frontend Requirements: • Three.js (or equivalent WebGL renderer) • Chunk-based terrain mesh generation • Simplified but recognizable player and entity models • Free camera mode • Follow player mode • Automatic action camera mode (prioritize combat or player clustering) • Smooth interpolation between updates Performance Constraint:

The plugin must not cause noticeable TPS degradation on a moderately populated server.

Architecture Expectations: • Strict separation of event capture, world state cache, meshing system, and networking • Efficient spatial indexing • Minimal object allocation in hot paths • Designed for scalability

Kodari AI
KodariFeb 27 at 11:16 am 25,721 (v2)

I’ll create a production-grade live spectator plugin with embedded web server and real-time 3D visualization.

LiveSpectator
A high-performance Paper plugin providing real-time 3D web visualization of server activity through an embedded web server and WebSocket system. Features optimized chunk-based tracking, entity monitoring, delta updates, adaptive throttling, and a Three.js frontend with multiple camera modes for streaming without a Minecraft client. Designed for zero TPS impact with async mesh building and spatial partitioning.

I’ll create a high-performance live spectator system with embedded web server and 3D visualization.

Plan:

  • Embedded Javalin web server with WebSocket support

  • Async chunk mesh generation with spatial partitioning

  • Delta-based update system with adaptive throttling

  • Three.js frontend with multiple camera modes

  • Zero main-thread blocking operations

Now I’ll add the command registration to the main plugin class:

Production-grade LiveSpectator plugin created with embedded web server, real-time WebSocket updates, async mesh generation, adaptive throttling, Three.js visualization, and zero TPS impact design.

kinitolol

update it so that you can change the websocket port too

Kodari AI
KodariFeb 27 at 11:23 am 8,134 (v2)

I’ll update the plugin to make the WebSocket port configurable.

I’ll add a configurable WebSocket port separate from the HTTP server port.

Updated the plugin to allow configuring the WebSocket port separately via the websocket-port setting in config.yml (defaults to 8081).

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
Code
22 2,160
src/main/java/com/livespectator/LiveSpectatorPlugin.java
package com.livespectator;

import com.livespectator.command.SpectatorCommand;
import com.livespectator.config.ConfigManager;
import com.livespectator.listener.WorldEventListener;
import com.livespectator.manager.*;
import com.livespectator.service.MeshingService;
import com.livespectator.service.UpdateBatcher;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class LiveSpectatorPlugin extends JavaPlugin {
    
    private ConfigManager configManager;
    private WorldStateManager worldStateManager;
    private ChunkTrackerManager chunkTrackerManager;
    private EntityTrackerManager entityTrackerManager;
    private PlayerTrackerManager playerTrackerManager;
    private WebSocketManager webSocketManager;
    private WebServerManager webServerManager;
    private MeshingService meshingService;
    private UpdateBatcher updateBatcher;
    
    @Override
    public void onEnable() {
        this.configManager = new ConfigManager(this);
        this.configManager.loadConfig();
        
        this.worldStateManager = new WorldStateManager(this);
        this.chunkTrackerManager = new ChunkTrackerManager(this);
        this.entityTrackerManager = new EntityTrackerManager(this);
        this.playerTrackerManager = new PlayerTrackerManager(this);
        this.meshingService = new MeshingService(this);
        this.updateBatcher = new UpdateBatcher(this);
        this.webSocketManager = new WebSocketManager(this);
        this.webServerManager = new WebServerManager(this);
        
        Bukkit.getPluginManager().registerEvents(new WorldEventListener(this), this);
        
        this.getCommand("spectator").setExecutor(new SpectatorCommand(this));
        
        if (this.configManager.isWebServerEnabled()) {
            this.webServerManager.start();
            getLogger().info("Web server started on port " + this.configManager.getWebServerPort());
            getLogger().info("WebSocket server started on port " + this.configManager.getWebSocketPort());
        }
        
        this.startUpdateTask();
        
        getLogger().info("LiveSpectator enabled successfully!");
    }
    
    @Override
    public void onDisable() {
        if (this.webServerManager != null) {
            this.webServerManager.stop();
        }
        
        if (this.meshingService != null) {
            this.meshingService.shutdown();
        }
        
        getLogger().info("LiveSpectator disabled!");
    }
    
    private void startUpdateTask() {
        long updateInterval = this.configManager.getUpdateRateMs() / 50;
        if (updateInterval < 1) updateInterval = 1;
        
        Bukkit.getScheduler().runTaskTimer(this, () -> {
            if (this.webSocketManager.hasClients()) {
                this.updateBatcher.processBatch();
            }
        }, 20L, updateInterval);
    }
    
    public void reload() {
        this.configManager.loadConfig();
        getLogger().info("Configuration reloaded!");
    }
}