suman731220

Create the COMPLETE and FINAL version of a Minecraft Optimization Plugin named "HyperOptimize" for Spigot/Paper version 1.21.x.

Objective: Combine extreme chunk loading speeds with strict entity limits and aggressive lag removal in a single plugin.

CORE REQUIREMENTS:

1. Extreme Chunk Loading (Priority #1 - The Speed Engine): - Goal: Instant loading. Zero waiting for players moving fast (Elytra/Sprinting). - Critical Logic (Lag Prevention): - Listen to PlayerMoveEvent. - OPTIMIZATION: Do NOT run the logic on every tick/pixel movement. Only run if the player has moved to a NEW CHUNK (Compare from.getChunk() vs to.getChunk()). - Loading Logic: - Get the player's velocity/direction. - Identify the next 3-5 chunks in that direction. - Use Paper's Async API to load them. - PRIORITY: You must use ChunkPriority.URGENT (or URGENT level in getChunkAtAsync).

2. Hard Entity Limiting (Replaces Mob Stacking): - Goal: Strict limits per chunk. No stacking visuals. - Logic: - Listen to CreatureSpawnEvent. - Check chunk.getEntities(). Count how many are HOSTILE or PASSIVE. - If Hostile Count >= config.hostile-limit, CANCEL the spawn. - If Passive Count >= config.passive-limit, CANCEL the spawn. - Exceptions: Do NOT cancel spawns for Wither, Ender Dragon, or mobs that have a Custom Name (Name Tag). - Performance: Ensure you only count LivingEntity to avoid counting dropped items or arrows as "mobs".

3. Smart Cleaner (Ground Items & XP): - Item Clear: Run a task every clear-interval seconds. - Whitelist: Check item.getType() against the config whitelist. NEVER remove whitelisted items. - Warnings: Broadcast formatted messages at 60s, 30s, 5s. - XP Orb Merger: Listen to EntitySpawnEvent (for XP Orbs) or run a timer. Merge nearby XP orbs into a single orb with the combined value to reduce entity count.

4. CPU Savers (AI & Redstone): - Smart AI Culling: Run a timer every 5-10 seconds. - If Server TPS < 18.0: Find mobs > 30 blocks from players and setAI(false). - Recovery: If TPS > 19.0 OR player gets within 10 blocks, setAI(true) so they move again. - Redstone Guard: Limit redstone updates per chunk. If updates > redstone-limit in 1 second, cancel event.

Configuration (config.yml):

  • chunk-loading: "EXTREME"
  • mob-limits:

- hostile: 20 - passive: 15

  • clear-interval: 300
  • whitelist-items: [DIAMOND_SWORD, NETHER_STAR, BEACON, SHULKER_BOX, ELYTRA]
  • redstone-limit: 200

Output Deliverables:

  1. Main.java: Registers listeners and tasks.
  2. FastChunkLoader.java: Implements the URGENT loading logic with "New Chunk Only" check.
  3. EntityLimiter.java: Implements the hard limit logic.
  4. Cleaner.java: Implements Item clear and XP merging.
  5. plugin.yml: Correct version and permissions.
Kodari AI
KodariJan 3 at 1:54 am 8,043 (v2)

I’ll create a comprehensive optimization plugin with extreme chunk loading, entity limiting, and aggressive lag removal.

HyperOptimize
Advanced Minecraft server optimization plugin combining instant chunk loading with URGENT priority, strict per-chunk entity limits, smart item clearing with XP orb merging, TPS-based AI culling, and redstone limiters. Designed for high-performance servers running 1.21.x with extreme player movement speeds.

HyperOptimize Complete!

Core Features Delivered:

  1. Extreme Chunk Loading - URGENT priority preloading with new-chunk-only checks (FastChunkLoader)

  2. Hard Entity Limits - Per-chunk hostile/passive caps with named mob exceptions (EntityLimiter)

  3. Smart Cleaner - Timed item clearing with whitelist + XP orb merging (Cleaner)

  4. AI Culling - TPS-based mob AI disabling with distance recovery (AIManager)

  5. Redstone Guard - Per-chunk update limiting (RedstoneGuard)

Key Optimizations:

  • Only runs chunk loading when player enters new chunk (prevents per-tick lag)

  • Uses Paper’s async API with ChunkPriority.URGENT

  • Entity counting filters to LivingEntity only

  • XP orb merger reduces entity count by combining nearby orbs

  • AI restoration when players approach or TPS recovers

Commands: /ho reload, /ho stats, /ho clear

suman731220

Fix the compilation errors in 'FastChunkLoader.java' for Paper 1.21.

Problem: The symbol 'io.papermc.paper.world.ChunkPriority' is not being recognized. This is likely due to an incorrect package path or API version mismatch in the code.

Required Changes:

  1. Update Imports: Instead of using the full path in the method call, use the correct Paper-API import.
  2. Proper Method Call: In Paper 1.21, use the Consumer-based or Priority-based getChunkAtAsync correctly.
  3. Alternative Logic: If 'ChunkPriority.URGENT' is causing issues, use the integer-based priority or the simplified 'getChunkAtAsync(x, z, true)' which defaults to a high-priority load.

Corrected Code Logic for FastChunkLoader.java: Replace the problematic lines with this safer approach:

```java // Use a more compatible way to call Async chunk loading world.getChunkAtAsync(targetX, targetZ, true).thenAccept(chunk -> { // Chunk loaded successfully });

suman731220

Fix the compilation errors in 'FastChunkLoader.java' for Paper 1.21.

THE PROBLEM: The compiler cannot find the symbol 'io.papermc.paper.world.ChunkPriority'. This is causing the 'getChunkAtAsync' method calls to fail.

THE FIX:

  1. Remove hardcoded Priority: Instead of using the full package path 'io.papermc.paper.world.ChunkPriority.URGENT' inside the method, use the standard Paper async loading method.
  2. Modern Paper Approach: In 1.21, the best way to load chunks asynchronously without errors is using the 'CompletableFuture' return type or the simplified 'getChunkAtAsync(x, z, gen)' method.
  3. Optimized Logic: Replace the problematic lines (72, 75, 76, 77, 78) with:

'location.getWorld().getChunkAtAsync(targetX, targetZ, true);' This automatically uses the default high priority and is much safer for compilation.

RE-WRITE REQUEST: Please rewrite the 'FastChunkLoader.java' file. Ensure all 'getChunkAtAsync' calls do not use the 'ChunkPriority' class directly to avoid these package-missing errors. Use only the methods available in the stable Paper 1.21 API.

Kodari AI
KodariJan 4 at 9:13 am 3,725 (v2)

I’ll read the FastChunkLoader.java file first to understand the current implementation and fix the compilation errors.

Now I’ll fix the FastChunkLoader.java file by removing the ChunkPriority references and using the standard Paper async chunk loading method.

Fixed compilation errors by removing all io.papermc.paper.world.ChunkPriority.URGENT references and using the standard getChunkAtAsync(x, z, gen) method which is stable across Paper 1.21.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
10 651
src/main/java/com/hyperoptimize/Main.java
package com.hyperoptimize;

import com.hyperoptimize.listeners.EntityLimiter;
import com.hyperoptimize.listeners.FastChunkLoader;
import com.hyperoptimize.listeners.RedstoneGuard;
import com.hyperoptimize.tasks.AIManager;
import com.hyperoptimize.tasks.Cleaner;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class Main extends JavaPlugin {
    
    private static Main instance;
    private Cleaner cleaner;
    private AIManager aiManager;
    
    @Override
    public void onEnable() {
        instance = this;
        
        saveDefaultConfig();
        
        FastChunkLoader chunkLoader = new FastChunkLoader(this);
        EntityLimiter entityLimiter = new EntityLimiter(this);
        RedstoneGuard redstoneGuard = new RedstoneGuard(this);
        
        Bukkit.getPluginManager().registerEvents(chunkLoader, this);
        Bukkit.getPluginManager().registerEvents(entityLimiter, this);
        Bukkit.getPluginManager().registerEvents(redstoneGuard, this);
        
        cleaner = new Cleaner(this);
        cleaner.start();
        
        if (getConfig().getBoolean("ai-culling.enabled", true)) {
            aiManager = new AIManager(this);
            aiManager.start();
        }
        
        getCommand("hyperoptimize").setExecutor(new CommandHandler(this));
        
        getLogger().info("HyperOptimize enabled - EXTREME mode activated!");
        getLogger().info("Chunk Loading: " + getConfig().getString("chunk-loading"));
        getLogger().info("Entity Limits - Hostile: " + getConfig().getInt("mob-limits.hostile") + 
                        " | Passive: " + getConfig().getInt("mob-limits.passive"));
    }
    
    @Override
    public void onDisable() {
        if (cleaner != null) {
            cleaner.stop();
        }
        if (aiManager != null) {
            aiManager.stop();
        }
        getLogger().info("HyperOptimize disabled!");
    }
    
    public static Main getInstance() {
        return instance;
    }
}