Optimizator
适用于 Minecraft 1.16.5 至 1.21.11 的 Paper / Folia 服务器的轻量级优化插件。
单个 .jar 文件即可覆盖整个版本范围:该插件基于最旧的 API(1.16.5)编译,因此得益于 Bukkit API 向后兼容性,它也能在更高版本中加载。无需外部库依赖。
功能特性
- 实体 (Entities) — 当设定半径内没有玩家时取消生物生成;移除区块溢出;每个被移除实体的区块限制;可选移除远处生物;受保护的类型列表。
- 物品 (Items) — 移除陈旧掉落的物品(伴有玩家警告)并合并附近相同的物品堆叠。
- 爆炸 (Explosions) — 可配置是否取消苦力怕、TNT 和凋灵的爆炸;设置允许爆炸的世界白名单。
- 区块 (Chunks) — 定期追踪已加载的区块。
- TPS 监控 — 监控 TPS 和内存,并在性能下降时发出警告。
- 世界黑名单 — 完全禁用选定世界中的优化功能。
- Folia — 安全的调度器:通过
GlobalRegionScheduler 执行全局任务,在玩家所在区域 (RegionScheduler) 处理区块工作,绝不触碰其他区域。
- 全版本通用 JAR — 从 1.16.5 到 1.21.11 无需重新构建。
- 统计与命令 — 提供计数器及支持 Tab 补全的
/optimizator 命令。
- 热重载 — 使用
/optimizator reload 无需重启服务器即可应用更改。
游戏安全性
该插件设计为对玩家不可见:
- 仅移除废弃的敌对生物。 移除操作仅应用于会自动消失的生物实体 (
getRemoveWhenFarAway() == true)。动物、刷怪笼生成的生物以及持久性生物绝不会受到干扰。
- 重要实体受保护。 以下实体永远不会被移除:玩家、驯服的宠物、命名过的生物、Boss(末影龙、凋灵)、列入
protected-types 的生物,以及正在承载他人或被骑乘的实体(包括由玩家骑乘)。
- 安全半径。 在玩家周围
entity.safety-radius(默认 32 格)范围内,不会移除任何内容 — 战斗、农场和宠物均不受影响。
- 生成取消不可察觉。 仅切断自然 (
NATURAL) 生成,且仅在远离所有玩家的地方 — 即无人目睹的区域。
- 物品不会丢失。 仅移除超过
item-lifetime 时长的物品(默认 600 秒;原版在 300 秒后移除)。拥有名称、描述或附魔的物品受保护 (protect-valuable)。物品合并不会删除任何东西 — 它仅合并相同的物品堆叠。
- 爆炸默认不被取消 — 每个
cancel-* 选项均为 false。
- 所有功能均可单独关闭。 任何部分都可以禁用,并且可以将世界添加到
disabled-worlds 中。
兼容性
| 服务器 |
版本 |
任务调度器 |
| Paper / Spigot |
1.16.5 – 1.21.11 |
BukkitScheduler |
| Folia |
1.19.4 – 1.21.11 |
GlobalRegionScheduler / RegionScheduler |
Folia 在 1.19.4 版本之前不存在,因此在 1.16.5 上插件以正常的 Paper/Spigot 模式运行,而在 Folia 上运行时区域模式会自动启用。
要求
- 服务器: 支持版本的 Paper、Folia 或 Spigot。
- Java: 构建需要 JDK 16+;运行时需要与您服务器匹配的 Java 版本(1.16.5 对应 Java 16,1.21+ 对应 Java 21)。
安装
- 构建插件(参见 构建)或直接获取现成的
Optimizator-1.0.0.jar。
- 将
Optimizator-1.0.0.jar 放入服务器的 plugins/ 文件夹。
- 启动服务器 — 将会创建
plugins/Optimizator/config.yml 文件。
- 根据您的需要编辑
config.yml。
- 使用
/optimizator reload 应用更改。
命令与权限
| 命令 |
描述 |
/optimizator reload |
重新加载 config.yml 并重启任务 |
/optimizator stats |
总体统计信息(MC 版本、TPS、内存、计数器) |
/optimizator entity |
实体统计信息 |
/optimizator items |
物品统计信息 |
/optimizator chunk |
区块统计信息 |
/optimizator explosion |
爆炸统计信息 |
/optimizator tps |
当前 TPS 和内存使用情况 |
/optimizator folia |
检查服务器是否运行在 Folia 上 |
/optimizator reset |
重置所有统计信息 |
该命令支持子命令的 Tab 补全(Tab)。
| 权限 |
描述 |
默认值 |
optimizator.admin |
访问所有插件命令 |
op |
配置
plugins/Optimizator/config.yml 文件:
# 控制台调试消息。
debug: false
# 完全禁用优化的世界(按世界名称)。
disabled-worlds: []
entity:
optimization-enabled: true
cancel-spawns: true # 在远离玩家的地方取消自然生成
mob-spawn-range: 48 # 玩家周围的生物生成半径(格)
max-entities-per-chunk: 50 # 每个区块最多移除的生物数量
max-living-per-chunk: 30 # 每个区块最多移除的生命体数量(0 = 关闭)
remove-far-mobs: false # 移除远离玩家的生物
safety-radius: 32 # 距离玩家更近的任何东西都不会被移除
protected-types: # 永远不会被移除的类型
- PLAYER
- VILLAGER
- WANDERING_TRADER
- IRON_GOLEM
- SNOWMAN
- WOLF
- CAT
- PARROT
- HORSE
- DONKEY
- MULE
- LLAMA
- TRADER_LLAMA
- AXOLOTL
- ALLAY
爆炸优化:
启用优化: true
取消苦力怕爆炸: false # 取消苦力怕爆炸
取消TNT爆炸: false # 取消TNT爆炸
取消凋灵爆炸: false # 取消凋灵爆炸
允许的世界: [] # 始终允许发生爆炸的世界
物品:
清理已启用: true # 移除旧的掉落物
物品生命周期: 600 # 物品保留时间(秒)
清理间隔: 60 # 检查间隔(秒)
清理前警告: true # 移除前向玩家发出警告
警告延迟: 5 # 警告与移除之间的延迟(秒)
保护贵重物品: true # 不移除拥有名称/描述/附魔的物品
合并物品: true # 合并附近相同的物品
合并半径: 1.5 # 合并半径(方块)
区块:
启用优化: true
自动保存间隔: 1200 # 区块追踪间隔(刻,1200 = 60 秒)
保存非活跃区块: true
每秒刻数(TPS):
监控已启用: true # 追踪 TPS
警告阈值: 15.0 # TPS 警告阈值
检查间隔: 60 # 检查间隔(秒)
设置参考
| 设置项 |
类型 |
默认值 |
描述 |
debug |
布尔 |
false |
打印调试信息 |
disabled-worlds |
列表 |
[] |
完全禁用优化的世界 |
entity.optimization-enabled |
布尔 |
true |
实体优化 |
entity.cancel-spawns |
布尔 |
true |
在远离玩家的地方取消自然生成 |
entity.mob-spawn-range |
整数 |
48 |
玩家周围的生物生成半径(方块) |
entity.max-entities-per-chunk |
整数 |
50 |
每个区块移除的生物上限 |
entity.max-living-per-chunk |
整数 |
30 |
可移除的活体实体上限(0 = 关闭) |
entity.remove-far-mobs |
布尔 |
false |
移除远离玩家的生物 |
entity.safety-radius |
整数 |
32 |
永远不会移除距离玩家过近的实体(方块) |
entity.protected-types |
列表 |
见上文 |
永远不会被移除的类型 |
explosion.optimization-enabled |
布尔 |
true |
爆炸优化 |
explosion.cancel-creeper |
布尔 |
false |
取消苦力怕爆炸 |
explosion.cancel-tnt |
布尔 |
false |
取消 TNT 爆炸 |
explosion.cancel-wither |
布尔 |
false |
取消凋灵爆炸 |
explosion.allowed-worlds |
列表 |
[] |
始终允许发生爆炸的世界 |
items.cleanup-enabled |
布尔 |
true |
移除旧物品 |
items.item-lifetime |
整数 |
600 |
物品保留时间(秒) |
items.cleanup-interval |
整数 |
60 |
检查间隔(秒) |
items.warn-before-cleanup |
布尔 |
true |
移除前发出警告 |
items.warn-delay |
整数 |
5 |
移除前的延迟(秒) |
items.protect-valuable |
布尔 |
true |
不移除拥有名称/描述/附魔的物品 |
items.merge-items |
布尔 |
true |
合并附近物品 |
items.merge-radius |
双精度浮点数 |
1.5 |
合并半径(方块) |
chunk.optimization-enabled |
布尔 |
true |
区块追踪 |
chunk.auto-save-interval |
整数 |
1200 |
区块追踪间隔(刻) |
chunk.save-inactive-chunks |
布尔 |
true |
追踪非活跃区块 |
tps.monitor-enabled |
布尔 |
true |
TPS 和内存监控 |
tps.warn-threshold |
双精度浮点数 |
15.0 |
TPS 警告阈值 |
tps.check-interval |
整数 |
60 |
TPS 检查间隔(秒) |
工作原理
OptimizatorPlugin — 入口点:读取配置文件,连接管理器、命令,启动任务,并支持完整重载。
FoliaOptimizer — 中央调度器。检测 Folia 并通过 Folia 调度器或 BukkitScheduler 分发任务。返回 TaskHandle 以便在重载时干净地取消任务。
EntityOptimizer — 每 10 秒遍历区块,仅移除超出限制的“无人看管”敌对生物:它绝不会触碰宠物、命名生物、Boss、持久化生物或处于玩家 safety-radius 范围内的任何实体。在 Folia 上,它仅遍历玩家区域。
OptimizatorListener — 监听 CreatureSpawnEvent 并取消在远离玩家处的自然生物生成。
ExplosionOptimizer — 监听 ExplosionPrimeEvent 并取消选定的爆炸,尊重世界白名单。
ItemOptimizer — 清理旧物品(带有警告)并合并附近相同的物品堆。
ChunkOptimizer — 定期追踪加载的区块。
TPSMonitor — 测量 TPS(通过 Paper 的 getTPS() 或其自身的采样)和内存,当性能下降时记录警告。
ConfigManager — 加载、保存和重载设置。
ServerVersion — 检测和比较 Minecraft 版本。
所有重型处理均按计时器运行,且从不阻塞主线程刻。
Folia 支持
Folia 是一个独立的构建(Paper 的一个分支),具有区域多线程功能,自 1.19.4 起可用。
插件通过 io.papermc.paper.threadedregions.RegionizedServer 类来检测 Folia —— 该类仅存在于 Folia 中。通过 RegionScheduler 进行检测并不可靠:自 Paper 1.20 以来,该类也作为主线程包装器存在于常规 Paper 中,这将导致误判。
- 全局任务(计时器)—— 通过
GlobalRegionScheduler。
- 区块和实体工作 —— 在玩家所在区域通过
RegionScheduler 执行。
- 跳过外部区域(
Bukkit.isOwnedByCurrentRegion),因此实体访问始终是线程安全的。
- 在常规 Paper/Spigot 上,所有内容均通过
BukkitScheduler 运行。
故障排除
插件未加载;日志显示 Unsupported class file major version。
服务器运行在较旧的 Java 版本上。对于 1.20.5+ 请使用 Java 21,对于 1.16.5–1.17 请使用 Java 16/17。插件兼容所有这些版本;关键在于服务器自身的 Java 版本。
任务未运行。
启用 debug: true,检查控制台,并确保相关部分(entity / items / chunk / tps)已启用,且该世界未列在 disabled-worlds 中。
附近持续生成生物。
仅当最近玩家距离超过 mob-spawn-range 时,才会取消 NATURAL(自然)原因的生成。降低该值可增强效果。
必要的物品/实体正在被移除。
增加 item-lifetime 的值,或从 entity.protected-types 中移除相应类型。对于物品,请禁用 items.cleanup-enabled。
物品移除消息刷屏。
禁用 items.warn-before-cleanup 或增加 items.cleanup-interval。
我想应用更改。
编辑 config.yml 后,运行 /optimizator reload —— 任务将重新启动。
更新日志
1.0.0
- 适用于 Minecraft 1.16.5 – 1.21.11 的单个 JAR 文件。
- 兼容 Folia 的计划任务系统:支持全局任务、区域任务以及无需重启服务器即可取消任务。
- 玩法安全:仅移除废弃的敌对生物;保护宠物、命名生物、Boss 和持久化生物;围绕玩家设置安全半径 (
entity.safety-radius)。
- 物品优化:清理旧物品并合并邻近堆叠;保护贵重物品 (
items.protect-valuable)。
- TPS 与内存监控及警告功能。
- 世界黑名单及用于爆炸的世界白名单。
- 受保护的实体类型列表。
- 每个区块被移除实体的数量限制。
- 命令补全功能,包含
items、tps、reset 子命令。
- 通过
/optimizator reload 完全重载配置。
许可证
本项目根据 MIT 许可证分发。
Optimizator
A lightweight optimization plugin for Paper / Folia servers from Minecraft 1.16.5 to 1.21.11.
A single .jar works across the whole version range: the plugin is compiled against the
oldest API (1.16.5), so it also loads on newer versions thanks to Bukkit API backward
compatibility. No external libraries are required.
Features
- Entities — cancels mob spawning when there are no players within a set radius;
removes chunk overflow; per-chunk limit for removed entities; optional removal of
distant mobs; protected type list.
- Items — removes old dropped items (with a player warning) and merges nearby
identical stacks.
- Explosions — configurable cancellation of creeper, TNT and Wither explosions;
world whitelist where explosions are always allowed.
- Chunks — periodic tracking of loaded chunks.
- TPS monitor — tracks TPS and memory with warnings when performance drops.
- World blacklist — fully disables optimization in selected worlds.
- Folia — safe scheduler: global tasks via
GlobalRegionScheduler, chunk work in
the player's region (RegionScheduler), foreign regions are never touched.
- One JAR for all versions — from 1.16.5 to 1.21.11 without rebuilding.
- Statistics and commands — counters,
/optimizator with tab completion.
- Hot reload —
/optimizator reload without restarting the server.
Gameplay-Safe
The plugin is designed to be invisible to players:
- Only abandoned hostile mobs are removed. Removal applies exclusively to
Mob
entities that despawn on their own (getRemoveWhenFarAway() == true). Animals,
spawner mobs and persistent mobs are never touched.
- Important entities are protected. The following are never removed: players,
tamed pets, named mobs, bosses (Ender Dragon, Wither), mobs listed in
protected-types, and any entity that is carrying someone or being ridden
(including by players).
- Safety radius. Within
entity.safety-radius (32 blocks by default) around a
player, nothing is removed — fights, farms and pets are unaffected.
- Spawn cancellation is unnoticeable. Only natural
NATURAL spawning is cut off,
and only far from all players — in places nobody sees.
- Items are not lost. Only items older than
item-lifetime are removed (600 sec
by default; vanilla removes them after 300 sec). Items with a name, lore or
enchantments are protected (protect-valuable). Item merging removes nothing — it
only combines identical stacks.
- Explosions are not cancelled by default — every
cancel-* option is false.
- Everything can be turned off individually. Any part can be disabled, and worlds
can be added to
disabled-worlds.
Compatibility
| Server |
Versions |
Task scheduler |
| Paper / Spigot |
1.16.5 – 1.21.11 |
BukkitScheduler |
| Folia |
1.19.4 – 1.21.11 |
GlobalRegionScheduler / RegionScheduler |
Folia does not exist below version 1.19.4, so on 1.16.5 the plugin runs in normal
Paper/Spigot mode and the regional mode is enabled automatically when running on
Folia.
Requirements
- Server: Paper, Folia or Spigot of a supported version.
- Java: for building — JDK 16+; for running — the Java version matching your
server (Java 16 for 1.16.5, Java 21 for 1.21+).
Installation
- Build the plugin (see Building) or grab the ready-made
Optimizator-1.0.0.jar.
- Place
Optimizator-1.0.0.jar into your server's plugins/ folder.
- Start the server — a
plugins/Optimizator/config.yml file will be created.
- Edit
config.yml to your needs.
- Apply the changes with
/optimizator reload.
Commands and Permissions
| Command |
Description |
/optimizator reload |
Reload config.yml and restart tasks |
/optimizator stats |
General statistics (MC version, TPS, memory, counters) |
/optimizator entity |
Entity statistics |
/optimizator items |
Item statistics |
/optimizator chunk |
Chunk statistics |
/optimizator explosion |
Explosion statistics |
/optimizator tps |
Current TPS and memory usage |
/optimizator folia |
Check whether the server is running on Folia |
/optimizator reset |
Reset all statistics |
The command supports subcommand tab completion (Tab).
| Permission |
Description |
Default |
optimizator.admin |
Access to all plugin commands |
op |
Configuration
The plugins/Optimizator/config.yml file:
# Debug messages to the console.
debug: false
# Worlds where optimization is fully disabled (by world name).
disabled-worlds: []
entity:
optimization-enabled: true
cancel-spawns: true # Cancel natural spawning away from players
mob-spawn-range: 48 # Mob spawn radius around players (blocks)
max-entities-per-chunk: 50 # Limit of mobs removed per chunk
max-living-per-chunk: 30 # Limit of living entities removed per chunk (0 = off)
remove-far-mobs: false # Remove mobs far away from players
safety-radius: 32 # Never remove anything closer than this to a player
protected-types: # Types that are never removed
- PLAYER
- VILLAGER
- WANDERING_TRADER
- IRON_GOLEM
- SNOWMAN
- WOLF
- CAT
- PARROT
- HORSE
- DONKEY
- MULE
- LLAMA
- TRADER_LLAMA
- AXOLOTL
- ALLAY
explosion:
optimization-enabled: true
cancel-creeper: false # Cancel creeper explosions
cancel-tnt: false # Cancel TNT explosions
cancel-wither: false # Cancel Wither explosions
allowed-worlds: [] # Worlds where explosions are always allowed
items:
cleanup-enabled: true # Remove old dropped items
item-lifetime: 600 # Item lifetime (seconds)
cleanup-interval: 60 # Check interval (seconds)
warn-before-cleanup: true # Warn players before removal
warn-delay: 5 # Delay between warning and removal (seconds)
protect-valuable: true # Do not remove items with name/lore/enchantments
merge-items: true # Merge nearby identical items
merge-radius: 1.5 # Merge radius (blocks)
chunk:
optimization-enabled: true
auto-save-interval: 1200 # Chunk tracking interval (ticks, 1200 = 60 sec)
save-inactive-chunks: true
tps:
monitor-enabled: true # Track TPS
warn-threshold: 15.0 # TPS warning threshold
check-interval: 60 # Check interval (seconds)
Settings Reference
| Setting |
Type |
Default |
Description |
debug |
bool |
false |
Print debug messages |
disabled-worlds |
list |
[] |
Worlds where optimization is fully disabled |
entity.optimization-enabled |
bool |
true |
Entity optimization |
entity.cancel-spawns |
bool |
true |
Cancel natural spawning away from players |
entity.mob-spawn-range |
int |
48 |
Mob spawn radius around players (blocks) |
entity.max-entities-per-chunk |
int |
50 |
Limit of mobs removed per chunk |
entity.max-living-per-chunk |
int |
30 |
Limit of living entities removed (0 = off) |
entity.remove-far-mobs |
bool |
false |
Remove mobs far from players |
entity.safety-radius |
int |
32 |
Never remove entities closer to a player (blocks) |
entity.protected-types |
list |
see above |
Types that are never removed |
explosion.optimization-enabled |
bool |
true |
Explosion optimization |
explosion.cancel-creeper |
bool |
false |
Cancel creeper explosions |
explosion.cancel-tnt |
bool |
false |
Cancel TNT explosions |
explosion.cancel-wither |
bool |
false |
Cancel Wither explosions |
explosion.allowed-worlds |
list |
[] |
Worlds where explosions are always allowed |
items.cleanup-enabled |
bool |
true |
Remove old items |
items.item-lifetime |
int |
600 |
Item lifetime (seconds) |
items.cleanup-interval |
int |
60 |
Check interval (seconds) |
items.warn-before-cleanup |
bool |
true |
Warn before removal |
items.warn-delay |
int |
5 |
Delay before removal (seconds) |
items.protect-valuable |
bool |
true |
Do not remove items with name/lore/enchantments |
items.merge-items |
bool |
true |
Merge nearby items |
items.merge-radius |
double |
1.5 |
Merge radius (blocks) |
chunk.optimization-enabled |
bool |
true |
Chunk tracking |
chunk.auto-save-interval |
int |
1200 |
Chunk tracking interval (ticks) |
chunk.save-inactive-chunks |
bool |
true |
Track inactive chunks |
tps.monitor-enabled |
bool |
true |
TPS and memory monitor |
tps.warn-threshold |
double |
15.0 |
TPS warning threshold |
tps.check-interval |
int |
60 |
TPS check interval (seconds) |
How It Works
OptimizatorPlugin — entry point: reads the config, wires up the managers and
the command, starts the tasks, and supports a full reload.
FoliaOptimizer — the central scheduler. Detects Folia and dispatches tasks
through the Folia schedulers or BukkitScheduler. Returns a TaskHandle for clean
task cancellation on reload.
EntityOptimizer — every 10 seconds walks chunks and removes only "abandoned"
hostile mobs above the limit: it never touches pets, named mobs, bosses, persistent
mobs, or anything within safety-radius of players. On Folia it only walks player
regions.
OptimizatorListener — listens to CreatureSpawnEvent and cancels natural mob
spawning far from players.
ExplosionOptimizer — listens to ExplosionPrimeEvent and cancels the chosen
explosions, honoring the world whitelist.
ItemOptimizer — cleans up old items (with a warning) and merges nearby
identical stacks.
ChunkOptimizer — periodically tracks loaded chunks.
TPSMonitor — measures TPS (via Paper getTPS() or its own sampling) and
memory, logging a warning when performance drops.
ConfigManager — loads, saves and reloads the settings.
ServerVersion — detects and compares the Minecraft version.
All heavy passes run on a timer and never block the main tick.
Folia Support
Folia is a separate build (a Paper fork) with regional multithreading, available
since 1.19.4.
The plugin detects Folia by the io.papermc.paper.threadedregions.RegionizedServer
class — it exists only in Folia. Detecting by RegionScheduler is not reliable:
since Paper 1.20 that class is also present in regular Paper as a main-thread wrapper,
which would give a false result.
- Global tasks (timers) — via
GlobalRegionScheduler.
- Chunk and entity work — in the player's region via
RegionScheduler.
- Foreign regions are skipped (
Bukkit.isOwnedByCurrentRegion), so entity access is
always thread-safe.
- On regular Paper/Spigot everything runs via
BukkitScheduler.
Troubleshooting
The plugin does not load; the log shows Unsupported class file major version.
The server is running on an older Java. Use Java 21 for 1.20.5+, Java 16/17 for
1.16.5–1.17. The plugin works with all of them; the server's own Java version is what
matters.
Tasks are not running.
Enable debug: true, check the console and make sure the relevant section
(entity / items / chunk / tps) is enabled and the world is not listed in
disabled-worlds.
Mobs keep spawning nearby.
Natural spawning is only cancelled for the NATURAL reason and only when the nearest
player is farther than mob-spawn-range. Lower the value to strengthen the effect.
Necessary items/entities are being removed.
Increase item-lifetime or remove the type from entity.protected-types. For items,
disable items.cleanup-enabled.
Item removal messages are spamming.
Disable items.warn-before-cleanup or increase items.cleanup-interval.
I want to apply changes.
After editing config.yml, run /optimizator reload — the tasks will restart.
Changelog
1.0.0
- A single JAR for Minecraft 1.16.5 – 1.21.11.
- Folia-safe scheduler: global tasks, regional tasks and task cancellation without a
server restart.
- Gameplay safety: only abandoned hostile mobs are removed; protection for pets,
named mobs, bosses and persistent mobs; a safety radius around players
(
entity.safety-radius).
- Item optimization: cleanup of old items and merging of nearby stacks; protection for
valuable items (
items.protect-valuable).
- TPS and memory monitor with warnings.
- World blacklist and a world whitelist for explosions.
- Protected entity type list.
- Per-chunk limit of removed entities.
- Command tab completion,
items, tps, reset subcommands.
- Full config reload via
/optimizator reload.
License
This project is distributed under the MIT license.
评论 0
登录后参与评分
还没有评论,来抢沙发吧