☮ TownyPacifist
一个轻量级的 Towny 插件,为和平城镇执行和平状态——不仅限于其领地范围内。
? 简介
许多服务器都面临一个常见问题:来自和平城镇的玩家被敌对城镇击杀,或者和平城镇的成员攻击他人却无需承担后果。
TownyPacifist 通过直接挂钩 Towny 的和平标志(/t toggle peaceful)来解决此问题。无需自定义数据,无需额外命令——只要城镇在 Towny 中被标记为和平,该插件就会在整个地图范围内强制执行这一状态。
✨ 特性
- 零自定义存储 — 直接读取 Towny 的
isNeutral() 标志
- 双向保护 — 和平城镇既不能攻击别人,也不能被别人攻击
- 竞技场支持 — 和平玩家仍可在 Towny 竞技场地块内 PvP(
/plot set arena)
- EventWar 集成 — 与 EventWar 的中立系统自然兼容
- SiegeWar 集成 — 安装时尊重 SiegeWar 自身的和平城镇系统
- TownyCaptureSites 集成 — 安装时允许和平玩家在占领点内战斗
- 多语言 — 内置 9 种语言(en-US, pt-BR, es-ES, fr-FR, de-DE, zh-CN, ru-RU, pl-PL, tr-TR)
- 轻量级 — 仅有一个事件监听器,无数据库,无命令
- 跨平台 — 适用于 Bukkit、Spigot、Paper、Purpur 和 Folia
? 依赖项
⚙️ 工作原理
TownyPacifist 监听 TownyPlayerDamagePlayerEvent 并使用 Towny API 检查双方玩家的城镇归属:
玩家 A 攻击玩家 B
└─ 任意一方是否来自中立(和平)城镇?
├─ 否 → 不做任何操作,由 Towny 正常处理
├─ 是 → 他们是否在竞技场地块内?
│ ├─ 是 + 允许竞技场 → 允许战斗(无垃圾信息,进入时通知)
│ └─ 否 → 取消伤害 + 发送消息
└─ 双方均为和平状态 → 取消伤害 + 发送特定消息
“和平”状态由镇长使用 Towny 自带的命令设置:
/t toggle peaceful
无需使用 TownyPacifist 的任何命令。
? 配置
# 全局启用或禁用所有保护
enabled: true
# 允许和平城镇成员在 Towny 竞技场地块内进行 PvP
allow-pacifist-in-arenas: true
# 允许和平城镇成员在 TownyCaptureSites 地块内战斗(需要 TownyCaptureSites)
allow-pacifist-in-capture-sites: true
? 添加语言
TownyPacifist 使用 Towny 内置的翻译系统。消息会根据每位玩家的语言自动发送。
- 前往
plugins/TownyPacifist/lang/
- 复制
en-US.yml 并重命名(例如 es-ES.yml)
- 翻译其中的消息
- Towny 会自动识别——无需更改配置
? 从源码构建
要求:
- JDK 21(用于编译)
- Gradle 8.12(或使用自带的
gradlew)
- Towny JAR →
libs/Towny-x.x.x.x.jar(从 Towny releases 下载)
- EventWar JAR →
libs/EventWar-x.x.x.jar (可选,仅用于 IDE 支持)
./gradlew build
# 输出:build/libs/TownyPacifist-1.0.jar
?️ 计划中的集成
- 占领点 (Capture sites)
- SiegeWar
? 许可证
Apache 2.0 — 详见 LICENSE
? 作者
由 RN_Axol 制作
☮ TownyPacifist
A lightweight Towny addon that enforces peace for peaceful towns — everywhere, not just within their borders.
? About
Many servers struggle with a common problem: players from peaceful towns getting killed by aggressive towns, or peaceful town members attacking others without consequence.
TownyPacifist solves this by hooking directly into Towny's own peaceful flag (/t toggle peaceful). No custom data, no extra commands — if a town is marked as peaceful in Towny, this plugin enforces that everywhere on the map.
✨ Features
- Zero custom storage — reads directly from Towny's
isNeutral() flag
- Bidirectional protection — peaceful towns can't attack OR be attacked
- Arena support — peaceful players can still PvP inside Towny arena plots (
/plot set arena)
- EventWar integration — works naturally alongside EventWar's neutrality system
- SiegeWar integration — respects SiegeWar's own peaceful town system when installed
- TownyCaptureSites integration — allows peaceful players to fight inside capture sites when installed
- Multi-language — ships with 9 languages (en-US, pt-BR, es-ES, fr-FR, de-DE, zh-CN, ru-RU, pl-PL, tr-TR)
- Lightweight — a single event listener, no databases, no commands
- Cross-platform — runs on Bukkit, Spigot, Paper, Purpur and Folia
? Dependencies
⚙️ How It Works
TownyPacifist listens to TownyPlayerDamagePlayerEvent and checks both players' towns using Towny's API:
Player A hits Player B
└─ Is either player from a neutral (peaceful) town?
├─ No → do nothing, let Towny handle it normally
├─ Yes → are they inside an arena plot?
│ ├─ Yes + arenas allowed → permit combat (no spam, notified on entry)
│ └─ No → cancel damage + send message
└─ Both peaceful → cancel damage + specific message
The "peaceful" status is set by the town mayor using Towny's own command:
/t toggle peaceful
No TownyPacifist commands needed.
? Config
# Enable or disable all protection globally
enabled: true
# Allow peaceful town members to PvP inside Towny arena plots
allow-pacifist-in-arenas: true
# Allow peaceful town members to fight inside TownyCaptureSites plots (requires TownyCaptureSites)
allow-pacifist-in-capture-sites: true
? Adding a Language
TownyPacifist uses Towny's built-in translation system. Messages are delivered in each player's own language automatically.
- Go to
plugins/TownyPacifist/lang/
- Copy
en-US.yml and rename it (e.g. es-ES.yml)
- Translate the messages
- Towny picks it up automatically — no config change needed
? Building from Source
Requirements:
- JDK 21 (for compilation)
- Gradle 8.12 (or use the included
gradlew)
- Towny JAR →
libs/Towny-x.x.x.x.jar (download from Towny releases)
- EventWar JAR →
libs/EventWar-x.x.x.jar (optional, for IDE support only)
./gradlew build
# Output: build/libs/TownyPacifist-1.0.jar
?️ Planned Integrations
? License
Apache 2.0 — see LICENSE
? Author
Made by RN_Axol
评论 0
登录后参与评分
还没有评论,来抢沙发吧