Chunk Cleaners

插件

· 作者 d15c07d

一款面向性能、高度优化的 Paper 1.21+ 插件,允许玩家移除区块内的所有方块和实体。这是 Factions 和生存服务器中备受期待的功能。

0 本站下载 0 关注 更新于 1 年前

最新 1.0.0 · 1.21.10 · Paper / Purpur

一键开服(送7天)

ChunkCleaners

一款专注于性能、高度优化的区块清理插件,适用于 Paper 1.21+。它允许玩家清除指定区块内的所有方块和实体。这是 Factions(阵营)和 Survival(生存)服务器中备受青睐的功能。

支持 FactionsUUID、MassiveCore Factions、WorldGuard、GriefPrevention 和 CoreProtect! 主要功能

可放置的区块清理道具(可配置类型:小型、中型、大型)。
自上而下的清理方式(先处理地表),以避免在作业过程中形成地下空洞。
支持多区块清理(1x1、2x2、4x4 等),并根据大小自动调整吞吐量。
TPS 自适应限流——当服务器 TPS 下降时自动减少工作量。
全息图与动作栏(ActionBars)!
集成支持:
    WorldGuard(检查区域建造标志)
    GriefPrevention(检查领地主张)
    Factions
    CoreProtect(按区块汇总记录、限制入队频率 + 定期刷新)
持久化存储,支持自动保存及每个任务的进度保存(减少重启后的进度丢失)。

命令

主命令:/chunkcleaners(别名 /cc)

玩家命令

/chunkcleaners give <player> <type> [amount] — 向玩家发放清理道具(权限:chunkcleaners.give)。
/chunkcleaners list — 显示当前活跃的清理道具数量或简要列表。
/chunkcleaners reload — 重新加载插件配置(需要管理员权限)。

管理员子命令(权限:chunkcleaners.admin)

/chunkcleaners admin save — 强制将所有活跃任务保存到磁盘。
/chunkcleaners admin savetask <uuid> — 立即保存单个任务的进度。
/chunkcleaners admin list — 列出所有活跃任务及其百分比进度。
/chunkcleaners admin status <uuid> — 显示详细状态(预计剩余时间、区块指针、进度)。

全息图与视觉效果

可在 hologram.* 下进行配置:

hologram.lines — 多行全息图的行列表(推荐,支持占位符)。
hologram.text — 单行文本回退方案,支持 \n 换行。
hologram.offset — 放置在方块上方的垂直偏移量。可用占位符:{remaining}、{progress}、{coords}、{type}、{amount}、{player}。

性能调优与选项

所有调优选项均位于 config.yml 的 performance.* 下。

重要参数

performance.max_chunks_per_interval — 每次调度运行准备的基准区块数量。
performance.y_batch_size — 每个区块任务处理的基准垂直层数。
performance.ticks_per_chunk_interval — 调度间隔(刻/ticks)。
performance.size_scale_enabled — 是否让较大的清理道具自动执行更多工作。
performance.size_scale_multiplier — 用于结合清理道具大小计算缩放因子的乘数。
performance.size_scale_cap — 缩放因子的上限(安全默认值为 8)。
performance.aggressive_interval_divisor — (高级)允许为大型清理道具使用更小的调度间隔。
performance.tps_threshold & performance.tps_smoothing — 用于检测低 TPS 并平滑地减少工作量。
performance.eta_window_seconds — 移动平均 ETA 估计器的窗口大小(秒)。

CoreProtect 安全性

coreprotect.log_chunk_summary(推荐)— 每个完成的区块仅记录一条汇总条目,而非每个方块。
coreprotect.flush_interval_ticks & coreprotect.max_entries_per_flush — 控制 CoreProtect 的日志写入吞吐量。
coreprotect.queue_max_size — 通过限制队列条目数量防止内存溢出。

持久化

persistence-file — 保存活跃任务的文件路径(默认 data/active-cleaners.yml)。
persistence.autosave_enabled & persistence.autosave_interval_seconds — 定期自动保存设置。
插件还会在每个区块清理完成时保存单个任务的进度。

推荐的生成环境调优

从 config.yml 中的默认值开始。
在新世界中测试多种类型的清理道具。
监控服务器 TPS 和 tick 时间。如果 TPS 保持稳定(≥ ~19),则逐步:
    增加 size_scale_multiplier 或 size_scale_cap,或者
    增加 max_chunks_per_interval 和 y_batch_size。
保持 CoreProtect 批量日志记录启用,并监控 CoreProtect 的性能/IO。
使用 persistence.autosave_interval_seconds(默认 60s)来平衡韧性与磁盘写入次数。

安全与集成行为

如果启用了保护集成,插件将拒绝代表离线玩家编辑区块(保守的默认设置)。
WorldGuard/GriefPrevention/Factions 的检查通过反射实现,因为最新版本中缺少相关 API。

开发与测试

试用该插件!
    /chunkcleaners give <player> small 1
    玩家放置道具后——应出现全息图和动作栏。
    使用 /chunkcleaners admin list 和 /chunkcleaners admin status <uuid> 进行调试。

配置

# ChunkCleaners
# Version 1.0.0 by d15c07d
#
# Supported placeholders (used in messages/holograms/actionbar):
#   {remaining}  - seconds remaining (ETA)
#   {progress}   - percent complete 0-100
#   {coords}     - world:chunkX,chunkZ (or world:x,z)
#   {type}       - cleaner type key
#   {amount}     - numeric amount
#   {player}     - player name
#   {id}         - task UUID
#   {count}      - number of active cleaners
# ----------------------------------------------------------------
types:
  small:
    display-name: "<green>Small Cleaner</green>"
    description: "Clears a 1x1 chunk area quickly.\nTip: place on flat ground."
    size: 1
    block: END_PORTAL_FRAME
    duration: 10

  medium:
    display-name: "<yellow>Medium Cleaner</yellow>"
    description: "Clears a 2x2 chunk area over time."
    size: 2
    block: END_PORTAL_FRAME
    duration: 30

  large:
    display-name: "<red>Large Cleaner</red>"
    description: "Clears a 4x4 chunk area. Use with caution."
    size: 4
    block: END_PORTAL_FRAME
    duration: 90

# ----------------------------------------------------------------
# 全息显示与视觉效果
# - 你可以配置单个字符串(hologram.text)或多行文本(hologram.lines)——对于多行全息图,推荐使用 lines。
# - hologram.offset 用于将全息图在已放置方块上方垂直移动。
# - 行间距和其他高级行为可以稍后添加。
# ----------------------------------------------------------------
hologram:
  enabled: true
  # 在已放置方块上方的垂直偏移量(以方块为单位)
  offset: 0.6
  lines:
    - "<gold>Cleaning: <yellow>{remaining}s</yellow>"
    - "<gray>{progress}% complete</gray>"
  # 如果未定义或 'lines' 为空时的单行文本备用方案。
  text: "<gold>Cleaning: <yellow>{remaining}s</yellow>"

# ----------------------------------------------------------------
# 在 Cleaner 运行时定期向玩家显示的 Actionbar 内容。
# 使用 {remaining} 和 {progress} 占位符。
# ----------------------------------------------------------------
actionbar:
  enabled: true
  message: "&aChunk Cleaner &7- &e{remaining}s &8[&e{progress}%&8]"

# ----------------------------------------------------------------
# 消息(通用、管理员和普通消息)。所有消息均可编辑以进行本地化。
# 支持 MiniMessage 或传统的 '&' 代码。支持多个占位符。
# ----------------------------------------------------------------
messages:
  # 通用(非管理员)消息
  no_permission: "<red>You don't have permission to do that."
  invalid_type: "<red>That chunk cleaner type doesn't exist."
  gave_cleaner: "<green>Gave {amount}x {type} to {player}."
  placed_denied_same_chunk: "<red>There is already an active chunk cleaner in this chunk."
  placed_denied_protected: "<red>You cannot place a chunk cleaner in a protected region."
  start_cleaning: "<green>Started cleaning chunk area {coords} (type {type})."
  cancel_no_nearby: "<red>You are not near an active chunk cleaner you own."
  cancel_success: "<green>Cancelled the chunk cleaner at {coords}."
  reload_success: "<green>Reloaded config and plugin data."
  list_header: "<gold>Active Chunk Cleaners (page {page}/{max})"
  list_entry: "<yellow>{index}. <white>{owner} <gray>({coords}) <gold>{type} <gray>age={age}s"
  cannot_place_in_same_chunk: "<red>A chunk cleaner is already active in this chunk."
  cannot_place_in_protected: "<red>Cannot place chunk cleaners in protected regions."

# 管理员命令消息(由 /chunkcleaners admin ... 使用)
  admin:
    help_header: "<gold>ChunkCleaners 管理员命令"
    help_lines:
      - "<yellow>/chunkcleaners admin save <white>- 将所有活跃清理器保存到磁盘"
      - "<yellow>/chunkcleaners admin savetask <uuid> <white>- 保存特定任务的进度"
      - "<yellow>/chunkcleaners admin list <white>- 列出活跃任务"
      - "<yellow>/chunkcleaners admin status <uuid> <white>- 显示任务的详细状态"
    save_success: "<green>已将所有活跃清理器保存到磁盘。"
    save_fail: "<red>保存失败:{error}"
    savetask_success: "<green>已保存任务 {id} 的进度"
    savetask_no_task: "<red>没有该 UUID 的活跃任务。"
    savetask_invalid_uuid: "<red>无效的 UUID:{id}"
    help_no_permission: "<red>您没有权限使用管理员命令。"
    list_header: "<gold>活跃的区块清理器:<gray>({count})"
    list_empty: "<yellow>没有活跃的区块清理器。"
    status_not_found: "<red>没有该 UUID 的活跃任务。"
    status_world_unloaded: "<red>世界未加载:{world}"
    status_progress_line: "<gold>进度:<white>{percent}% ({processed}/{total} 层级)"
    status_eta_line: "<gold>预计剩余时间:<white>{seconds}s"
    status_pointers: "<gold>区块索引:<white>{idx} <gold>Y 轴指针:<white>{y}"

# 主命令消息与用法(适用于 /chunkcleaners 及其别名 /cc)
  main:
    usage_header: "<yellow>ChunkCleaners 命令:"
    usage_lines:
      - "<yellow>/chunkcleaners give <玩家> <类型> [数量] <white>- 向玩家发放一个清理器"
      - "<yellow>/chunkcleaners list <white>- 列出当前活跃的清理器"
      - "<yellow>/chunkcleaners reload <white>- 重新加载插件配置"

- "<yellow>/chunkcleaners admin <sub> <white>- 管理员工具(需要权限)"
    reload_success: "<green>配置已重新加载。"
    reload_fail: "<red>重新加载失败:{error}"

give_no_permission: "<red>你没有权限给予清洁工。"
    give_success: "<green>已向 {player} 发放了 {amount}x {type}。"

# ----------------------------------------------------------------
# 行为开关与持久化
# ----------------------------------------------------------------
prevent_same_chunk: true          # 如果为 true,插件将阻止在同一区块中运行两个清理器
save_on_shutdown: true            # 在关闭时将活动的清理器保存到持久化文件
persistence-file: data/active-cleaners.yml

persistence:
  autosave_enabled: true
  autosave_interval_seconds: 60   # 每 N 秒保存一次,以减少进度丢失

# 热重载(监听 config.yml 并自动重新加载)
hot_reload:
  enabled: true
  file: config.yml
  poll_interval_ms: 1000

# ----------------------------------------------------------------
# 集成:仅启用你在服务器上运行的插件
# - WorldGuard:区域/建造标志检查
# - GriefPrevention:领地检查
# - Factions:FactionsUUID 或 MassiveCore Factions 检测
# - CoreProtect:按区块批量日志记录
# ----------------------------------------------------------------
integrations:
  worldguard: true
  griefprevention: true
  factions: true
  coreprotect: true

# ----------------------------------------------------------------
# 性能调优与自适应限流
#
# 注意事项:
# - 从保守设置开始。在监控 TPS(每秒刻数)的同时缓慢增加数值。
# - 基于大小的缩放机制会让更大的清理器在每个刻中执行更多工作。
# ----------------------------------------------------------------
performance:
  # 基础参数
  max_chunks_per_interval: 1     # 每个调度器间隔内尝试处理的区块基线数量
  y_batch_size: 1                # 每个区块任务中垂直层数的基线数量
  ticks_per_chunk_interval: 2    # 调度器重复间隔(以刻为单位)

  # 自适应限流
  tps_threshold: 18.0
  tps_min_chunks_per_interval: 1
  tps_min_y_batch_size: 1
  tps_smoothing: 0.75
  tps_check_interval_ticks: 1

  # 用于计算平滑处理速率的 ETA 平滑窗口(秒)
  eta_window_seconds: 8

  # 基于大小的缩放(让更大的清理器按比例处理更多工作)
  size_scale_enabled: true
  # scaleFactor = min(size_scale_cap, size * size_scale_multiplier)
  size_scale_multiplier: 1
  size_scale_cap: 8

  # 如果 >1,调度器间隔可以被分割以用于更大的清理器(谨慎使用)
  aggressive_interval_divisor: 1

# ----------------------------------------------------------------
# CoreProtect 日志记录(按区块批量)—— 避免使 CoreProtect 过载
# - log_chunk_summary:为每个已完成的区块发送单个摘要(推荐)
# - flush_interval_ticks / max_entries_per_flush 控制吞吐量
# ----------------------------------------------------------------
coreprotect:
  enabled: true
  log_chunk_summary: true
  flush_interval_ticks: 20
  max_entries_per_flush: 50
  queue_max_size: 5000
  queue_trim_to: 4000
  # 旧版回退方案(当 log_chunk_summary=true 时不使用)
  log_every_n: 10

# ----------------------------------------------------------------
# 安全与操作说明
# ----------------------------------------------------------------
# - 如果您启用了集成插件,本插件将拒绝代表离线所有者编辑受保护的区块。
#   这可以防止意外修改其他玩家的领地/区域。
# - 运行大型清理器时请监控服务器 TPS。本插件会根据 TPS 自动调整其吞吐量。
# - 如果在高规模环境下使用 CoreProtect 日志记录,请确保 CoreProtect 和磁盘 I/O 能够承受负载。
# - 为了快速恢复,默认 persistence.autosave_interval_seconds = 60s。您可以将其调低以实现更频繁的保存,
#   但这会增加磁盘写入量。

支持

需要此插件的支持,或希望添加对其他插件的支持?请在 Discord 上联系 @d15co7d!

你是这个资源的作者?登录后可认领此资源。

评论 0

0.0
暂无评分
5 星
0
4 星
0
3 星
0
2 星
0
1 星
0
我的评分

登录后参与评分

还没有评论,来抢沙发吧

评论配图

相似资源