release: 发布 1.3.1
This commit is contained in:
@@ -1,5 +1,19 @@
|
|||||||
# 更新日志
|
# 更新日志
|
||||||
|
|
||||||
|
## 1.3.1 - 2026-08-16
|
||||||
|
|
||||||
|
### 移除
|
||||||
|
|
||||||
|
- 移除内置维护模式、相关命令、权限、配置和 LuckPerms 软依赖;维护功能建议使用独立的 Maintenance 插件。
|
||||||
|
|
||||||
|
### 调整
|
||||||
|
|
||||||
|
- GitHub 仓库迁移至 InfstarMC 组织,并同步更新项目文档与下载地址。
|
||||||
|
|
||||||
|
### 升级说明
|
||||||
|
|
||||||
|
- 升级时不再读取 `maintenance.yml`;为避免删除管理员数据,服务器目录中的旧文件会原样保留,可在确认迁移完成后手动删除。
|
||||||
|
|
||||||
## 1.3.0 - 2026-08-05
|
## 1.3.0 - 2026-08-05
|
||||||
|
|
||||||
### 新增
|
### 新增
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
轻量、现代、面向 Paper 服务端的基础功能插件,灵感来自 CMI,但更聚焦于常用能力与模块化构建。
|
轻量、现代、面向 Paper 服务端的基础功能插件,灵感来自 CMI,但更聚焦于常用能力与模块化构建。
|
||||||
|
|
||||||
[](https://github.com/Coldsmiles/EssentialsC/releases)
|
[](https://github.com/InfstarMC/EssentialsC/releases)
|
||||||
[](LICENSE)
|
[](LICENSE)
|
||||||
[](https://papermc.io/)
|
[](https://papermc.io/)
|
||||||
[](https://adoptium.net/)
|
[](https://adoptium.net/)
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
- 最低支持版本为 `Paper 1.21.11`
|
- 最低支持版本为 `Paper 1.21.11`
|
||||||
- 已适配 `Paper 26.2`
|
- 已适配 `Paper 26.2`
|
||||||
- 插件统一使用 Paper 公共 API 和 Java 21 字节码,无需按服务端版本拆分构建
|
- 插件统一使用 Paper 公共 API 和 Java 21 字节码,无需按服务端版本拆分构建
|
||||||
- 配置按职责拆分:主行为与 SkinBridge、模块开关、菜单布局、维护模式和语言文本分别管理
|
- 配置按职责拆分:主行为与 SkinBridge、模块开关、菜单布局和语言文本分别管理
|
||||||
- 支持运行期模块开关,避免为不同功能组合构建多个插件版本
|
- 支持运行期模块开关,避免为不同功能组合构建多个插件版本
|
||||||
|
|
||||||
## 主要功能
|
## 主要功能
|
||||||
@@ -43,12 +43,10 @@
|
|||||||
- `/seen` `(/info)`
|
- `/seen` `(/info)`
|
||||||
- `/tpsbar`
|
- `/tpsbar`
|
||||||
- `/essc admin` 管理模式切换
|
- `/essc admin` 管理模式切换
|
||||||
- `/maintenance` `(/maint)` 维护模式管理
|
|
||||||
|
|
||||||
### 控制台命令
|
### 控制台命令
|
||||||
|
|
||||||
- `/essc help`、`/essc version`、`/essc reload`
|
- `/essc help`、`/essc version`、`/essc reload`
|
||||||
- `/maintenance [on|off|status|reload|add|remove|list]`,也可通过 `/essc maintenance ...` 执行
|
|
||||||
- `/seen [玩家]`、`/heal [玩家]`、`/feed [玩家]`、`/tpsbar [玩家]`
|
- `/seen [玩家]`、`/heal [玩家]`、`/feed [玩家]`、`/tpsbar [玩家]`
|
||||||
- `/essc skin [status|refresh] [玩家]`
|
- `/essc skin [status|refresh] [玩家]`
|
||||||
|
|
||||||
@@ -59,7 +57,6 @@
|
|||||||
- Shift + 右键快捷打开潜影盒
|
- Shift + 右键快捷打开潜影盒
|
||||||
- 潜影盒交互保护,尽量避免刷物品、吞物品和嵌套放入问题
|
- 潜影盒交互保护,尽量避免刷物品、吞物品和嵌套放入问题
|
||||||
- 管理模式独立背包、装备栏与状态切换
|
- 管理模式独立背包、装备栏与状态切换
|
||||||
- 维护模式:替换 MOTD、登录拦截、白名单放行和管理员拦截通知
|
|
||||||
- Enderman 掉落方块控制
|
- Enderman 掉落方块控制
|
||||||
|
|
||||||
## 模块配置
|
## 模块配置
|
||||||
@@ -72,19 +69,19 @@
|
|||||||
| `admin-mode` | 开启 | `/essc admin` 管理模式与独立状态保存 |
|
| `admin-mode` | 开启 | `/essc admin` 管理模式与独立状态保存 |
|
||||||
| `tpsbar` | 开启 | 插件版 TPSBar,检测到服务端原生命令时自动避免冲突 |
|
| `tpsbar` | 开启 | 插件版 TPSBar,检测到服务端原生命令时自动避免冲突 |
|
||||||
| `mob-drops` | 关闭 | 末影人掉落控制,默认关闭以保留过去标准版行为 |
|
| `mob-drops` | 关闭 | 末影人掉落控制,默认关闭以保留过去标准版行为 |
|
||||||
| `maintenance` | 开启 | 维护模式命令、MOTD 替换、登录拦截、白名单和拦截通知 |
|
|
||||||
| `skin-bridge` | 关闭 | 查询外置 Yggdrasil profile,并通过 MineSkin 与 Paper Profile API 同步皮肤 |
|
| `skin-bridge` | 关闭 | 查询外置 Yggdrasil profile,并通过 MineSkin 与 Paper Profile API 同步皮肤 |
|
||||||
|
|
||||||
修改模块开关后使用 `/essc reload` 即可刷新运行期服务、监听器和命令门禁。可选模块命令始终注册,模块关闭时会返回统一的停用提示,因此无需为了启用命令重启服务器。
|
修改模块开关后使用 `/essc reload` 即可刷新运行期服务、监听器和命令门禁。可选模块命令始终注册,模块关闭时会返回统一的停用提示,因此无需为了启用命令重启服务器。
|
||||||
|
|
||||||
## 安装说明
|
## 安装说明
|
||||||
|
|
||||||
1. 从 [Releases](https://github.com/Coldsmiles/EssentialsC/releases) 下载所需版本。
|
1. 从 [Releases](https://github.com/InfstarMC/EssentialsC/releases) 下载所需版本。
|
||||||
2. 将插件放入服务端的 `plugins/` 目录。
|
2. 将插件放入服务端的 `plugins/` 目录。
|
||||||
3. 建议安装 LuckPerms;维护模式会优先通过其缓存异步检查登录权限,未安装时会在玩家加入后立即复核。
|
3. 启动一次服务端以生成配置文件。
|
||||||
4. 启动一次服务端以生成配置文件。
|
4. 按需修改 `plugins/EssentialsC/` 下的配置文件与 `lang/` 语言文件。
|
||||||
5. 按需修改 `plugins/EssentialsC/` 下的配置文件与 `lang/` 语言文件。
|
5. 使用权限插件为玩家分配所需权限。
|
||||||
6. 使用权限插件为玩家分配所需权限。
|
|
||||||
|
维护功能建议独立安装 [Maintenance](https://github.com/kennytv/Maintenance)。EssentialsC 不再内置维护模式,也不要求安装该插件。
|
||||||
|
|
||||||
## 配置说明
|
## 配置说明
|
||||||
|
|
||||||
@@ -103,14 +100,6 @@ SkinBridge 默认关闭。使用前需启用 `modules.yml` 中的 `modules.skin-
|
|||||||
- 功能模块开关
|
- 功能模块开关
|
||||||
- `blocks-menu.yml`
|
- `blocks-menu.yml`
|
||||||
- 便捷菜单分区、槽位、材质和权限
|
- 便捷菜单分区、槽位、材质和权限
|
||||||
- `maintenance.yml`
|
|
||||||
- 维护模式状态
|
|
||||||
- 维护 MOTD
|
|
||||||
- 维护踢出提示
|
|
||||||
- 维护 BossBar
|
|
||||||
- 绕过权限
|
|
||||||
- 维护白名单
|
|
||||||
- 拦截通知权限
|
|
||||||
- `lang/zh_CN.yml`、`lang/en_US.yml`
|
- `lang/zh_CN.yml`、`lang/en_US.yml`
|
||||||
- 命令反馈
|
- 命令反馈
|
||||||
- 帮助信息
|
- 帮助信息
|
||||||
@@ -151,13 +140,10 @@ essentialsc.tpa.bypass-cooldown
|
|||||||
essentialsc.tpa.warmup.3
|
essentialsc.tpa.warmup.3
|
||||||
essentialsc.command.admin
|
essentialsc.command.admin
|
||||||
essentialsc.command.tpsbar
|
essentialsc.command.tpsbar
|
||||||
essentialsc.command.maintenance
|
|
||||||
essentialsc.command.skin
|
essentialsc.command.skin
|
||||||
essentialsc.command.skin.status
|
essentialsc.command.skin.status
|
||||||
essentialsc.command.skin.refresh
|
essentialsc.command.skin.refresh
|
||||||
essentialsc.command.skin.others
|
essentialsc.command.skin.others
|
||||||
essentialsc.maintenance.bypass
|
|
||||||
essentialsc.maintenance.notify
|
|
||||||
essentialsc.shulkerbox.open
|
essentialsc.shulkerbox.open
|
||||||
essentialsc.mobdrops.enderman
|
essentialsc.mobdrops.enderman
|
||||||
essentialsc.*
|
essentialsc.*
|
||||||
@@ -168,7 +154,7 @@ essentialsc.*
|
|||||||
## 从源码构建
|
## 从源码构建
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/Coldsmiles/EssentialsC.git
|
git clone https://github.com/InfstarMC/EssentialsC.git
|
||||||
cd EssentialsC
|
cd EssentialsC
|
||||||
./gradlew build
|
./gradlew build
|
||||||
```
|
```
|
||||||
@@ -216,5 +202,5 @@ IDEA 运行配置会先构建插件,再由启动脚本复制最新 JAR,并
|
|||||||
|
|
||||||
## 仓库
|
## 仓库
|
||||||
|
|
||||||
- GitHub: <https://github.com/Coldsmiles/EssentialsC>
|
- GitHub: <https://github.com/InfstarMC/EssentialsC>
|
||||||
- Gitea: <https://git.infstar.cn/InfStarMC/EssentialsC>
|
- Gitea: <https://git.infstar.cn/InfStarMC/EssentialsC>
|
||||||
|
|||||||
+1
-2
@@ -10,7 +10,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = 'cn.infstar'
|
group = 'cn.infstar'
|
||||||
def pluginVersion = providers.gradleProperty('pluginVersion').orElse('1.3.0').get()
|
def pluginVersion = providers.gradleProperty('pluginVersion').orElse('1.3.1').get()
|
||||||
version = pluginVersion
|
version = pluginVersion
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
@@ -23,7 +23,6 @@ repositories {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
paperweight.paperDevBundle('1.21.11-R0.1-SNAPSHOT')
|
paperweight.paperDevBundle('1.21.11-R0.1-SNAPSHOT')
|
||||||
compileOnly 'net.luckperms:api:5.5'
|
|
||||||
implementation 'com.google.code.gson:gson:2.11.0'
|
implementation 'com.google.code.gson:gson:2.11.0'
|
||||||
testImplementation platform('org.junit:junit-bom:5.13.4')
|
testImplementation platform('org.junit:junit-bom:5.13.4')
|
||||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||||
|
|||||||
@@ -0,0 +1,189 @@
|
|||||||
|
name: EssentialsC
|
||||||
|
description: 高版本基础工具箱
|
||||||
|
version: 1.3.1
|
||||||
|
|
||||||
|
main: cn.infstar.essentialsC.EssentialsC
|
||||||
|
api-version: '1.21.11'
|
||||||
|
load: POSTWORLD
|
||||||
|
folia-supported: false
|
||||||
|
|
||||||
|
authors: [ Coldsmiles_7 ]
|
||||||
|
website: www.infstar.cn
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
essentialsc.command.workbench:
|
||||||
|
description: 允许使用 /workbench
|
||||||
|
default: op
|
||||||
|
essentialsc.command.anvil:
|
||||||
|
description: 允许使用 /anvil
|
||||||
|
default: op
|
||||||
|
essentialsc.command.cartographytable:
|
||||||
|
description: 允许使用 /cartographytable
|
||||||
|
default: op
|
||||||
|
essentialsc.command.grindstone:
|
||||||
|
description: 允许使用 /grindstone
|
||||||
|
default: op
|
||||||
|
essentialsc.command.loom:
|
||||||
|
description: 允许使用 /loom
|
||||||
|
default: op
|
||||||
|
essentialsc.command.smithingtable:
|
||||||
|
description: 允许使用 /smithingtable
|
||||||
|
default: op
|
||||||
|
essentialsc.command.stonecutter:
|
||||||
|
description: 允许使用 /stonecutter
|
||||||
|
default: op
|
||||||
|
essentialsc.command.enderchest:
|
||||||
|
description: 允许使用 /enderchest
|
||||||
|
default: op
|
||||||
|
essentialsc.command.blocks:
|
||||||
|
description: 允许使用 /essc blocks
|
||||||
|
default: true
|
||||||
|
essentialsc.command.hat:
|
||||||
|
description: 允许使用 /hat
|
||||||
|
default: op
|
||||||
|
essentialsc.command.suicide:
|
||||||
|
description: 允许使用 /suicide
|
||||||
|
default: op
|
||||||
|
essentialsc.command.fly:
|
||||||
|
description: 允许使用 /fly
|
||||||
|
default: op
|
||||||
|
essentialsc.command.nightvision:
|
||||||
|
description: 允许使用 /nightvision
|
||||||
|
default: op
|
||||||
|
essentialsc.command.glow:
|
||||||
|
description: 允许使用 /glow
|
||||||
|
default: op
|
||||||
|
essentialsc.command.heal:
|
||||||
|
description: 允许使用 /heal
|
||||||
|
default: op
|
||||||
|
essentialsc.command.heal.others:
|
||||||
|
description: 允许治疗其他玩家
|
||||||
|
default: op
|
||||||
|
essentialsc.command.vanish:
|
||||||
|
description: 允许使用 /vanish
|
||||||
|
default: op
|
||||||
|
essentialsc.vanish.see:
|
||||||
|
description: 允许看见隐身玩家
|
||||||
|
default: op
|
||||||
|
essentialsc.command.seen:
|
||||||
|
description: 允许使用 /seen
|
||||||
|
default: op
|
||||||
|
essentialsc.command.feed:
|
||||||
|
description: 允许使用 /feed
|
||||||
|
default: op
|
||||||
|
essentialsc.command.feed.others:
|
||||||
|
description: 允许为其他玩家补充饥饿值
|
||||||
|
default: op
|
||||||
|
essentialsc.command.repair:
|
||||||
|
description: 允许使用 /repair
|
||||||
|
default: op
|
||||||
|
essentialsc.command.repair.all:
|
||||||
|
description: 允许使用 /repair all
|
||||||
|
default: op
|
||||||
|
essentialsc.command.tpa:
|
||||||
|
description: 允许发送 /tpa 请求
|
||||||
|
default: true
|
||||||
|
essentialsc.command.tpahere:
|
||||||
|
description: 允许发送 /tpahere 请求
|
||||||
|
default: true
|
||||||
|
essentialsc.command.tpaall:
|
||||||
|
description: 允许向所有玩家发送 /tpahere 请求
|
||||||
|
default: op
|
||||||
|
essentialsc.command.tpaccept:
|
||||||
|
description: 允许接受 TPA 请求
|
||||||
|
default: true
|
||||||
|
essentialsc.command.tpdeny:
|
||||||
|
description: 允许拒绝 TPA 请求
|
||||||
|
default: true
|
||||||
|
essentialsc.command.tpignore:
|
||||||
|
description: 允许切换是否忽略 TPA 请求
|
||||||
|
default: true
|
||||||
|
essentialsc.tpa.bypass-warmup:
|
||||||
|
description: 允许绕过 TPA 传送预热
|
||||||
|
default: op
|
||||||
|
essentialsc.tpa.bypass-cooldown:
|
||||||
|
description: 允许绕过 TPA 冷却
|
||||||
|
default: op
|
||||||
|
essentialsc.command.admin:
|
||||||
|
description: 允许使用 /essc admin
|
||||||
|
default: op
|
||||||
|
essentialsc.command.help:
|
||||||
|
description: 允许使用 /essc help
|
||||||
|
default: true
|
||||||
|
essentialsc.command.reload:
|
||||||
|
description: 允许使用 /essc reload
|
||||||
|
default: op
|
||||||
|
essentialsc.command.tpsbar:
|
||||||
|
description: 允许使用 /tpsbar
|
||||||
|
default: op
|
||||||
|
essentialsc.command.tpsbar.others:
|
||||||
|
description: 允许为其他玩家切换 /tpsbar
|
||||||
|
default: op
|
||||||
|
essentialsc.command.skin:
|
||||||
|
description: 允许使用 SkinBridge 管理命令
|
||||||
|
default: op
|
||||||
|
children:
|
||||||
|
essentialsc.command.skin.status: true
|
||||||
|
essentialsc.command.skin.refresh: true
|
||||||
|
essentialsc.command.skin.others: true
|
||||||
|
essentialsc.command.skin.status:
|
||||||
|
description: 允许查看 SkinBridge 状态
|
||||||
|
default: op
|
||||||
|
essentialsc.command.skin.refresh:
|
||||||
|
description: 允许强制刷新自己的皮肤
|
||||||
|
default: op
|
||||||
|
essentialsc.command.skin.others:
|
||||||
|
description: 允许查看或刷新其他玩家的皮肤
|
||||||
|
default: op
|
||||||
|
essentialsc.shulkerbox.open:
|
||||||
|
description: 允许通过 Shift+右键快捷打开潜影盒
|
||||||
|
default: op
|
||||||
|
essentialsc.mobdrops.enderman:
|
||||||
|
description: 允许控制末影人死亡时是否掉落物品
|
||||||
|
default: op
|
||||||
|
essentialsc.*:
|
||||||
|
description: 授予 EssentialsC 的全部权限
|
||||||
|
default: false
|
||||||
|
children:
|
||||||
|
essentialsc.command.workbench: true
|
||||||
|
essentialsc.command.anvil: true
|
||||||
|
essentialsc.command.cartographytable: true
|
||||||
|
essentialsc.command.grindstone: true
|
||||||
|
essentialsc.command.loom: true
|
||||||
|
essentialsc.command.smithingtable: true
|
||||||
|
essentialsc.command.stonecutter: true
|
||||||
|
essentialsc.command.enderchest: true
|
||||||
|
essentialsc.command.blocks: true
|
||||||
|
essentialsc.command.hat: true
|
||||||
|
essentialsc.command.suicide: true
|
||||||
|
essentialsc.command.fly: true
|
||||||
|
essentialsc.command.nightvision: true
|
||||||
|
essentialsc.command.glow: true
|
||||||
|
essentialsc.command.heal: true
|
||||||
|
essentialsc.command.heal.others: true
|
||||||
|
essentialsc.command.vanish: true
|
||||||
|
essentialsc.vanish.see: true
|
||||||
|
essentialsc.command.seen: true
|
||||||
|
essentialsc.command.feed: true
|
||||||
|
essentialsc.command.feed.others: true
|
||||||
|
essentialsc.command.repair: true
|
||||||
|
essentialsc.command.repair.all: true
|
||||||
|
essentialsc.command.tpa: true
|
||||||
|
essentialsc.command.tpahere: true
|
||||||
|
essentialsc.command.tpaall: true
|
||||||
|
essentialsc.command.tpaccept: true
|
||||||
|
essentialsc.command.tpdeny: true
|
||||||
|
essentialsc.command.tpignore: true
|
||||||
|
essentialsc.tpa.bypass-warmup: true
|
||||||
|
essentialsc.tpa.bypass-cooldown: true
|
||||||
|
essentialsc.command.admin: true
|
||||||
|
essentialsc.command.help: true
|
||||||
|
essentialsc.command.reload: true
|
||||||
|
essentialsc.command.tpsbar: true
|
||||||
|
essentialsc.command.tpsbar.others: true
|
||||||
|
essentialsc.command.skin: true
|
||||||
|
essentialsc.command.skin.status: true
|
||||||
|
essentialsc.command.skin.refresh: true
|
||||||
|
essentialsc.command.skin.others: true
|
||||||
|
essentialsc.shulkerbox.open: true
|
||||||
|
essentialsc.mobdrops.enderman: true
|
||||||
@@ -11,8 +11,6 @@ import cn.infstar.essentialsC.listeners.MobDropListener;
|
|||||||
import cn.infstar.essentialsC.listeners.MobDropMenuListener;
|
import cn.infstar.essentialsC.listeners.MobDropMenuListener;
|
||||||
import cn.infstar.essentialsC.listeners.ShulkerBoxListener;
|
import cn.infstar.essentialsC.listeners.ShulkerBoxListener;
|
||||||
import cn.infstar.essentialsC.listeners.VanishListener;
|
import cn.infstar.essentialsC.listeners.VanishListener;
|
||||||
import cn.infstar.essentialsC.maintenance.MaintenanceListener;
|
|
||||||
import cn.infstar.essentialsC.maintenance.MaintenanceManager;
|
|
||||||
import cn.infstar.essentialsC.player.PlayerStateManager;
|
import cn.infstar.essentialsC.player.PlayerStateManager;
|
||||||
import cn.infstar.essentialsC.skinbridge.SkinBridgeManager;
|
import cn.infstar.essentialsC.skinbridge.SkinBridgeManager;
|
||||||
import cn.infstar.essentialsC.teleport.TeleportRequestManager;
|
import cn.infstar.essentialsC.teleport.TeleportRequestManager;
|
||||||
@@ -38,10 +36,8 @@ public final class EssentialsC extends JavaPlugin {
|
|||||||
private ModuleManager moduleManager;
|
private ModuleManager moduleManager;
|
||||||
private FeatureConfigManager featureConfigManager;
|
private FeatureConfigManager featureConfigManager;
|
||||||
private AdminModeManager adminModeManager;
|
private AdminModeManager adminModeManager;
|
||||||
private MaintenanceManager maintenanceManager;
|
|
||||||
private TeleportRequestManager teleportRequestManager;
|
private TeleportRequestManager teleportRequestManager;
|
||||||
private PlayerStateManager playerStateManager;
|
private PlayerStateManager playerStateManager;
|
||||||
private MaintenanceListener maintenanceListener;
|
|
||||||
private TpsBarService tpsBarManager;
|
private TpsBarService tpsBarManager;
|
||||||
private ShulkerBoxListener shulkerBoxListener;
|
private ShulkerBoxListener shulkerBoxListener;
|
||||||
private BlocksMenuCommand blocksMenuCommandListener;
|
private BlocksMenuCommand blocksMenuCommandListener;
|
||||||
@@ -72,9 +68,6 @@ public final class EssentialsC extends JavaPlugin {
|
|||||||
if (adminModeManager != null) {
|
if (adminModeManager != null) {
|
||||||
adminModeManager.shutdown();
|
adminModeManager.shutdown();
|
||||||
}
|
}
|
||||||
if (maintenanceManager != null) {
|
|
||||||
maintenanceManager.shutdown();
|
|
||||||
}
|
|
||||||
if (teleportRequestManager != null) {
|
if (teleportRequestManager != null) {
|
||||||
teleportRequestManager.shutdown();
|
teleportRequestManager.shutdown();
|
||||||
}
|
}
|
||||||
@@ -111,10 +104,6 @@ public final class EssentialsC extends JavaPlugin {
|
|||||||
return featureConfigManager;
|
return featureConfigManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MaintenanceManager getMaintenanceManager() {
|
|
||||||
return maintenanceManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TeleportRequestManager getTeleportRequestManager() {
|
public TeleportRequestManager getTeleportRequestManager() {
|
||||||
return teleportRequestManager;
|
return teleportRequestManager;
|
||||||
}
|
}
|
||||||
@@ -135,7 +124,6 @@ public final class EssentialsC extends JavaPlugin {
|
|||||||
moduleStatus.clear();
|
moduleStatus.clear();
|
||||||
refreshCorePlayerFeatures();
|
refreshCorePlayerFeatures();
|
||||||
refreshAdminMode();
|
refreshAdminMode();
|
||||||
refreshMaintenance();
|
|
||||||
refreshTpsBar();
|
refreshTpsBar();
|
||||||
refreshBlocks();
|
refreshBlocks();
|
||||||
refreshMobDrops();
|
refreshMobDrops();
|
||||||
@@ -179,32 +167,6 @@ public final class EssentialsC extends JavaPlugin {
|
|||||||
setModuleStatus("管理模式", true, "监听器已注册");
|
setModuleStatus("管理模式", true, "监听器已注册");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshMaintenance() {
|
|
||||||
if (!moduleManager.isEnabled(ModuleManager.MAINTENANCE)) {
|
|
||||||
if (maintenanceManager != null) {
|
|
||||||
maintenanceManager.shutdown();
|
|
||||||
maintenanceManager = null;
|
|
||||||
}
|
|
||||||
if (maintenanceListener != null) {
|
|
||||||
HandlerList.unregisterAll(maintenanceListener);
|
|
||||||
maintenanceListener = null;
|
|
||||||
}
|
|
||||||
setModuleStatus("维护模式", false, "已禁用");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (maintenanceManager == null) {
|
|
||||||
maintenanceManager = new MaintenanceManager(this);
|
|
||||||
} else {
|
|
||||||
maintenanceManager.reload();
|
|
||||||
}
|
|
||||||
if (maintenanceListener == null) {
|
|
||||||
maintenanceListener = new MaintenanceListener(this, maintenanceManager);
|
|
||||||
getServer().getPluginManager().registerEvents(maintenanceListener, this);
|
|
||||||
}
|
|
||||||
setModuleStatus("维护模式", true, maintenanceManager.isEnabled() ? "当前开启" : "当前关闭");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void refreshTpsBar() {
|
private void refreshTpsBar() {
|
||||||
if (!moduleManager.isEnabled(ModuleManager.TPSBAR)) {
|
if (!moduleManager.isEnabled(ModuleManager.TPSBAR)) {
|
||||||
if (tpsBarManager != null) {
|
if (tpsBarManager != null) {
|
||||||
@@ -313,7 +275,6 @@ public final class EssentialsC extends JavaPlugin {
|
|||||||
|
|
||||||
private void unregisterRuntimeListeners() {
|
private void unregisterRuntimeListeners() {
|
||||||
unregisterListener(adminModeManager);
|
unregisterListener(adminModeManager);
|
||||||
unregisterListener(maintenanceListener);
|
|
||||||
unregisterListener(shulkerBoxListener);
|
unregisterListener(shulkerBoxListener);
|
||||||
unregisterListener(blocksMenuCommandListener);
|
unregisterListener(blocksMenuCommandListener);
|
||||||
unregisterListener(mobDropListener);
|
unregisterListener(mobDropListener);
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ public final class ModuleManager {
|
|||||||
public static final String ADMIN_MODE = "admin-mode";
|
public static final String ADMIN_MODE = "admin-mode";
|
||||||
public static final String TPSBAR = "tpsbar";
|
public static final String TPSBAR = "tpsbar";
|
||||||
public static final String MOB_DROPS = "mob-drops";
|
public static final String MOB_DROPS = "mob-drops";
|
||||||
public static final String MAINTENANCE = "maintenance";
|
|
||||||
public static final String SKIN_BRIDGE = "skin-bridge";
|
public static final String SKIN_BRIDGE = "skin-bridge";
|
||||||
|
|
||||||
private static final Map<String, Boolean> DEFAULT_MODULES = new LinkedHashMap<>();
|
private static final Map<String, Boolean> DEFAULT_MODULES = new LinkedHashMap<>();
|
||||||
@@ -29,7 +28,6 @@ public final class ModuleManager {
|
|||||||
DEFAULT_MODULES.put(ADMIN_MODE, true);
|
DEFAULT_MODULES.put(ADMIN_MODE, true);
|
||||||
DEFAULT_MODULES.put(TPSBAR, true);
|
DEFAULT_MODULES.put(TPSBAR, true);
|
||||||
DEFAULT_MODULES.put(MOB_DROPS, false);
|
DEFAULT_MODULES.put(MOB_DROPS, false);
|
||||||
DEFAULT_MODULES.put(MAINTENANCE, true);
|
|
||||||
DEFAULT_MODULES.put(SKIN_BRIDGE, false);
|
DEFAULT_MODULES.put(SKIN_BRIDGE, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,21 +55,25 @@ public final class ModuleManager {
|
|||||||
throw new IllegalStateException("无法加载 modules.yml,请修复配置格式后重试。", exception);
|
throw new IllegalStateException("无法加载 modules.yml,请修复配置格式后重试。", exception);
|
||||||
}
|
}
|
||||||
modulesConfig = loaded;
|
modulesConfig = loaded;
|
||||||
boolean removedJeiSync = modulesConfig.contains("modules.jei-sync", true);
|
boolean removedRetiredModules = false;
|
||||||
if (removedJeiSync) {
|
for (String retiredModule : new String[]{"jei-sync", "maintenance"}) {
|
||||||
modulesConfig.set("modules.jei-sync", null);
|
String retiredPath = "modules." + retiredModule;
|
||||||
|
if (modulesConfig.contains(retiredPath, true)) {
|
||||||
|
modulesConfig.set(retiredPath, null);
|
||||||
|
removedRetiredModules = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
modulesConfig.addDefault("config-version", CURRENT_CONFIG_VERSION);
|
modulesConfig.addDefault("config-version", CURRENT_CONFIG_VERSION);
|
||||||
for (Map.Entry<String, Boolean> module : DEFAULT_MODULES.entrySet()) {
|
for (Map.Entry<String, Boolean> module : DEFAULT_MODULES.entrySet()) {
|
||||||
modulesConfig.addDefault(path(module.getKey()), module.getValue());
|
modulesConfig.addDefault(path(module.getKey()), module.getValue());
|
||||||
}
|
}
|
||||||
modulesConfig.options().copyDefaults(true);
|
modulesConfig.options().copyDefaults(true);
|
||||||
if (removedJeiSync) {
|
if (removedRetiredModules) {
|
||||||
try {
|
try {
|
||||||
AtomicYamlWriter.save(modulesConfig, modulesFile);
|
AtomicYamlWriter.save(modulesConfig, modulesFile);
|
||||||
plugin.getLogger().info("已从 modules.yml 移除停用的 JEI 配方同步配置。");
|
plugin.getLogger().info("已从 modules.yml 移除退役功能的配置项。");
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
plugin.getLogger().warning("清理 modules.yml 中的 JEI 配置失败: " + exception.getMessage());
|
plugin.getLogger().warning("清理 modules.yml 中的退役配置失败: " + exception.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ public final class CommandRegistry {
|
|||||||
registerCore("tpignore", "essentialsc.command.tpignore", TpIgnoreCommand::new);
|
registerCore("tpignore", "essentialsc.command.tpignore", TpIgnoreCommand::new);
|
||||||
register("tpsbar", "essentialsc.command.tpsbar", ModuleManager.TPSBAR, TpsBarCommand::new);
|
register("tpsbar", "essentialsc.command.tpsbar", ModuleManager.TPSBAR, TpsBarCommand::new);
|
||||||
register("mobdrops", "essentialsc.mobdrops.enderman", ModuleManager.MOB_DROPS, MobDropCommand::new);
|
register("mobdrops", "essentialsc.mobdrops.enderman", ModuleManager.MOB_DROPS, MobDropCommand::new);
|
||||||
register("maintenance", "essentialsc.command.maintenance", ModuleManager.MAINTENANCE, MaintenanceCommand::new, "maint");
|
|
||||||
registerSubCommand("admin", "essentialsc.command.admin", ModuleManager.ADMIN_MODE, AdminCommand::new);
|
registerSubCommand("admin", "essentialsc.command.admin", ModuleManager.ADMIN_MODE, AdminCommand::new);
|
||||||
registerSubCommand("skin", "essentialsc.command.skin", ModuleManager.SKIN_BRIDGE, SkinBridgeCommand::new);
|
registerSubCommand("skin", "essentialsc.command.skin", ModuleManager.SKIN_BRIDGE, SkinBridgeCommand::new);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,10 +104,6 @@ public class HelpCommand extends BaseCommand implements TabCompleter {
|
|||||||
if (CommandRegistry.isAvailable("tpsbar") && sender.hasPermission("essentialsc.command.tpsbar")) {
|
if (CommandRegistry.isAvailable("tpsbar") && sender.hasPermission("essentialsc.command.tpsbar")) {
|
||||||
sendPrefixed(sender, lang.getString("help.commands.tpsbar"));
|
sendPrefixed(sender, lang.getString("help.commands.tpsbar"));
|
||||||
}
|
}
|
||||||
if (CommandRegistry.isAvailable("maintenance")
|
|
||||||
&& sender.hasPermission("essentialsc.command.maintenance")) {
|
|
||||||
sendPrefixed(sender, lang.getString("help.commands.maintenance"));
|
|
||||||
}
|
|
||||||
sender.sendMessage("");
|
sender.sendMessage("");
|
||||||
sendPrefixed(sender, lang.getString("help.footer"));
|
sendPrefixed(sender, lang.getString("help.footer"));
|
||||||
}
|
}
|
||||||
@@ -282,10 +278,6 @@ public class HelpCommand extends BaseCommand implements TabCompleter {
|
|||||||
otherCommands.append(lang.getString("help.commands.tpsbar")).append("\n");
|
otherCommands.append(lang.getString("help.commands.tpsbar")).append("\n");
|
||||||
hasOtherCommands = true;
|
hasOtherCommands = true;
|
||||||
}
|
}
|
||||||
if (CommandRegistry.isAvailable("maintenance") && player.hasPermission("essentialsc.command.maintenance")) {
|
|
||||||
otherCommands.append(lang.getString("help.commands.maintenance")).append("\n");
|
|
||||||
hasOtherCommands = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasOtherCommands) {
|
if (hasOtherCommands) {
|
||||||
sendPrefixed(player, lang.getString("help.section-other"));
|
sendPrefixed(player, lang.getString("help.section-other"));
|
||||||
@@ -367,8 +359,6 @@ public class HelpCommand extends BaseCommand implements TabCompleter {
|
|||||||
{"tpignore", "essentialsc.command.tpignore"},
|
{"tpignore", "essentialsc.command.tpignore"},
|
||||||
{"skin", "essentialsc.command.skin"},
|
{"skin", "essentialsc.command.skin"},
|
||||||
{"tpsbar", "essentialsc.command.tpsbar"},
|
{"tpsbar", "essentialsc.command.tpsbar"},
|
||||||
{"maintenance", "essentialsc.command.maintenance"},
|
|
||||||
{"maint", "essentialsc.command.maintenance"},
|
|
||||||
{"mobdrops", "essentialsc.mobdrops.enderman"},
|
{"mobdrops", "essentialsc.mobdrops.enderman"},
|
||||||
{"admin", "essentialsc.command.admin"},
|
{"admin", "essentialsc.command.admin"},
|
||||||
{"version", null},
|
{"version", null},
|
||||||
@@ -451,10 +441,6 @@ public class HelpCommand extends BaseCommand implements TabCompleter {
|
|||||||
return players;
|
return players;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((subCmd.equals("maintenance") || subCmd.equals("maint"))
|
|
||||||
&& sender.hasPermission("essentialsc.command.maintenance")) {
|
|
||||||
return completeMaintenanceArgs(args[1]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length == 3 && args[0].equalsIgnoreCase("skin")
|
if (args.length == 3 && args[0].equalsIgnoreCase("skin")
|
||||||
@@ -499,14 +485,4 @@ public class HelpCommand extends BaseCommand implements TabCompleter {
|
|||||||
return completions;
|
return completions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> completeMaintenanceArgs(String partialInput) {
|
|
||||||
List<String> completions = new ArrayList<>();
|
|
||||||
String partial = partialInput.toLowerCase();
|
|
||||||
for (String option : List.of("on", "off", "status", "reload", "add", "remove", "list")) {
|
|
||||||
if (option.startsWith(partial)) {
|
|
||||||
completions.add(option);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return completions;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,179 +0,0 @@
|
|||||||
package cn.infstar.essentialsC.commands;
|
|
||||||
|
|
||||||
import cn.infstar.essentialsC.maintenance.MaintenanceManager;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.TabCompleter;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class MaintenanceCommand extends BaseCommand implements TabCompleter {
|
|
||||||
|
|
||||||
public MaintenanceCommand() {
|
|
||||||
super("essentialsc.command.maintenance");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean execute(Player player, String[] args) {
|
|
||||||
return executeCommand(player, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean executeConsole(CommandSender sender, String[] args) {
|
|
||||||
return executeCommand(sender, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean executeCommand(CommandSender sender, String[] args) {
|
|
||||||
MaintenanceManager maintenanceManager = plugin.getMaintenanceManager();
|
|
||||||
if (maintenanceManager == null) {
|
|
||||||
sender.sendMessage(getLang().getPrefixedString("messages.module-disabled"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 0 || args[0].equalsIgnoreCase("status")) {
|
|
||||||
sendStatus(sender, maintenanceManager);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (args[0].toLowerCase(Locale.ROOT)) {
|
|
||||||
case "on", "enable", "enabled" -> {
|
|
||||||
if (maintenanceManager.setEnabled(true) == MaintenanceManager.OperationResult.SAVE_FAILED) {
|
|
||||||
sendSaveFailed(sender);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
sender.sendMessage(getLang().getPrefixedString("maintenance.messages.enabled"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "off", "disable", "disabled" -> {
|
|
||||||
if (maintenanceManager.setEnabled(false) == MaintenanceManager.OperationResult.SAVE_FAILED) {
|
|
||||||
sendSaveFailed(sender);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
sender.sendMessage(getLang().getPrefixedString("maintenance.messages.disabled"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "reload" -> {
|
|
||||||
maintenanceManager.reload();
|
|
||||||
sender.sendMessage(getLang().getPrefixedString("maintenance.messages.reloaded"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "add" -> {
|
|
||||||
if (args.length < 2) {
|
|
||||||
sender.sendMessage(getLang().getPrefixedString("maintenance.messages.add-usage"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
String target = args[1];
|
|
||||||
MaintenanceManager.OperationResult result = maintenanceManager.addWhitelistEntry(target);
|
|
||||||
if (result == MaintenanceManager.OperationResult.SAVE_FAILED) {
|
|
||||||
sendSaveFailed(sender);
|
|
||||||
} else if (result == MaintenanceManager.OperationResult.SUCCESS) {
|
|
||||||
sender.sendMessage(getLang().getPrefixedString("maintenance.messages.whitelist-added",
|
|
||||||
Map.of("player", target)));
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(getLang().getPrefixedString("maintenance.messages.whitelist-exists",
|
|
||||||
Map.of("player", target)));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (args.length < 2) {
|
|
||||||
sender.sendMessage(getLang().getPrefixedString("maintenance.messages.remove-usage"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
String target = args[1];
|
|
||||||
MaintenanceManager.OperationResult result = maintenanceManager.removeWhitelistEntry(target);
|
|
||||||
if (result == MaintenanceManager.OperationResult.SAVE_FAILED) {
|
|
||||||
sendSaveFailed(sender);
|
|
||||||
} else if (result == MaintenanceManager.OperationResult.SUCCESS) {
|
|
||||||
sender.sendMessage(getLang().getPrefixedString("maintenance.messages.whitelist-removed",
|
|
||||||
Map.of("player", target)));
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(getLang().getPrefixedString("maintenance.messages.whitelist-missing",
|
|
||||||
Map.of("player", target)));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "list" -> {
|
|
||||||
sendWhitelist(sender, maintenanceManager);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(getLang().getPrefixedString("maintenance.messages.usage"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendStatus(CommandSender sender, MaintenanceManager maintenanceManager) {
|
|
||||||
String status = getLang().getString(maintenanceManager.isEnabled()
|
|
||||||
? "maintenance.status.enabled"
|
|
||||||
: "maintenance.status.disabled");
|
|
||||||
sender.sendMessage(getLang().getPrefixedString("maintenance.messages.status",
|
|
||||||
Map.of(
|
|
||||||
"status", status,
|
|
||||||
"whitelist_count", String.valueOf(maintenanceManager.getWhitelistCount())
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendWhitelist(CommandSender sender, MaintenanceManager maintenanceManager) {
|
|
||||||
List<String> entries = maintenanceManager.getWhitelistEntries();
|
|
||||||
if (entries.isEmpty()) {
|
|
||||||
sender.sendMessage(getLang().getPrefixedString("maintenance.messages.whitelist-empty"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage(getLang().getPrefixedString("maintenance.messages.whitelist-list",
|
|
||||||
Map.of(
|
|
||||||
"count", String.valueOf(entries.size()),
|
|
||||||
"entries", String.join(", ", entries)
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendSaveFailed(CommandSender sender) {
|
|
||||||
sender.sendMessage(getLang().getPrefixedString("maintenance.messages.save-failed"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
if (!sender.hasPermission(getPermission())) {
|
|
||||||
return List.of();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 1) {
|
|
||||||
return complete(args[0], List.of("on", "off", "status", "reload", "add", "remove", "list"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 2 && args[0].equalsIgnoreCase("add")) {
|
|
||||||
return complete(args[1], plugin.getServer().getOnlinePlayers().stream()
|
|
||||||
.map(Player::getName)
|
|
||||||
.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 2 && args[0].equalsIgnoreCase("remove")) {
|
|
||||||
MaintenanceManager maintenanceManager = plugin.getMaintenanceManager();
|
|
||||||
if (maintenanceManager == null) {
|
|
||||||
return List.of();
|
|
||||||
}
|
|
||||||
return complete(args[1], maintenanceManager.getWhitelistEntries());
|
|
||||||
}
|
|
||||||
|
|
||||||
return List.of();
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<String> complete(String input, List<String> options) {
|
|
||||||
String partial = input.toLowerCase(Locale.ROOT);
|
|
||||||
List<String> completions = new ArrayList<>();
|
|
||||||
for (String option : options) {
|
|
||||||
if (option.toLowerCase(Locale.ROOT).startsWith(partial)) {
|
|
||||||
completions.add(option);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return completions;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-56
@@ -1,56 +0,0 @@
|
|||||||
package cn.infstar.essentialsC.maintenance;
|
|
||||||
|
|
||||||
import cn.infstar.essentialsC.EssentialsC;
|
|
||||||
import net.luckperms.api.LuckPerms;
|
|
||||||
import net.luckperms.api.model.user.User;
|
|
||||||
import net.luckperms.api.model.user.UserManager;
|
|
||||||
import net.luckperms.api.query.QueryOptions;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
|
|
||||||
public final class LuckPermsMaintenancePermissionResolver implements MaintenancePermissionResolver {
|
|
||||||
|
|
||||||
private final EssentialsC plugin;
|
|
||||||
private final LuckPerms luckPerms;
|
|
||||||
private final UserManager userManager;
|
|
||||||
private final AtomicBoolean failureLogged = new AtomicBoolean();
|
|
||||||
|
|
||||||
public LuckPermsMaintenancePermissionResolver(EssentialsC plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.luckPerms = plugin.getServer().getServicesManager().load(LuckPerms.class);
|
|
||||||
if (luckPerms == null) {
|
|
||||||
throw new IllegalStateException("LuckPerms 服务尚未注册");
|
|
||||||
}
|
|
||||||
this.userManager = luckPerms.getUserManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PermissionResult checkPermission(UUID uniqueId, String permission) {
|
|
||||||
if (uniqueId == null || permission == null || permission.isBlank()) {
|
|
||||||
return PermissionResult.DENIED;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
User user = userManager.getUser(uniqueId);
|
|
||||||
if (user == null) {
|
|
||||||
user = userManager.loadUser(uniqueId).join();
|
|
||||||
}
|
|
||||||
|
|
||||||
QueryOptions queryOptions = luckPerms.getContextManager().getQueryOptions(user)
|
|
||||||
.orElseGet(() -> luckPerms.getContextManager().getStaticQueryOptions());
|
|
||||||
boolean granted = user.getCachedData()
|
|
||||||
.getPermissionData(queryOptions)
|
|
||||||
.checkPermission(permission)
|
|
||||||
.asBoolean();
|
|
||||||
failureLogged.set(false);
|
|
||||||
return granted ? PermissionResult.GRANTED : PermissionResult.DENIED;
|
|
||||||
} catch (RuntimeException exception) {
|
|
||||||
if (failureLogged.compareAndSet(false, true)) {
|
|
||||||
plugin.getLogger().warning("LuckPerms 维护权限查询失败,将在玩家加入后复核权限: "
|
|
||||||
+ exception.getMessage());
|
|
||||||
}
|
|
||||||
return PermissionResult.UNAVAILABLE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
package cn.infstar.essentialsC.maintenance;
|
|
||||||
|
|
||||||
import cn.infstar.essentialsC.EssentialsC;
|
|
||||||
import cn.infstar.essentialsC.ModuleManager;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
import org.bukkit.event.server.ServerListPingEvent;
|
|
||||||
|
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public final class MaintenanceListener implements Listener {
|
|
||||||
|
|
||||||
private final EssentialsC plugin;
|
|
||||||
private final MaintenanceManager maintenanceManager;
|
|
||||||
private final MaintenancePermissionResolver permissionResolver;
|
|
||||||
|
|
||||||
public MaintenanceListener(EssentialsC plugin, MaintenanceManager maintenanceManager) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.maintenanceManager = maintenanceManager;
|
|
||||||
this.permissionResolver = MaintenancePermissionResolverFactory.create(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onServerListPing(ServerListPingEvent event) {
|
|
||||||
if (!plugin.getModuleManager().isEnabled(ModuleManager.MAINTENANCE)
|
|
||||||
|| !maintenanceManager.isEnabled()
|
|
||||||
|| !maintenanceManager.isMotdEnabled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
event.motd(maintenanceManager.getMotd());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
|
||||||
public void onPlayerPreLogin(AsyncPlayerPreLoginEvent event) {
|
|
||||||
if (event.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
MaintenanceManager.AccessSnapshot snapshot = maintenanceManager.getAccessSnapshot();
|
|
||||||
if (!snapshot.enabled()
|
|
||||||
|| snapshot.isWhitelisted(event.getUniqueId(), event.getName())
|
|
||||||
|| maintenanceManager.isOperator(event.getUniqueId())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (permissionResolver == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
MaintenancePermissionResolver.PermissionResult permissionResult = permissionResolver
|
|
||||||
.checkPermission(event.getUniqueId(), snapshot.bypassPermission());
|
|
||||||
if (permissionResult != MaintenancePermissionResolver.PermissionResult.DENIED) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, snapshot.kickMessage());
|
|
||||||
notifyBlockedLogin(event.getName(), event.getUniqueId().toString(), event.getAddress(), snapshot);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
|
||||||
if (!plugin.getModuleManager().isEnabled(ModuleManager.MAINTENANCE)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
if (maintenanceManager.isEnabled() && !maintenanceManager.canJoin(player)) {
|
|
||||||
MaintenanceManager.AccessSnapshot snapshot = maintenanceManager.getAccessSnapshot();
|
|
||||||
player.kick(snapshot.kickMessage());
|
|
||||||
InetSocketAddress socketAddress = player.getAddress();
|
|
||||||
notifyBlockedLogin(player.getName(), player.getUniqueId().toString(),
|
|
||||||
socketAddress == null ? null : socketAddress.getAddress(), snapshot);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
maintenanceManager.addBossBarPlayer(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
|
||||||
maintenanceManager.removeBossBarPlayer(event.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void notifyBlockedLogin(String playerName, String uniqueId, InetAddress inetAddress,
|
|
||||||
MaintenanceManager.AccessSnapshot snapshot) {
|
|
||||||
if (!snapshot.notifyEnabled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String visibleAddress = snapshot.includeAddress() && inetAddress != null ? inetAddress.getHostAddress() : null;
|
|
||||||
plugin.getServer().getScheduler().runTask(plugin, () -> {
|
|
||||||
String address = visibleAddress == null
|
|
||||||
? EssentialsC.getLangManager().getString("maintenance.status.address-hidden")
|
|
||||||
: visibleAddress;
|
|
||||||
var message = EssentialsC.getLangManager().getPrefixedComponent("maintenance.messages.login-blocked",
|
|
||||||
Map.of("player", playerName, "uuid", uniqueId, "address", address));
|
|
||||||
|
|
||||||
for (Player onlinePlayer : plugin.getServer().getOnlinePlayers()) {
|
|
||||||
if (onlinePlayer.hasPermission(snapshot.notifyPermission())) {
|
|
||||||
onlinePlayer.sendMessage(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,461 +0,0 @@
|
|||||||
package cn.infstar.essentialsC.maintenance;
|
|
||||||
|
|
||||||
import cn.infstar.essentialsC.EssentialsC;
|
|
||||||
import cn.infstar.essentialsC.util.AtomicYamlWriter;
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.boss.BarColor;
|
|
||||||
import org.bukkit.boss.BarStyle;
|
|
||||||
import org.bukkit.boss.BossBar;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public final class MaintenanceManager {
|
|
||||||
|
|
||||||
private static final int CURRENT_CONFIG_VERSION = 1;
|
|
||||||
private static final LegacyComponentSerializer LEGACY_AMPERSAND = LegacyComponentSerializer.legacyAmpersand();
|
|
||||||
private static final LegacyComponentSerializer LEGACY_SECTION = LegacyComponentSerializer.legacySection();
|
|
||||||
|
|
||||||
private final EssentialsC plugin;
|
|
||||||
private final File configFile;
|
|
||||||
private final BukkitTask operatorCacheTask;
|
|
||||||
private FileConfiguration config;
|
|
||||||
private BossBar bossBar;
|
|
||||||
private volatile AccessSnapshot accessSnapshot = AccessSnapshot.disabled();
|
|
||||||
private volatile Set<UUID> operatorUuids = Set.of();
|
|
||||||
|
|
||||||
public MaintenanceManager(EssentialsC plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.configFile = new File(plugin.getDataFolder(), "maintenance.yml");
|
|
||||||
refreshOperatorCache();
|
|
||||||
this.operatorCacheTask = plugin.getServer().getScheduler()
|
|
||||||
.runTaskTimer(plugin, this::refreshOperatorCache, 20L, 20L);
|
|
||||||
reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reload() {
|
|
||||||
if (!configFile.exists()) {
|
|
||||||
plugin.saveResource("maintenance.yml", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
config = loadConfiguration();
|
|
||||||
config.addDefault("config-version", CURRENT_CONFIG_VERSION);
|
|
||||||
config.addDefault("enabled", false);
|
|
||||||
config.addDefault("bypass-permission", "essentialsc.maintenance.bypass");
|
|
||||||
config.addDefault("notify.enabled", true);
|
|
||||||
config.addDefault("notify.permission", "essentialsc.maintenance.notify");
|
|
||||||
config.addDefault("notify.include-address", false);
|
|
||||||
config.addDefault("whitelist.uuids", List.of());
|
|
||||||
config.addDefault("whitelist.names", List.of());
|
|
||||||
config.addDefault("motd.enabled", true);
|
|
||||||
config.addDefault("motd.lines", List.of("&c服务器维护中", "&7请稍后再试"));
|
|
||||||
config.addDefault("kick-message", List.of("&c服务器正在维护", "&7请稍后再进入"));
|
|
||||||
config.addDefault("bossbar.enabled", true);
|
|
||||||
config.addDefault("bossbar.title", "&c服务器正在维护");
|
|
||||||
config.addDefault("bossbar.color", "RED");
|
|
||||||
config.addDefault("bossbar.style", "SOLID");
|
|
||||||
config.addDefault("bossbar.progress", 1.0D);
|
|
||||||
config.options().copyDefaults(true);
|
|
||||||
publishAccessSnapshot();
|
|
||||||
refreshBossBar();
|
|
||||||
if (isEnabled()) {
|
|
||||||
kickUnauthorizedPlayers();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEnabled() {
|
|
||||||
return config.getBoolean("enabled", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public OperationResult setEnabled(boolean enabled) {
|
|
||||||
if (isEnabled() == enabled) {
|
|
||||||
return OperationResult.UNCHANGED;
|
|
||||||
}
|
|
||||||
boolean previous = isEnabled();
|
|
||||||
config.set("enabled", enabled);
|
|
||||||
if (!save()) {
|
|
||||||
config.set("enabled", previous);
|
|
||||||
return OperationResult.SAVE_FAILED;
|
|
||||||
}
|
|
||||||
publishAccessSnapshot();
|
|
||||||
refreshBossBar();
|
|
||||||
if (enabled) {
|
|
||||||
kickUnauthorizedPlayers();
|
|
||||||
}
|
|
||||||
return OperationResult.SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBypassPermission() {
|
|
||||||
return config.getString("bypass-permission", "essentialsc.maintenance.bypass");
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isNotifyEnabled() {
|
|
||||||
return config.getBoolean("notify.enabled", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNotifyPermission() {
|
|
||||||
return config.getString("notify.permission", "essentialsc.maintenance.notify");
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean shouldIncludeAddressInNotification() {
|
|
||||||
return config.getBoolean("notify.include-address", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canJoin(Player player) {
|
|
||||||
return player != null && (player.isOp() || player.hasPermission(getBypassPermission()) || isWhitelisted(player));
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOperator(UUID uniqueId) {
|
|
||||||
return uniqueId != null && operatorUuids.contains(uniqueId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AccessSnapshot getAccessSnapshot() {
|
|
||||||
return accessSnapshot;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isWhitelisted(Player player) {
|
|
||||||
if (player == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return getWhitelistUuids().contains(player.getUniqueId().toString().toLowerCase(Locale.ROOT))
|
|
||||||
|| getWhitelistNames().contains(normalizeName(player.getName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public OperationResult addWhitelistEntry(String input) {
|
|
||||||
String normalized = normalizeEntry(input);
|
|
||||||
if (normalized.isEmpty()) {
|
|
||||||
return OperationResult.UNCHANGED;
|
|
||||||
}
|
|
||||||
|
|
||||||
UUID uuid = parseUuid(normalized);
|
|
||||||
if (uuid != null) {
|
|
||||||
return addWhitelistUuid(uuid.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
Player onlinePlayer = Bukkit.getPlayerExact(normalized);
|
|
||||||
if (onlinePlayer != null) {
|
|
||||||
return addWhitelistUuid(onlinePlayer.getUniqueId().toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return addWhitelistName(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
public OperationResult removeWhitelistEntry(String input) {
|
|
||||||
String normalized = normalizeEntry(input);
|
|
||||||
if (normalized.isEmpty()) {
|
|
||||||
return OperationResult.UNCHANGED;
|
|
||||||
}
|
|
||||||
|
|
||||||
UUID uuid = parseUuid(normalized);
|
|
||||||
if (uuid != null) {
|
|
||||||
return removeWhitelistUuid(uuid.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
Player onlinePlayer = Bukkit.getPlayerExact(normalized);
|
|
||||||
if (onlinePlayer != null) {
|
|
||||||
OperationResult uuidResult = removeWhitelistUuid(onlinePlayer.getUniqueId().toString());
|
|
||||||
if (uuidResult != OperationResult.UNCHANGED) {
|
|
||||||
return uuidResult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return removeWhitelistName(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getWhitelistEntries() {
|
|
||||||
List<String> entries = new ArrayList<>();
|
|
||||||
entries.addAll(getWhitelistNames());
|
|
||||||
entries.addAll(getWhitelistUuids());
|
|
||||||
return entries;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWhitelistCount() {
|
|
||||||
return getWhitelistEntries().size();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMotdEnabled() {
|
|
||||||
return config.getBoolean("motd.enabled", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Component getMotd() {
|
|
||||||
return colorizeLines(config.getStringList("motd.lines"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Component getKickMessage() {
|
|
||||||
return colorizeLines(config.getStringList("kick-message"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void refreshBossBar() {
|
|
||||||
clearBossBar();
|
|
||||||
if (!isEnabled() || !isBossBarEnabled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bossBar = plugin.getServer().createBossBar(
|
|
||||||
LEGACY_SECTION.serialize(colorize(config.getString("bossbar.title", "&c服务器正在维护"))),
|
|
||||||
readBossBarColor(),
|
|
||||||
readBossBarStyle()
|
|
||||||
);
|
|
||||||
bossBar.setProgress(readBossBarProgress());
|
|
||||||
bossBar.setVisible(true);
|
|
||||||
|
|
||||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
|
||||||
addBossBarPlayer(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addBossBarPlayer(Player player) {
|
|
||||||
if (bossBar == null || player == null || !player.isOnline()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
bossBar.addPlayer(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeBossBarPlayer(Player player) {
|
|
||||||
if (bossBar != null && player != null) {
|
|
||||||
bossBar.removePlayer(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void kickUnauthorizedPlayers() {
|
|
||||||
Component message = getKickMessage();
|
|
||||||
for (Player player : List.copyOf(plugin.getServer().getOnlinePlayers())) {
|
|
||||||
if (!canJoin(player)) {
|
|
||||||
player.kick(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void shutdown() {
|
|
||||||
operatorCacheTask.cancel();
|
|
||||||
accessSnapshot = AccessSnapshot.disabled();
|
|
||||||
operatorUuids = Set.of();
|
|
||||||
clearBossBar();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void refreshOperatorCache() {
|
|
||||||
Set<UUID> operators = new LinkedHashSet<>();
|
|
||||||
for (org.bukkit.OfflinePlayer operator : plugin.getServer().getOperators()) {
|
|
||||||
operators.add(operator.getUniqueId());
|
|
||||||
}
|
|
||||||
operatorUuids = Set.copyOf(operators);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void clearBossBar() {
|
|
||||||
if (bossBar == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bossBar.removeAll();
|
|
||||||
bossBar = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isBossBarEnabled() {
|
|
||||||
return config.getBoolean("bossbar.enabled", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private BarColor readBossBarColor() {
|
|
||||||
try {
|
|
||||||
return BarColor.valueOf(config.getString("bossbar.color", "RED").toUpperCase(Locale.ROOT));
|
|
||||||
} catch (IllegalArgumentException ignored) {
|
|
||||||
return BarColor.RED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private BarStyle readBossBarStyle() {
|
|
||||||
try {
|
|
||||||
return BarStyle.valueOf(config.getString("bossbar.style", "SOLID").toUpperCase(Locale.ROOT));
|
|
||||||
} catch (IllegalArgumentException ignored) {
|
|
||||||
return BarStyle.SOLID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private double readBossBarProgress() {
|
|
||||||
double progress = config.getDouble("bossbar.progress", 1.0D);
|
|
||||||
if (!Double.isFinite(progress)) {
|
|
||||||
return 1.0D;
|
|
||||||
}
|
|
||||||
return Math.max(0.0D, Math.min(1.0D, progress));
|
|
||||||
}
|
|
||||||
|
|
||||||
private OperationResult addWhitelistUuid(String uuid) {
|
|
||||||
return updateWhitelist("whitelist.uuids", uuid.toLowerCase(Locale.ROOT), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private OperationResult addWhitelistName(String name) {
|
|
||||||
return updateWhitelist("whitelist.names", normalizeName(name), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private OperationResult removeWhitelistUuid(String uuid) {
|
|
||||||
return updateWhitelist("whitelist.uuids", uuid.toLowerCase(Locale.ROOT), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private OperationResult removeWhitelistName(String name) {
|
|
||||||
return updateWhitelist("whitelist.names", normalizeName(name), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private OperationResult updateWhitelist(String path, String value, boolean add) {
|
|
||||||
if (value == null || value.isBlank()) {
|
|
||||||
return OperationResult.UNCHANGED;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> previousEntries = new ArrayList<>(config.getStringList(path));
|
|
||||||
Set<String> entries = path.endsWith(".names") ? getWhitelistNames() : getWhitelistUuids();
|
|
||||||
boolean changed;
|
|
||||||
if (add) {
|
|
||||||
changed = entries.add(value);
|
|
||||||
} else {
|
|
||||||
changed = entries.remove(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!changed) {
|
|
||||||
return OperationResult.UNCHANGED;
|
|
||||||
}
|
|
||||||
|
|
||||||
config.set(path, new ArrayList<>(entries));
|
|
||||||
if (!save()) {
|
|
||||||
config.set(path, previousEntries);
|
|
||||||
return OperationResult.SAVE_FAILED;
|
|
||||||
}
|
|
||||||
publishAccessSnapshot();
|
|
||||||
refreshBossBar();
|
|
||||||
if (isEnabled()) {
|
|
||||||
kickUnauthorizedPlayers();
|
|
||||||
}
|
|
||||||
return OperationResult.SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Set<String> getWhitelistUuids() {
|
|
||||||
Set<String> entries = new LinkedHashSet<>();
|
|
||||||
for (String value : config.getStringList("whitelist.uuids")) {
|
|
||||||
String normalized = normalizeEntry(value).toLowerCase(Locale.ROOT);
|
|
||||||
if (!normalized.isEmpty()) {
|
|
||||||
entries.add(normalized);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return entries;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Set<String> getWhitelistNames() {
|
|
||||||
Set<String> entries = new LinkedHashSet<>();
|
|
||||||
for (String value : config.getStringList("whitelist.names")) {
|
|
||||||
String normalized = normalizeName(value);
|
|
||||||
if (!normalized.isEmpty()) {
|
|
||||||
entries.add(normalized);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return entries;
|
|
||||||
}
|
|
||||||
|
|
||||||
private UUID parseUuid(String input) {
|
|
||||||
try {
|
|
||||||
return UUID.fromString(input);
|
|
||||||
} catch (IllegalArgumentException ignored) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String normalizeEntry(String input) {
|
|
||||||
return input == null ? "" : input.trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String normalizeName(String input) {
|
|
||||||
return normalizeEntry(input).toLowerCase(Locale.ROOT);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Component colorizeLines(List<String> lines) {
|
|
||||||
if (lines == null || lines.isEmpty()) {
|
|
||||||
return Component.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
return colorize(String.join("\n", lines));
|
|
||||||
}
|
|
||||||
|
|
||||||
private Component colorize(String text) {
|
|
||||||
return LEGACY_AMPERSAND.deserialize(text == null ? "" : text);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void publishAccessSnapshot() {
|
|
||||||
Set<UUID> whitelistUuids = new LinkedHashSet<>();
|
|
||||||
for (String value : getWhitelistUuids()) {
|
|
||||||
UUID uuid = parseUuid(value);
|
|
||||||
if (uuid != null) {
|
|
||||||
whitelistUuids.add(uuid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
accessSnapshot = new AccessSnapshot(
|
|
||||||
isEnabled(),
|
|
||||||
getBypassPermission(),
|
|
||||||
whitelistUuids,
|
|
||||||
getWhitelistNames(),
|
|
||||||
getKickMessage(),
|
|
||||||
isNotifyEnabled(),
|
|
||||||
getNotifyPermission(),
|
|
||||||
shouldIncludeAddressInNotification()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean save() {
|
|
||||||
try {
|
|
||||||
AtomicYamlWriter.save(config, configFile);
|
|
||||||
return true;
|
|
||||||
} catch (Exception e) {
|
|
||||||
plugin.getLogger().warning("保存 maintenance.yml 失败: " + e.getMessage());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private YamlConfiguration loadConfiguration() {
|
|
||||||
YamlConfiguration loaded = new YamlConfiguration();
|
|
||||||
loaded.options().parseComments(true);
|
|
||||||
try {
|
|
||||||
loaded.load(configFile);
|
|
||||||
} catch (IOException | InvalidConfigurationException exception) {
|
|
||||||
plugin.getLogger().severe("加载 maintenance.yml 失败: " + exception.getMessage());
|
|
||||||
throw new IllegalStateException("无法加载 maintenance.yml,请修复配置格式后重试。", exception);
|
|
||||||
}
|
|
||||||
return loaded;
|
|
||||||
}
|
|
||||||
|
|
||||||
public record AccessSnapshot(boolean enabled, String bypassPermission, Set<UUID> whitelistUuids,
|
|
||||||
Set<String> whitelistNames, Component kickMessage, boolean notifyEnabled,
|
|
||||||
String notifyPermission, boolean includeAddress) {
|
|
||||||
|
|
||||||
public AccessSnapshot {
|
|
||||||
bypassPermission = bypassPermission == null ? "" : bypassPermission;
|
|
||||||
whitelistUuids = Set.copyOf(whitelistUuids);
|
|
||||||
whitelistNames = Set.copyOf(whitelistNames);
|
|
||||||
kickMessage = kickMessage == null ? Component.empty() : kickMessage;
|
|
||||||
notifyPermission = notifyPermission == null ? "" : notifyPermission;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isWhitelisted(UUID uniqueId, String playerName) {
|
|
||||||
return whitelistUuids.contains(uniqueId)
|
|
||||||
|| whitelistNames.contains(playerName == null ? "" : playerName.trim().toLowerCase(Locale.ROOT));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static AccessSnapshot disabled() {
|
|
||||||
return new AccessSnapshot(false, "", Set.of(), Set.of(), Component.empty(), false, "", false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum OperationResult {
|
|
||||||
SUCCESS,
|
|
||||||
UNCHANGED,
|
|
||||||
SAVE_FAILED
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
package cn.infstar.essentialsC.maintenance;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public interface MaintenancePermissionResolver {
|
|
||||||
|
|
||||||
PermissionResult checkPermission(UUID uniqueId, String permission);
|
|
||||||
|
|
||||||
enum PermissionResult {
|
|
||||||
GRANTED,
|
|
||||||
DENIED,
|
|
||||||
UNAVAILABLE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-35
@@ -1,35 +0,0 @@
|
|||||||
package cn.infstar.essentialsC.maintenance;
|
|
||||||
|
|
||||||
import cn.infstar.essentialsC.EssentialsC;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
|
|
||||||
final class MaintenancePermissionResolverFactory {
|
|
||||||
|
|
||||||
private static final String LUCKPERMS_RESOLVER_CLASS =
|
|
||||||
"cn.infstar.essentialsC.maintenance.LuckPermsMaintenancePermissionResolver";
|
|
||||||
|
|
||||||
private MaintenancePermissionResolverFactory() {
|
|
||||||
}
|
|
||||||
|
|
||||||
static MaintenancePermissionResolver create(EssentialsC plugin) {
|
|
||||||
Plugin luckPerms = plugin.getServer().getPluginManager().getPlugin("LuckPerms");
|
|
||||||
if (luckPerms == null || !luckPerms.isEnabled()) {
|
|
||||||
plugin.getLogger().info("未检测到 LuckPerms,维护模式将在玩家加入后复核绕过权限。");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Class<?> resolverClass = Class.forName(LUCKPERMS_RESOLVER_CLASS, true, plugin.getClass().getClassLoader());
|
|
||||||
return (MaintenancePermissionResolver) resolverClass
|
|
||||||
.getConstructor(EssentialsC.class)
|
|
||||||
.newInstance(plugin);
|
|
||||||
} catch (ClassNotFoundException | NoSuchMethodException | InstantiationException
|
|
||||||
| IllegalAccessException | InvocationTargetException | LinkageError exception) {
|
|
||||||
plugin.getLogger().warning("LuckPerms 维护权限解析器初始化失败,将在玩家加入后复核权限: "
|
|
||||||
+ exception.getMessage());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# EssentialsC 主配置
|
# EssentialsC 主配置
|
||||||
# 其他配置:modules.yml、maintenance.yml、blocks-menu.yml
|
# 其他配置:modules.yml、blocks-menu.yml
|
||||||
# 消息与颜色:lang/<语言>.yml
|
# 消息与颜色:lang/<语言>.yml
|
||||||
# 修改后使用 /essc reload 重载;命令注册状态发生变化时建议重启服务器。
|
# 修改后使用 /essc reload 重载;命令注册状态发生变化时建议重启服务器。
|
||||||
|
|
||||||
|
|||||||
@@ -107,7 +107,6 @@ help:
|
|||||||
skin: '<white>/essc skin [status|refresh] [player]</white> <gray>- View or refresh SkinBridge status</gray>'
|
skin: '<white>/essc skin [status|refresh] [player]</white> <gray>- View or refresh SkinBridge status</gray>'
|
||||||
admin: '<white>/essc admin</white> <gray>- Toggle admin mode</gray>'
|
admin: '<white>/essc admin</white> <gray>- Toggle admin mode</gray>'
|
||||||
tpsbar: '<white>/tpsbar [player]</white> <gray>- Toggle TPS boss bar</gray>'
|
tpsbar: '<white>/tpsbar [player]</white> <gray>- Toggle TPS boss bar</gray>'
|
||||||
maintenance: '<white>/maintenance [on|off|status|reload|add|remove|list]</white> <gray>- Manage maintenance mode</gray>'
|
|
||||||
|
|
||||||
tpa:
|
tpa:
|
||||||
messages:
|
messages:
|
||||||
@@ -259,25 +258,3 @@ mobdrops-menu:
|
|||||||
name: '<#00FB9A>Enderman Drops</#00FB9A>'
|
name: '<#00FB9A>Enderman Drops</#00FB9A>'
|
||||||
status: '<gray>Current status: {status}</gray>'
|
status: '<gray>Current status: {status}</gray>'
|
||||||
toggle: '<gray>Click to toggle</gray>'
|
toggle: '<gray>Click to toggle</gray>'
|
||||||
|
|
||||||
maintenance:
|
|
||||||
status:
|
|
||||||
enabled: '<#FF7E5E>Enabled</#FF7E5E>'
|
|
||||||
disabled: '<#00FB9A>Disabled</#00FB9A>'
|
|
||||||
address-hidden: 'hidden'
|
|
||||||
messages:
|
|
||||||
enabled: '<#00FB9A>Maintenance mode enabled.</#00FB9A>'
|
|
||||||
disabled: '<#FF7E5E>Maintenance mode disabled.</#FF7E5E>'
|
|
||||||
reloaded: '<#00FB9A>Maintenance configuration reloaded.</#00FB9A>'
|
|
||||||
save-failed: '<#FF3300>Error:</#FF3300> <#FF7E5E>Failed to save maintenance configuration; no changes were applied.</#FF7E5E>'
|
|
||||||
status: '<gray>Maintenance mode status: {status} | Whitelist: <white>{whitelist_count}</white></gray>'
|
|
||||||
usage: '<#FF3300>Error:</#FF3300> <#FF7E5E>Usage: /maintenance [on|off|status|reload|add|remove|list]</#FF7E5E>'
|
|
||||||
add-usage: '<#FF3300>Error:</#FF3300> <#FF7E5E>Usage: /maintenance add [player|uuid]</#FF7E5E>'
|
|
||||||
remove-usage: '<#FF3300>Error:</#FF3300> <#FF7E5E>Usage: /maintenance remove [player|uuid]</#FF7E5E>'
|
|
||||||
whitelist-added: '<#00FB9A>Added {player} to the maintenance whitelist.</#00FB9A>'
|
|
||||||
whitelist-removed: '<#00FB9A>Removed {player} from the maintenance whitelist.</#00FB9A>'
|
|
||||||
whitelist-exists: '<#FFC43B>{player} is already on the maintenance whitelist.</#FFC43B>'
|
|
||||||
whitelist-missing: '<#FF3300>Error:</#FF3300> <#FF7E5E>{player} is not on the maintenance whitelist.</#FF7E5E>'
|
|
||||||
whitelist-empty: '<gray>The maintenance whitelist is empty.</gray>'
|
|
||||||
whitelist-list: '<gray>Maintenance whitelist ({count}): <white>{entries}</white></gray>'
|
|
||||||
login-blocked: '<#FFC43B>{player} was blocked by maintenance mode.</#FFC43B> <gray>UUID: {uuid} | IP: {address}</gray>'
|
|
||||||
|
|||||||
@@ -107,7 +107,6 @@ help:
|
|||||||
skin: '<white>/essc skin [status|refresh] [玩家]</white> <gray>- 查看或刷新皮肤桥接状态</gray>'
|
skin: '<white>/essc skin [status|refresh] [玩家]</white> <gray>- 查看或刷新皮肤桥接状态</gray>'
|
||||||
admin: '<white>/essc admin</white> <gray>- 切换管理模式</gray>'
|
admin: '<white>/essc admin</white> <gray>- 切换管理模式</gray>'
|
||||||
tpsbar: '<white>/tpsbar [玩家]</white> <gray>- 切换 TPS 状态栏</gray>'
|
tpsbar: '<white>/tpsbar [玩家]</white> <gray>- 切换 TPS 状态栏</gray>'
|
||||||
maintenance: '<white>/maintenance [on|off|status|reload|add|remove|list]</white> <gray>- 管理维护模式</gray>'
|
|
||||||
|
|
||||||
tpa:
|
tpa:
|
||||||
messages:
|
messages:
|
||||||
@@ -259,25 +258,3 @@ mobdrops-menu:
|
|||||||
name: '<#00FB9A>末影人掉落</#00FB9A>'
|
name: '<#00FB9A>末影人掉落</#00FB9A>'
|
||||||
status: '<gray>当前状态: {status}</gray>'
|
status: '<gray>当前状态: {status}</gray>'
|
||||||
toggle: '<gray>点击切换</gray>'
|
toggle: '<gray>点击切换</gray>'
|
||||||
|
|
||||||
maintenance:
|
|
||||||
status:
|
|
||||||
enabled: '<#FF7E5E>开启</#FF7E5E>'
|
|
||||||
disabled: '<#00FB9A>关闭</#00FB9A>'
|
|
||||||
address-hidden: '已隐藏'
|
|
||||||
messages:
|
|
||||||
enabled: '<#00FB9A>维护模式已开启.</#00FB9A>'
|
|
||||||
disabled: '<#FF7E5E>维护模式已关闭.</#FF7E5E>'
|
|
||||||
reloaded: '<#00FB9A>维护模式配置已重载.</#00FB9A>'
|
|
||||||
save-failed: '<#FF3300>错误:</#FF3300> <#FF7E5E>维护模式配置保存失败,操作未生效.</#FF7E5E>'
|
|
||||||
status: '<gray>维护模式当前状态: {status} | 白名单: <white>{whitelist_count}</white></gray>'
|
|
||||||
usage: '<#FF3300>错误:</#FF3300> <#FF7E5E>用法: /maintenance [on|off|status|reload|add|remove|list]</#FF7E5E>'
|
|
||||||
add-usage: '<#FF3300>错误:</#FF3300> <#FF7E5E>用法: /maintenance add [玩家|UUID]</#FF7E5E>'
|
|
||||||
remove-usage: '<#FF3300>错误:</#FF3300> <#FF7E5E>用法: /maintenance remove [玩家|UUID]</#FF7E5E>'
|
|
||||||
whitelist-added: '<#00FB9A>已将 {player} 加入维护白名单.</#00FB9A>'
|
|
||||||
whitelist-removed: '<#00FB9A>已将 {player} 移出维护白名单.</#00FB9A>'
|
|
||||||
whitelist-exists: '<#FFC43B>{player} 已在维护白名单中.</#FFC43B>'
|
|
||||||
whitelist-missing: '<#FF3300>错误:</#FF3300> <#FF7E5E>{player} 不在维护白名单中.</#FF7E5E>'
|
|
||||||
whitelist-empty: '<gray>维护白名单为空.</gray>'
|
|
||||||
whitelist-list: '<gray>维护白名单 ({count}): <white>{entries}</white></gray>'
|
|
||||||
login-blocked: '<#FFC43B>{player} 被维护模式拦截.</#FFC43B> <gray>UUID: {uuid} | IP: {address}</gray>'
|
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
# EssentialsC 维护模式配置
|
|
||||||
|
|
||||||
config-version: 1
|
|
||||||
|
|
||||||
# 是否开启维护模式。
|
|
||||||
enabled: false
|
|
||||||
|
|
||||||
# 拥有该权限的玩家可以在维护模式下进入服务器。
|
|
||||||
bypass-permission: "essentialsc.maintenance.bypass"
|
|
||||||
|
|
||||||
notify:
|
|
||||||
# 玩家因维护模式被拒绝进入时,是否通知在线管理员。
|
|
||||||
enabled: true
|
|
||||||
# 拥有该权限的在线玩家会收到拦截通知。
|
|
||||||
permission: "essentialsc.maintenance.notify"
|
|
||||||
# 是否在通知中显示玩家 IP 地址;出于隐私考虑默认关闭。
|
|
||||||
include-address: false
|
|
||||||
|
|
||||||
whitelist:
|
|
||||||
# 这些 UUID 可以在维护模式下进入服务器。
|
|
||||||
uuids: []
|
|
||||||
# 这些玩家名可以在维护模式下进入服务器。大小写不敏感。
|
|
||||||
names: []
|
|
||||||
|
|
||||||
motd:
|
|
||||||
# 维护模式开启时是否替换服务器列表 MOTD。
|
|
||||||
enabled: true
|
|
||||||
lines:
|
|
||||||
- "&c服务器维护中"
|
|
||||||
- "&7请稍后再试"
|
|
||||||
|
|
||||||
kick-message:
|
|
||||||
- "&c服务器正在维护"
|
|
||||||
- "&7请稍后再进入"
|
|
||||||
|
|
||||||
bossbar:
|
|
||||||
# 维护模式开启时是否向所有在线玩家显示 BossBar。
|
|
||||||
enabled: true
|
|
||||||
title: "&c服务器正在维护"
|
|
||||||
# 可选值:PINK / BLUE / RED / GREEN / YELLOW / PURPLE / WHITE
|
|
||||||
color: RED
|
|
||||||
# 可选值:SOLID / SEGMENTED_6 / SEGMENTED_10 / SEGMENTED_12 / SEGMENTED_20
|
|
||||||
style: SOLID
|
|
||||||
# 进度范围:0.0 - 1.0
|
|
||||||
progress: 1.0
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
# EssentialsC 模块配置
|
# EssentialsC 模块配置
|
||||||
#
|
#
|
||||||
# modules.yml 用于控制功能模块是否在运行时加载。
|
# modules.yml 用于控制功能模块是否在运行时加载。
|
||||||
# 各功能的详细设置位于 config.yml、maintenance.yml 与 blocks-menu.yml。
|
# 各功能的详细设置位于 config.yml 与 blocks-menu.yml。
|
||||||
#
|
#
|
||||||
# 修改模块开关后可使用 /essc reload 刷新运行期服务和监听器。
|
# 修改模块开关后可使用 /essc reload 刷新运行期服务和监听器。
|
||||||
# 直连命令的完整热增删仍建议通过重启服务器完成。
|
# 直连命令的完整热增删仍建议通过重启服务器完成。
|
||||||
@@ -21,9 +21,6 @@ modules:
|
|||||||
mob-drops:
|
mob-drops:
|
||||||
# 末影人掉落控制菜单和监听器;具体掉落状态可在游戏内切换。
|
# 末影人掉落控制菜单和监听器;具体掉落状态可在游戏内切换。
|
||||||
enabled: false
|
enabled: false
|
||||||
maintenance:
|
|
||||||
# 维护模式。开启维护后可替换 MOTD,并阻止无绕过权限的玩家进入。
|
|
||||||
enabled: true
|
|
||||||
skin-bridge:
|
skin-bridge:
|
||||||
# 查询外置 Yggdrasil profile,并通过 MineSkin 与 Paper Profile API 同步皮肤。
|
# 查询外置 Yggdrasil profile,并通过 MineSkin 与 Paper Profile API 同步皮肤。
|
||||||
enabled: false
|
enabled: false
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
name: EssentialsC
|
name: EssentialsC
|
||||||
description: 适用于 Paper 服务端的轻量基础功能插件。
|
description: 高版本基础工具箱
|
||||||
version: ${version}
|
version: ${version}
|
||||||
|
|
||||||
main: cn.infstar.essentialsC.EssentialsC
|
main: cn.infstar.essentialsC.EssentialsC
|
||||||
@@ -7,13 +7,6 @@ api-version: '1.21.11'
|
|||||||
load: POSTWORLD
|
load: POSTWORLD
|
||||||
folia-supported: false
|
folia-supported: false
|
||||||
|
|
||||||
dependencies:
|
|
||||||
server:
|
|
||||||
LuckPerms:
|
|
||||||
load: BEFORE
|
|
||||||
required: false
|
|
||||||
join-classpath: true
|
|
||||||
|
|
||||||
authors: [ Coldsmiles_7 ]
|
authors: [ Coldsmiles_7 ]
|
||||||
website: www.infstar.cn
|
website: www.infstar.cn
|
||||||
|
|
||||||
@@ -126,9 +119,6 @@ permissions:
|
|||||||
essentialsc.command.tpsbar.others:
|
essentialsc.command.tpsbar.others:
|
||||||
description: 允许为其他玩家切换 /tpsbar
|
description: 允许为其他玩家切换 /tpsbar
|
||||||
default: op
|
default: op
|
||||||
essentialsc.command.maintenance:
|
|
||||||
description: 允许管理维护模式
|
|
||||||
default: op
|
|
||||||
essentialsc.command.skin:
|
essentialsc.command.skin:
|
||||||
description: 允许使用 SkinBridge 管理命令
|
description: 允许使用 SkinBridge 管理命令
|
||||||
default: op
|
default: op
|
||||||
@@ -145,12 +135,6 @@ permissions:
|
|||||||
essentialsc.command.skin.others:
|
essentialsc.command.skin.others:
|
||||||
description: 允许查看或刷新其他玩家的皮肤
|
description: 允许查看或刷新其他玩家的皮肤
|
||||||
default: op
|
default: op
|
||||||
essentialsc.maintenance.bypass:
|
|
||||||
description: 允许在维护模式下进入服务器
|
|
||||||
default: op
|
|
||||||
essentialsc.maintenance.notify:
|
|
||||||
description: 允许接收维护模式拦截通知
|
|
||||||
default: op
|
|
||||||
essentialsc.shulkerbox.open:
|
essentialsc.shulkerbox.open:
|
||||||
description: 允许通过 Shift+右键快捷打开潜影盒
|
description: 允许通过 Shift+右键快捷打开潜影盒
|
||||||
default: op
|
default: op
|
||||||
@@ -197,12 +181,9 @@ permissions:
|
|||||||
essentialsc.command.reload: true
|
essentialsc.command.reload: true
|
||||||
essentialsc.command.tpsbar: true
|
essentialsc.command.tpsbar: true
|
||||||
essentialsc.command.tpsbar.others: true
|
essentialsc.command.tpsbar.others: true
|
||||||
essentialsc.command.maintenance: true
|
|
||||||
essentialsc.command.skin: true
|
essentialsc.command.skin: true
|
||||||
essentialsc.command.skin.status: true
|
essentialsc.command.skin.status: true
|
||||||
essentialsc.command.skin.refresh: true
|
essentialsc.command.skin.refresh: true
|
||||||
essentialsc.command.skin.others: true
|
essentialsc.command.skin.others: true
|
||||||
essentialsc.maintenance.bypass: true
|
|
||||||
essentialsc.maintenance.notify: true
|
|
||||||
essentialsc.shulkerbox.open: true
|
essentialsc.shulkerbox.open: true
|
||||||
essentialsc.mobdrops.enderman: true
|
essentialsc.mobdrops.enderman: true
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import java.nio.charset.StandardCharsets;
|
|||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
class ConfigurationResourcesTest {
|
class ConfigurationResourcesTest {
|
||||||
@@ -22,7 +23,6 @@ class ConfigurationResourcesTest {
|
|||||||
@ValueSource(strings = {
|
@ValueSource(strings = {
|
||||||
"config.yml",
|
"config.yml",
|
||||||
"modules.yml",
|
"modules.yml",
|
||||||
"maintenance.yml",
|
|
||||||
"blocks-menu.yml",
|
"blocks-menu.yml",
|
||||||
"paper-plugin.yml",
|
"paper-plugin.yml",
|
||||||
"lang/zh_CN.yml",
|
"lang/zh_CN.yml",
|
||||||
@@ -67,6 +67,20 @@ class ConfigurationResourcesTest {
|
|||||||
assertFalse(loadResource("lang/en_US.yml").contains("messages.jei-sync-neoforge", true));
|
assertFalse(loadResource("lang/en_US.yml").contains("messages.jei-sync-neoforge", true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void retiredMaintenanceFeatureIsAbsentFromResources() throws Exception {
|
||||||
|
assertNull(getClass().getClassLoader().getResource("maintenance.yml"));
|
||||||
|
assertFalse(loadResource("modules.yml").contains("modules.maintenance", true));
|
||||||
|
assertFalse(loadResource("paper-plugin.yml").contains("dependencies.server.LuckPerms", true));
|
||||||
|
assertFalse(loadResource("paper-plugin.yml").contains("permissions.essentialsc.command.maintenance", true));
|
||||||
|
assertFalse(loadResource("paper-plugin.yml").contains("permissions.essentialsc.maintenance.bypass", true));
|
||||||
|
assertFalse(loadResource("paper-plugin.yml").contains("permissions.essentialsc.maintenance.notify", true));
|
||||||
|
assertFalse(loadResource("lang/zh_CN.yml").contains("maintenance", true));
|
||||||
|
assertFalse(loadResource("lang/en_US.yml").contains("maintenance", true));
|
||||||
|
assertNull(cn.infstar.essentialsC.commands.CommandRegistry.resolveCommandName("maintenance"));
|
||||||
|
assertNull(cn.infstar.essentialsC.commands.CommandRegistry.resolveCommandName("maint"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void miniMessageTagNamesAreNormalized() {
|
void miniMessageTagNamesAreNormalized() {
|
||||||
assertEquals("<gray>文本</gray>", LangManager.normalizeMiniMessageTags("<GRAY>文本</GRAY>"));
|
assertEquals("<gray>文本</gray>", LangManager.normalizeMiniMessageTags("<GRAY>文本</GRAY>"));
|
||||||
|
|||||||
Reference in New Issue
Block a user