
NeuroLag
A smart, resource-aware optimization plugin that dynamically adjusts Mob AI based on server TPS and RAM to ensure a lag-free SMP experience
NeuroLag 1.7.0
release11 мая 2026 г.[1.7.0] — 2026-05-01 — Major Architecture & Algorithm Improvements
🚀 Major Features
-
Safe Mode for Critical State
- Added
safe-modeconfiguration option under critical TPS tier - Implemented
SafeModeOptimizerto selectively disable dangerous AI components while preserving essential game mechanics - Prevents over-optimization that breaks villager trading, mob escaping water, and other critical behaviors
- Added
-
LagEngine Refactoring
- Extracted optimization logic into dedicated classes following Single Responsibility Principle:
MobCuller- Entity culling with intelligent importance scoringAIThrottler- AI throttling and tick managementSpawnSuppressor- Spawn rate adjustment logic
- Improved code maintainability and testability
- Extracted optimization logic into dedicated classes following Single Responsibility Principle:
-
Event-Driven Architecture
- Implemented EventBus pattern for decoupled optimization logic:
OptimizationEventBus- Central event dispatcherOptimizationEvent- Event data containerOptimizationListener- Interface for event handlers- Enables plugins/addons to react to optimization state changes
- Implemented EventBus pattern for decoupled optimization logic:
-
Mob Importance Scoring System
- Created
MobImportanceScorerwith comprehensive importance evaluation:- Base scores for all entity types (bosses: 1000, villagers: 100, hostile: 10-20, etc.)
- Dynamic scoring factors: named mobs (10x), tamed mobs (20x), equipment (1.5x)
- Integration with MobCuller for intelligent culling decisions
- Created
-
Mob Behavior Groups
- Implemented
MobBehaviorGroupssystem for targeted optimization:- PASSIVE (low priority): Cows, pigs, sheep, chickens
- AGGRESSIVE (high priority): Zombies, skeletons, creepers
- NEUTRAL (medium priority): Endermen, iron golems
- SPECIAL (preserve): Villagers, bosses, named mobs
- AQUATIC (water-based): Dolphins, guardians, squids
- Implemented
🧠 Algorithm Improvements
-
RegionOptimizer Enhancements
- Dynamic Region Sizing: Automatically adjusts region size based on player count
- 0-5 players: 16 chunks (large regions)
- 6-20 players: 8 chunks (medium regions)
- 21-50 players: 4 chunks (small regions)
- 50+ players: 2 chunks (very small regions)
- Hot Region Decay: Regions gradually cool down when players leave
- Heat decays at 5% per second when no players present
- Prevents regions from staying hot indefinitely
- Dynamic Region Sizing: Automatically adjusts region size based on player count
-
PredictiveScheduler Algorithms
- EWMA (Exponentially Weighted Moving Average): Better short-term TPS prediction
- Alpha smoothing factor of 0.3 for optimal responsiveness
- Linear Regression: Trend analysis for TPS decline detection
- Combines simple average, EWMA, and trend for robust prediction
- More accurate lag prevention than simple hourly averages
- EWMA (Exponentially Weighted Moving Average): Better short-term TPS prediction
🛠️ Configuration Management
-
Annotation-Based Validation
@ConfigValidationannotation for field-level validation rulesConfigValidatorclass with automatic validation on reload- Validates numeric ranges, required fields, and boundary warnings
- Provides clear error messages and validation reports
-
Config Migration System
- Automatic version checking and stepwise migrations
- Backup creation before migration with rollback capability
- Supports migration of config.yml, features.yml, monitors.yml, systems.yml
- Preserves user settings while updating structure
📚 Documentation
-
Comprehensive Config Guide
CONFIG-GUIDE.mdwith detailed explanations for all settings- Usage examples, recommended values, and troubleshooting tips
- Clear organization by functional areas
-
Enhanced Config Comments
- Added detailed explanations to all YAML configuration files
- Section headers and inline comments for better understanding
- Security notes and setup instructions where applicable
🔧 Code Quality Improvements
-
Single Responsibility Principle
- Each class has a single, well-defined responsibility
- Reduced coupling between components
- Improved testability and maintainability
-
Modern Java Practices
- Updated deprecated Bukkit method usage
- Proper exception handling and logging
- Thread-safe data structures where appropriate
🎯 Performance Optimizations
-
Intelligent Culling
- Prioritizes removing low-importance mobs first
- Preserves named, tamed, and special mobs
- Reduces impact on gameplay while maintaining server performance
-
Targeted Optimization
- Behavior-based optimization strategies
- Different approaches for different mob types
- More efficient than one-size-fits-all approach
🔄 Backward Compatibility
- Seamless Migration
- Automatic config updates preserve existing functionality
- Graceful handling of missing or corrupt configuration files
- No breaking changes to existing setups
🐛 Bug Fixes
-
Fixed Memory Leaks
- Proper cleanup of event listeners and cached data
- Thread-safe collections with proper synchronization
-
Improved Error Handling
- Better exception messages and logging
- Graceful degradation when components fail
- Validation prevents invalid configurations
NeuroLag 1.6.0
release29 апреля 2026 г.Нет описания изменений
NeuroLag 1.5.2
release23 апреля 2026 г.[1.5.2] — 2026-04-23 — Bug Fix & Safety Patch
Fixed — plugin.yml
- Critical: wrong
api-version—api-versionwas set to1.5.1(the plugin version) instead of the required Bukkit API version1.21. Paper rejects plugins with a non-standardapi-versionstring, causing the plugin to either fail to load or log a persistent warning on every server start. Changed toapi-version: 1.21.
Fixed — WebDashboard
- Token not generated when
monitors.ymlis deleted or web dashboard is disabled.ensureStrongToken()was only called after theif (!webDashboardEnabled) returnguard, meaning servers that had the dashboard disabled (or whosemonitors.ymlwas deleted and recreated bysaveResource) would still have the default placeholder token the first time the dashboard was enabled — a silent security hole.ensureStrongToken()now runs before the enabled check on everystart()call.- If
monitors.ymldoes not yet exist,saveResource()is called first to create the file structure before the generated token is written into it.
Fixed — LagEngine — Culling count wrong when protected zones are present
- Protected-zone mobs were counted toward
targetRemoveCountbut never actually removed, causing the cull pass to under-remove and leaving entity counts abovemaxEntitiesindefinitely on servers with active zone protection.cull()now pre-filters protected mobs from the candidate pool before computingtargetRemoveCount, so the removal math uses only the actually-cullable mob count.- The redundant zone check inside the removal loop is kept as a race-condition safety net.
Fixed — LagEngine — AI update scheduler saturation on very mob-dense worlds
- No upper bound on
runTaskLatercalls per tick — on worlds with thousands of entities,applyAiBatched()could schedule dozens of batch tasks in a single tick, queuing more work than the scheduler could drain, leading to compounding latency.- Added
AI_UPDATE_PER_TICK_CAP = 80: at most 80 mob AI updates are scheduled per engine tick. The next monitor tick processes the remaining mobs, spreading load evenly.
- Added
Fixed — StressTestManager — Server crash on large spawns at low-chunk-count locations
- No per-chunk mob density check — spawning 2 000+ mobs at or near the world spawn could
saturate loaded chunks and crash the server within seconds.
- Before spawning, the manager now scans a 7×7 chunk area around the target location and
compares the current entity count against
stress-test.max-mobs-per-chunk(default: 80). - If the limit would be exceeded, the spawn count is automatically reduced to the safe maximum and a warning is logged. If the area is already at capacity, the command is rejected with a descriptive error message.
- Before spawning, the manager now scans a 7×7 chunk area around the target location and
compares the current entity count against
- New config key in
systems.yml:stress-test.max-mobs-per-chunk: 80.
Fixed — MultiServerSync — MySQL reconnect attempt logged on every polling cycle
- When the MySQL database was down for an extended period,
ensureConnected()logged"MySQL connection lost — reconnecting in Xs…"on every poll interval (default every 10 s), flooding the console with hundreds of lines.- Reconnect log messages are now gated behind the same power-of-2 streak filter already used for SQL error warnings (logs on streak 1, 2, 4, 8, 16 …), reducing noise by up to 95% during prolonged outages while still keeping the first occurrence visible.
Config changes
# systems.yml — new in 1.5.2
stress-test:
max-mobs-per-chunk: 80 # NEW — per-chunk density safety cap for stress tests
NeuroLag 1.5.1
release20 апреля 2026 г.[1.5.1] — 2026-04-20 — Code Quality & Performance Patch
Fixed / Improved — ZoneManager
- WorldGuard region cache —
getApplicableRegions()was called for every mob on every monitor tick. Queries are now cached per chunk with a 100-tick TTL (ConcurrentHashMap). Cache is invalidated automatically when TTL expires, eliminating excessive WorldGuard API pressure on large servers. - CuboidZone coords changed from
doubletoint— block-level precision is sufficient; int arithmetic is faster and the record is more memory-efficient. - Zone
initialize()now clears the WG cache on reload.
Fixed / Improved — ProfileManager
- Profile validation before apply — switching to a profile where
critical-tps ≥ medium-tpsormax-entities < 1now returns a clear error instead of silently corrupting the engine state. - Active profile persisted across restarts — the selected profile name is written to
plugins/NeuroLag/active-profile.daton switch and reloaded automatically on startup/reload, so profiles survive server restarts without manual re-selection. switchProfile()return type changed frombooleantoString(null = success,"NOT_FOUND"or error message = failure) — NeuroLag main command updated accordingly.
Fixed / Improved — PredictiveScheduler
- Hand-rolled JSON parser replaced with Gson (bundled by Paper) — the previous
split/replaceAllparser was fragile and could silently produce wrong data on corrupt files. Gson provides safe serialisation and clean error handling; corrupt files now log a warning instead of producing garbage hourly averages. - Loaded samples are capped to the last 60 per hour on load, not only on record.
Fixed / Improved — CpuMonitor
- Graceful fallback for non-Sun JVMs — if
com.sun.management.OperatingSystemMXBeanis unavailable (GraalVM, some container JVMs), the monitor now falls back toOperatingSystemMXBean.getSystemLoadAverage()normalised by CPU count. If even that is unavailable, the feature disables itself gracefully instead of throwing at construction time. - EMA smoothing (α = 0.3) — single-tick CPU spikes no longer toggle the throttle on/off erratically. The exponential moving average keeps the reading stable under transient load.
- Strategy (SUN_PROCESS / SYSTEM_LOAD / DISABLED) is selected once at construction and
stored in an enum — no repeated
instanceofchecks every tick.
Fixed / Improved — RegionOptimizer
- Player chunk position cache —
refresh()now tracks each player's last known chunk. The HOT/COLD region map is only rebuilt when at least one player has moved to a different chunk since the previous call. On a stable server this eliminates the full-player-scan every monitor tick. isBeyondPathfindingDistance()uses the cached positions instead of callingworld.getPlayers()a second time per mob check.
Fixed / Improved — NeuroLagAPI
- Added
NeuroLagAPI.getInstance()for cleaner third-party plugin integration. - JSON payload sent via plugin message channel now uses Gson instead of manual StringBuilder, eliminating potential escape bugs.
Fixed / Improved — LagReporter (Discord)
- Retry with exponential back-off — Discord webhook requests are retried up to 3 times (delays: 1 s → 2 s → 4 s) before giving up. Transient network errors and Discord 429 rate-limit responses no longer silently drop notifications.
- Discord embed payload now built with Gson — no more manual string escaping.
Fixed / Improved — StressTestManager
- Confirmation prompt for spawns > 1 000 mobs — the sender must repeat the command within 30 seconds to confirm. Prevents accidental large spawns.
- Multiple entity types —
stress-test.entity-typesconfig list (default: ZOMBIE, SKELETON, CREEPER) is cycled round-robin across spawned mobs, producing a more realistic mixed load. Invalid or non-spawnable type names log a warning and are skipped.
Fixed / Improved — LagEngine
- Added internal processing metrics:
lastTickMobCountandlastTickProcessingMs. Visible in/nlag status("Last Tick: N mobs, X ms"). ZoneManager.tick()is now called once per engine tick to advance the WG cache TTL counter.
Fixed / Improved — WebDashboard
- Rate limiting now also covers
GET /(the HTML dashboard page), not only/api/*endpoints. - Token auto-generation log output upgraded to
SEVERElevel and formatted as a clearly visible bordered block so admins cannot miss the new token in the console.
Fixed / Improved — ConfigManager / ConfigValidator
- Added
stress-test.entity-typeslist field. ConfigValidatornow checksentity-typeslist is non-empty when stress test is enabled.
Config changes (systems.yml)
stress-test:
entity-types: # NEW — 1.5.1
- ZOMBIE
- SKELETON
- CREEPER
NeuroLag 1.5.0
release19 апреля 2026 г.[1.5.0] — 2026-04-19 — Security Hardening & Stability Release
Fixed — Security
- [Bug #1] Web dashboard weak default token / no rate limiting / no IP filtering
(
WebDashboard.java,ConfigManager.java,monitors.yml)- Auto-generates a cryptographically strong 24-byte random token on first startup
whenever the default placeholder
"change-this-token-now"is detected. The new token is immediately persisted tomonitors.ymland printed to the console. - Added per-IP rate limiting (sliding 60-second window, configurable via
web-dashboard.rate-limit.max-requests-per-minute, default 60). Returns HTTP 429 when the limit is exceeded. - Added optional IP allow-list (
web-dashboard.ip-whitelist, disabled by default). When enabled, only explicitly listed IPs can reach/api/statusand/api/cmd.
- Auto-generates a cryptographically strong 24-byte random token on first startup
whenever the default placeholder
Fixed — Stability
-
[Bug #2] Stress test could spawn unlimited mobs with no cooldown (
StressTestManager.java,ConfigManager.java,systems.yml)- Hard cap: mob count is clamped to
stress-test.max-mob-count(default 2 000) regardless of the value passed to/nlag stresstest. The sender is notified when the cap applies. - Cooldown: a configurable
stress-test.cooldown-seconds(default 300) must elapse between tests. Attempting to start a test during cooldown shows the remaining time. - Both limits are enforced by
ConfigValidator.
- Hard cap: mob count is clamped to
-
[Bug #3] Redis subscriber join(3000) always timed out on slow networks (
MultiServerSync.java)stop()now holds avolatilereference to the activeJedisPubSubinstance and callspubSub.unsubscribe()beforeinterrupt()+join(). This signals the blockingjedis.subscribe()call to return immediately, sojoin()completes in milliseconds rather than timing out. Prevents connection-pool leaks during rapid/nlag reloadcycles.
-
[Bug #4] Smart culling could remove hundreds of entities in one pass → lag spike (
LagEngine.java)- Added
CULL_PER_TICK_CAP = 50— at most 50 entities are removed per cull invocation. If the entity count remains abovemax-entities-per-worldafter one pass, the next monitor tick handles the remainder. Eliminates the single-frame mob-removal lag spike seen on servers with thousands of entities.
- Added
-
[Bug #5] Predictive scheduler lost all historical data on server restart (
PredictiveScheduler.java)- Hourly TPS samples are now saved to
plugins/NeuroLag/predictive-data.jsononstop()(server shutdown or/nlag reload) and reloaded onstart(). No external library required — uses a compact hand-rolled JSON serializer/parser. The predictor now accumulates knowledge across restarts and becomes effective much faster on busy servers.
- Hourly TPS samples are now saved to
-
[Bug #6] Full plugin reload caused noticeable server stutter (
NeuroLag.java)reloadPluginState()now takes config snapshots before reloading and selectively restarts only the services whose configuration sections actually changed (web dashboard, multi-server sync, predictive scheduler, CPU monitor, boss-bar dashboard). The main monitor task and engine throttle are always restarted cleanly. On a typical/nlag reloadthat only changes TPS thresholds, zero external services are bounced, eliminating the stutter caused by restarting Redis/MySQL connections unnecessarily.
Changed
ConfigValidatornow validates the new stress-test limits and rate-limit settings.systems.yml— addedstress-test.max-mob-countandstress-test.cooldown-seconds.monitors.yml— addedweb-dashboard.rate-limitandweb-dashboard.ip-whitelistsections.
