Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b57c7d4843 | |||
| 113ae24afe | |||
| c0289c55d3 | |||
| 0a45be832b | |||
| 376d63e906 |
19
.github/workflows/release.yml
vendored
19
.github/workflows/release.yml
vendored
@@ -11,25 +11,28 @@ permissions:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
|
||||
steps:
|
||||
- name: 检出代码
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: 设置 Java
|
||||
|
||||
- name: 设置 Java 21
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '21'
|
||||
distribution: 'temurin'
|
||||
cache: maven
|
||||
|
||||
cache: gradle
|
||||
|
||||
- name: 授予执行权限
|
||||
run: chmod +x gradlew
|
||||
|
||||
- name: 构建插件
|
||||
run: mvn clean package -B
|
||||
|
||||
run: ./gradlew build
|
||||
|
||||
- name: 创建发行版
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: target/essentialsc-*.jar
|
||||
files: build/libs/EssentialsC*.jar
|
||||
generate_release_notes: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
8
.gitignore
vendored
8
.gitignore
vendored
@@ -4,7 +4,7 @@
|
||||
# Log files
|
||||
*.log
|
||||
|
||||
# Package Files
|
||||
# Package files
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
@@ -50,14 +50,14 @@ bin/
|
||||
# VS Code
|
||||
.vscode/
|
||||
|
||||
# macOS
|
||||
# System files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Test server (不要上传测试服务器文件)
|
||||
# 测试服务器目录
|
||||
test-server/
|
||||
|
||||
# Reference files (不要上传参考资料)
|
||||
# 参考资料目录
|
||||
references/
|
||||
|
||||
# Plugin build output
|
||||
|
||||
290
README.md
290
README.md
@@ -1,168 +1,142 @@
|
||||
# EssentialsC
|
||||
|
||||
> 一个轻量级的 Paper 服务器插件,灵感来自 CMI,但更加精简、易用且现代化。
|
||||
轻量、现代、面向 Paper 服务端的基础功能插件,灵感来自 CMI,但更聚焦于常用能力与模块化构建。
|
||||
|
||||
[](https://github.com/Coldsmiles/EssentialsC/releases)
|
||||
[](LICENSE)
|
||||
[](https://papermc.io/)
|
||||
[](https://www.oracle.com/java/)
|
||||
[](https://papermc.io/)
|
||||
[](https://adoptium.net/)
|
||||
|
||||
## ✨ 核心特性
|
||||
## 项目定位
|
||||
|
||||
### 🎯 随身功能方块
|
||||
随时随地打开各种功能性方块,无需放置实体方块:
|
||||
- **工作台** (`/workbench`, `/wb`)
|
||||
- **铁砧** (`/anvil`)
|
||||
- **制图台** (`/cartographytable`, `/ct`)
|
||||
- **砂轮** (`/grindstone`, `/gs`)
|
||||
- **织布机** (`/loom`)
|
||||
- **锻造台** (`/smithingtable`, `/st`)
|
||||
- **切石机** (`/stonecutter`, `/sc`)
|
||||
- **末影箱** (`/enderchest`, `/ec`)
|
||||
- 最低支持版本为 `Paper 1.21.11`
|
||||
- 已适配 `Paper 26.1.2`
|
||||
- 构建环境固定为 `Java 21`
|
||||
- 配置、模块开关与文本分离:行为配置放在 `config.yml`,模块开关放在 `modules.yml`,提示文本放在 `lang/`
|
||||
- 支持运行期模块开关,避免为不同功能组合构建多个插件版本
|
||||
|
||||
### 📦 智能容器管理
|
||||
- **潜影盒快捷打开** - 潜行+右键直接打开(类似 CMI)
|
||||
- ✅ 支持自定义标题(可配置)
|
||||
- ✅ 防刷物品机制(快照验证 + 数量检查)
|
||||
- ✅ 防止套娃(不能放入另一个潜影盒)
|
||||
- ✅ 异常恢复(物品丢失自动掉落)
|
||||
## 主要功能
|
||||
|
||||
### 🔧 实用工具
|
||||
- **帽子** (`/hat`) - 将手中物品戴在头上
|
||||
- **自杀** (`/suicide`, `/die`) - 快速自杀
|
||||
- **飞行** (`/fly`) - 切换飞行模式
|
||||
- **修复** (`/repair`, `/rep`) - 修复手中或所有物品
|
||||
- **饱食** (`/feed`) - 补满饱食度
|
||||
### 便捷方块
|
||||
|
||||
### 💚 生存辅助
|
||||
- **治疗** (`/heal`) - 恢复生命值和饱食度
|
||||
- **隐身** (`/vanish`, `/v`) - 管理员隐身模式
|
||||
- `/workbench` `(/wb)`
|
||||
- `/anvil`
|
||||
- `/cartographytable` `(/ct, /cartography)`
|
||||
- `/grindstone` `(/gs)`
|
||||
- `/loom`
|
||||
- `/smithingtable` `(/st, /smithing)`
|
||||
- `/stonecutter` `(/sc)`
|
||||
- `/enderchest` `(/ec)`
|
||||
- `/essc blocks` 打开便捷菜单
|
||||
|
||||
### 📊 管理功能
|
||||
- **玩家查询** (`/seen`, `/info`) - 查看玩家上线时间和信息
|
||||
- **功能方块菜单** (`/essc blocks`) - GUI 方块集合面板
|
||||
- **配置重载** (`/essc reload`) - 重新加载配置文件
|
||||
### 玩家功能
|
||||
|
||||
---
|
||||
- `/fly`
|
||||
- `/nightvision` `(/nv)`
|
||||
- `/glow`
|
||||
- `/heal`
|
||||
- `/feed`
|
||||
- `/repair` `(/rep)`
|
||||
- `/hat`
|
||||
- `/suicide` `(/die)`
|
||||
- `/vanish` `(/v)`
|
||||
- `/seen` `(/info)`
|
||||
- `/tpsbar`
|
||||
- `/essc admin` 管理模式切换
|
||||
- `/maintenance` `(/maint)` 维护模式管理
|
||||
|
||||
## 🌍 多语言支持
|
||||
### 其它功能
|
||||
|
||||
- ✅ 完整的中文和英文配置
|
||||
- ✅ 方块标题自动跟随客户端语言
|
||||
- ✅ 可自定义所有消息文本
|
||||
- Shift + 右键快捷打开潜影盒
|
||||
- 潜影盒交互保护,尽量避免刷物品、吞物品和嵌套放入问题
|
||||
- 管理模式独立背包、装备栏与状态切换
|
||||
- 维护模式:替换 MOTD、登录拦截、白名单放行和管理员拦截通知
|
||||
- Enderman 掉落方块控制
|
||||
- JEI 配方同步修复
|
||||
|
||||
## ⚡ 权限系统
|
||||
## 模块配置
|
||||
|
||||
- ✅ 精细的权限管理
|
||||
- ✅ 帮助菜单智能显示(只显示有权限的命令)
|
||||
- ✅ 默认仅 OP 可用,可通过权限插件授权
|
||||
- ✅ CMI 风格的命令别名支持
|
||||
项目现在默认构建一个完整插件,功能是否启用由 `plugins/EssentialsC/modules.yml` 控制。
|
||||
|
||||
## 📦 快速开始
|
||||
| 模块 | 默认状态 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| `blocks` | 开启 | 便捷方块命令、`/essc blocks` 菜单、潜影盒快捷打开 |
|
||||
| `player` | 开启 | 飞行、夜视、发光、治疗、喂食、修复、帽子、自杀、隐身、查询玩家 |
|
||||
| `admin-mode` | 开启 | `/essc admin` 管理模式与独立状态保存 |
|
||||
| `tpsbar` | 开启 | 插件版 TPSBar,仍受 `config.yml` 中 `tpsbar.mode` 控制 |
|
||||
| `jei-sync` | 开启 | Fabric / NeoForge JEI 配方同步修复 |
|
||||
| `mob-drops` | 关闭 | 末影人掉落控制,默认关闭以保留过去标准版行为 |
|
||||
| `maintenance` | 开启 | 维护模式命令、MOTD 替换、登录拦截、白名单和拦截通知 |
|
||||
|
||||
### 系统要求
|
||||
- **服务器**: Paper 1.21+
|
||||
- **Java**: 21+
|
||||
修改模块开关后可先使用 `/essc reload` 刷新运行期服务与监听器状态。由于 Bukkit 命令表不适合在运行期完整热增删,若模块是在启动时关闭的,对应直连命令可能仍需重启后才会注册;通过 `/essc <子命令>` 入口通常可立即按新的模块状态执行。
|
||||
|
||||
### 安装步骤
|
||||
1. 下载最新版本的 [`essentialsc-*.jar`](https://github.com/Coldsmiles/EssentialsC/releases)
|
||||
2. 将文件放入服务器的 `plugins` 文件夹
|
||||
3. 重启服务器
|
||||
4. 编辑 `plugins/EssentialsC/config.yml` 配置语言
|
||||
5. (可选)使用权限插件为玩家授予相应权限
|
||||
## 安装说明
|
||||
|
||||
## 🎮 命令列表
|
||||
1. 从 [Releases](https://github.com/Coldsmiles/EssentialsC/releases) 下载所需版本。
|
||||
2. 将插件放入服务端的 `plugins/` 目录。
|
||||
3. 启动一次服务端以生成配置文件。
|
||||
4. 按需修改 `plugins/EssentialsC/config.yml` 与 `plugins/EssentialsC/lang/` 下的语言文件。
|
||||
5. 如有需要,使用权限插件为玩家授权。
|
||||
|
||||
### 基础命令
|
||||
| 命令 | 说明 |
|
||||
|------|------|
|
||||
| `/essc help` | 显示帮助菜单(根据权限动态显示) |
|
||||
| `/essc reload` | 重载配置(管理员) |
|
||||
| `/essc blocks` | 打开功能方块菜单 |
|
||||
## 配置说明
|
||||
|
||||
### 功能方块命令
|
||||
| 命令 | 别名 | 说明 |
|
||||
|------|------|------|
|
||||
| `/workbench` | `/wb` | 打开工作台 |
|
||||
| `/anvil` | - | 打开铁砧 |
|
||||
| `/cartographytable` | `/ct` | 打开制图台 |
|
||||
| `/grindstone` | `/gs` | 打开砂轮 |
|
||||
| `/loom` | - | 打开织布机 |
|
||||
| `/smithingtable` | `/st` | 打开锻造台 |
|
||||
| `/stonecutter` | `/sc` | 打开切石机 |
|
||||
| `/enderchest` | `/ec` | 打开末影箱 |
|
||||
当前配置结构以“行为配置”和“文本配置”分离为原则:
|
||||
|
||||
### 其他命令
|
||||
| 命令 | 别名 | 说明 |
|
||||
|------|------|------|
|
||||
| `/hat` | - | 将手中物品戴在头上 |
|
||||
| `/suicide` | `/die` | 自杀 |
|
||||
| `/fly` | - | 切换飞行模式 |
|
||||
| `/heal` | - | 恢复生命值和饱食度 |
|
||||
| `/vanish` | `/v` | 切换隐身模式(管理员) |
|
||||
| `/seen` | `/info` | 查看玩家信息(管理员) |
|
||||
| `/feed` | - | 补满饱食度 |
|
||||
| `/repair` | `/rep` | 修复手中或所有物品 |
|
||||
- `config.yml`
|
||||
- 语言选择
|
||||
- 管理模式行为
|
||||
- JEI 同步开关
|
||||
- 掉落控制
|
||||
- TPSBar 模式
|
||||
- 便捷菜单布局
|
||||
- `modules.yml`
|
||||
- 功能模块开关
|
||||
- `maintenance.yml`
|
||||
- 维护模式状态
|
||||
- 维护 MOTD
|
||||
- 维护踢出提示
|
||||
- 维护 BossBar
|
||||
- 绕过权限
|
||||
- 维护白名单
|
||||
- 拦截通知权限
|
||||
- `lang/zh_CN.yml`、`lang/en_US.yml`
|
||||
- 命令反馈
|
||||
- 帮助信息
|
||||
- 菜单文本
|
||||
- 管理模式文本
|
||||
- TPSBar 文本
|
||||
|
||||
> 💡 **提示**: 使用 `/repair all` 可以修复背包中的所有物品
|
||||
配置文件包含 `config-version`,后续如有结构升级,可基于版本号进行迁移与重建。
|
||||
|
||||
## ⚙️ 配置说明
|
||||
## 权限示例
|
||||
|
||||
### config.yml
|
||||
```yaml
|
||||
# 语言设置 (en_US, zh_CN)
|
||||
language: "zh_CN"
|
||||
常用权限节点:
|
||||
|
||||
# 通用设置
|
||||
settings:
|
||||
enable-feedback: true # 启用命令反馈消息
|
||||
|
||||
# 潜影盒设置
|
||||
shulkerbox:
|
||||
default-title: "&e潜影盒" # 默认标题(支持颜色代码)
|
||||
```text
|
||||
essentialsc.command.blocks
|
||||
essentialsc.command.workbench
|
||||
essentialsc.command.enderchest
|
||||
essentialsc.command.fly
|
||||
essentialsc.command.nightvision
|
||||
essentialsc.command.glow
|
||||
essentialsc.command.heal
|
||||
essentialsc.command.feed
|
||||
essentialsc.command.repair
|
||||
essentialsc.command.vanish
|
||||
essentialsc.command.seen
|
||||
essentialsc.command.admin
|
||||
essentialsc.command.tpsbar
|
||||
essentialsc.command.maintenance
|
||||
essentialsc.maintenance.bypass
|
||||
essentialsc.maintenance.notify
|
||||
essentialsc.shulkerbox.open
|
||||
essentialsc.mobdrops.enderman
|
||||
essentialsc.*
|
||||
```
|
||||
|
||||
### 自定义语言
|
||||
编辑 `plugins/EssentialsC/lang/` 目录下的语言文件来自定义所有消息文本。
|
||||
具体默认值与完整节点以 `paper-plugin.yml` 为准。
|
||||
|
||||
## 🔐 权限节点
|
||||
|
||||
所有命令默认需要 OP 权限。使用权限插件授予权限:
|
||||
|
||||
### 基础权限
|
||||
```
|
||||
essentialsc.command.workbench # 工作台
|
||||
essentialsc.command.anvil # 铁砧
|
||||
essentialsc.command.cartographytable # 制图台
|
||||
essentialsc.command.grindstone # 砂轮
|
||||
essentialsc.command.loom # 织布机
|
||||
essentialsc.command.smithingtable # 锻造台
|
||||
essentialsc.command.stonecutter # 切石机
|
||||
essentialsc.command.enderchest # 末影箱
|
||||
essentialsc.command.hat # 帽子
|
||||
essentialsc.command.suicide # 自杀
|
||||
essentialsc.command.fly # 飞行
|
||||
essentialsc.command.heal # 治疗
|
||||
essentialsc.command.vanish # 隐身
|
||||
essentialsc.command.seen # 玩家查询
|
||||
essentialsc.command.feed # 饱食度
|
||||
essentialsc.command.repair # 修复
|
||||
essentialsc.shulkerbox.open # 潜行+右键潜影盒
|
||||
```
|
||||
|
||||
### 管理权限
|
||||
```
|
||||
essentialsc.command.blocks # 功能方块菜单
|
||||
essentialsc.command.reload # 重载配置
|
||||
essentialsc.command.help # 帮助(默认开放)
|
||||
```
|
||||
|
||||
### 通配符
|
||||
```
|
||||
essentialsc.* # 所有权限
|
||||
```
|
||||
|
||||
## 🔨 从源码构建
|
||||
## 从源码构建
|
||||
|
||||
```bash
|
||||
git clone https://github.com/Coldsmiles/EssentialsC.git
|
||||
@@ -170,20 +144,46 @@ cd EssentialsC
|
||||
./gradlew build
|
||||
```
|
||||
|
||||
编译后的文件位于 `build/libs/essentialsc-*.jar`
|
||||
Windows 可使用:
|
||||
|
||||
## 🤝 贡献
|
||||
```powershell
|
||||
.\gradlew.bat build
|
||||
```
|
||||
|
||||
欢迎提交 Issue 和 Pull Request!
|
||||
构建产物输出到 `build/libs/EssentialsC-<version>.jar`。
|
||||
|
||||
## 📄 许可证
|
||||
常用任务:
|
||||
|
||||
本项目采用 MIT 许可证 - 详见 [LICENSE](LICENSE) 文件
|
||||
```bash
|
||||
./gradlew shadowJar
|
||||
./gradlew build
|
||||
./gradlew deployToPaper12111
|
||||
./gradlew deployToPaper2612
|
||||
```
|
||||
|
||||
## 👨💻 作者
|
||||
- GitHub: [@Coldsmiles](https://github.com/Coldsmiles)
|
||||
- 网站: www.infstar.cn
|
||||
## 本地测试服
|
||||
|
||||
## ⭐ 支持
|
||||
项目包含两个本地测试服目录:
|
||||
|
||||
如果觉得这个插件对你有帮助,请考虑在 GitHub 上给它一个 Star!
|
||||
| 测试服 | 端口 | 部署任务 | 启动脚本 |
|
||||
| --- | --- | --- | --- |
|
||||
| Paper 1.21.11 | `25566` | `deployToPaper12111` | `test-server/paper-1.21.11/start.bat` |
|
||||
| Paper 26.1.2 | `25565` | `deployToPaper2612` | `test-server/paper-26.1.2/start.bat` |
|
||||
|
||||
IDEA 运行配置会在启动测试服前自动执行对应部署任务。部署任务会替换 `EssentialsC*.jar`,并删除 `plugins/EssentialsC` 数据目录,以便测试新增默认配置和语言文本。
|
||||
|
||||
## 开发说明
|
||||
|
||||
- 使用 `paperweight-userdev` 进行 Paper 开发
|
||||
- 使用 Paper Lifecycle Command API 注册命令,避免直接反射 Bukkit CommandMap
|
||||
- 运行时通过 `modules.yml` 控制模块加载,命令与监听器按模块状态注册
|
||||
- 发布流程基于 GitHub Actions 和 Gradle Wrapper
|
||||
|
||||
## 许可证
|
||||
|
||||
本项目基于 [MIT License](LICENSE) 开源。
|
||||
|
||||
## 仓库
|
||||
|
||||
- GitHub: <https://github.com/Coldsmiles/EssentialsC>
|
||||
- Gitea: <https://git.infstar.cn/InfStarMC/EssentialsC>
|
||||
|
||||
187
build.gradle
187
build.gradle
@@ -1,8 +1,6 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import org.gradle.language.jvm.tasks.ProcessResources
|
||||
|
||||
import java.util.Collections
|
||||
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'io.papermc.paperweight.userdev' version '2.0.0-beta.21'
|
||||
@@ -10,7 +8,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'cn.infstar'
|
||||
version = '1.3.1'
|
||||
version = '1.5.0'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@@ -28,96 +26,6 @@ java {
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
|
||||
def moduleExcludes = [
|
||||
'blocks': [
|
||||
'**/commands/WorkbenchCommand.java',
|
||||
'**/commands/AnvilCommand.java',
|
||||
'**/commands/CartographyTableCommand.java',
|
||||
'**/commands/GrindstoneCommand.java',
|
||||
'**/commands/LoomCommand.java',
|
||||
'**/commands/SmithingTableCommand.java',
|
||||
'**/commands/StonecutterCommand.java',
|
||||
'**/commands/EnderChestCommand.java',
|
||||
'**/commands/BlocksMenuCommand.java',
|
||||
'**/listeners/ShulkerBoxListener.java'
|
||||
],
|
||||
'player': [
|
||||
'**/commands/FlyCommand.java',
|
||||
'**/commands/NightVisionCommand.java',
|
||||
'**/commands/GlowCommand.java',
|
||||
'**/commands/HealCommand.java',
|
||||
'**/commands/FeedCommand.java',
|
||||
'**/commands/VanishCommand.java',
|
||||
'**/commands/SeenCommand.java',
|
||||
'**/commands/HatCommand.java',
|
||||
'**/commands/SuicideCommand.java',
|
||||
'**/commands/RepairCommand.java',
|
||||
'**/commands/AdminCommand.java',
|
||||
'**/commands/TpsBarCommand.java',
|
||||
'**/tpsbar/TpsBarManager.java'
|
||||
],
|
||||
'jei-fix': [
|
||||
'**/listeners/JeiRecipeSyncListener.java'
|
||||
],
|
||||
'mob-drops': [
|
||||
'**/listeners/MobDropListener.java',
|
||||
'**/listeners/MobDropMenuListener.java',
|
||||
'**/commands/MobDropCommand.java'
|
||||
]
|
||||
]
|
||||
|
||||
def variantDefinitions = [
|
||||
standard: [
|
||||
archiveFileName: "EssentialsC-${project.version}.jar",
|
||||
excludedModules: ['mob-drops']
|
||||
],
|
||||
all: [
|
||||
archiveFileName: "EssentialsC-all-${project.version}.jar",
|
||||
excludedModules: []
|
||||
],
|
||||
lite: [
|
||||
archiveFileName: "EssentialsC-lite-${project.version}.jar",
|
||||
excludedModules: ['blocks']
|
||||
]
|
||||
]
|
||||
|
||||
if (project.hasProperty('excludeModules')) {
|
||||
def customExcludedModules = project.property('excludeModules')
|
||||
.split(',')
|
||||
.collect { it.trim() }
|
||||
.findAll { !it.isEmpty() }
|
||||
|
||||
variantDefinitions.custom = [
|
||||
archiveFileName: "EssentialsC-custom-${project.version}.jar",
|
||||
excludedModules: customExcludedModules
|
||||
]
|
||||
}
|
||||
|
||||
def resolveExcludePatterns = { Collection<String> modules ->
|
||||
modules.collectMany { module -> moduleExcludes.get(module, Collections.emptyList()) }.unique()
|
||||
}
|
||||
|
||||
variantDefinitions.each { variantName, variantConfig ->
|
||||
def unknownModules = variantConfig.excludedModules.findAll { !moduleExcludes.containsKey(it) }
|
||||
if (!unknownModules.isEmpty()) {
|
||||
throw new GradleException("Unknown modules for variant '${variantName}': ${unknownModules.join(', ')}")
|
||||
}
|
||||
}
|
||||
|
||||
def variantSourceSets = [:]
|
||||
|
||||
variantDefinitions.each { variantName, variantConfig ->
|
||||
def sourceSet = sourceSets.create(variantName)
|
||||
sourceSet.java.srcDirs = sourceSets.main.java.srcDirs
|
||||
sourceSet.resources.srcDirs = sourceSets.main.resources.srcDirs
|
||||
resolveExcludePatterns(variantConfig.excludedModules).each { pattern ->
|
||||
sourceSet.java.exclude(pattern)
|
||||
}
|
||||
sourceSet.compileClasspath += sourceSets.main.compileClasspath
|
||||
sourceSet.runtimeClasspath += sourceSet.output + sourceSet.compileClasspath
|
||||
variantSourceSets[variantName] = sourceSet
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
||||
@@ -126,14 +34,10 @@ tasks.withType(ProcessResources).configureEach {
|
||||
filteringCharset = 'UTF-8'
|
||||
}
|
||||
|
||||
variantDefinitions.keySet().each { variantName ->
|
||||
def sourceSet = variantSourceSets[variantName]
|
||||
def processTaskName = sourceSet.processResourcesTaskName
|
||||
tasks.named(processTaskName, ProcessResources).configure {
|
||||
inputs.property('version', project.version)
|
||||
filesMatching('paper-plugin.yml') {
|
||||
expand('version': project.version)
|
||||
}
|
||||
tasks.named('processResources', ProcessResources).configure {
|
||||
inputs.property('version', project.version)
|
||||
filesMatching('paper-plugin.yml') {
|
||||
expand('version': project.version)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,72 +45,35 @@ tasks.named('jar').configure {
|
||||
enabled = false
|
||||
}
|
||||
|
||||
tasks.named('shadowJar').configure {
|
||||
enabled = false
|
||||
}
|
||||
|
||||
def variantJarTasks = variantDefinitions.collect { variantName, variantConfig ->
|
||||
def taskName = "shadowJar${variantName.capitalize()}"
|
||||
def sourceSet = variantSourceSets[variantName]
|
||||
|
||||
tasks.register(taskName, ShadowJar) {
|
||||
group = 'build'
|
||||
description = "Builds the ${variantName} plugin jar."
|
||||
archiveFileName.set(variantConfig.archiveFileName as String)
|
||||
from(sourceSet.output)
|
||||
configurations = [project.configurations.runtimeClasspath]
|
||||
dependsOn(tasks.named(sourceSet.classesTaskName))
|
||||
}
|
||||
tasks.named('shadowJar', ShadowJar).configure {
|
||||
group = 'build'
|
||||
description = '构建包含全部运行期可开关模块的 EssentialsC 插件。'
|
||||
archiveFileName.set("EssentialsC-${project.version}.jar")
|
||||
configurations = [project.configurations.runtimeClasspath]
|
||||
}
|
||||
|
||||
tasks.named('assemble').configure {
|
||||
dependsOn(variantJarTasks)
|
||||
dependsOn(tasks.named('shadowJar'))
|
||||
}
|
||||
|
||||
tasks.register('buildAllVersions') {
|
||||
group = 'build'
|
||||
description = 'Builds standard, all, and lite plugin jars.'
|
||||
dependsOn(variantJarTasks)
|
||||
}
|
||||
def registerTestServerDeployTask = { String taskName, String serverPath, String serverName ->
|
||||
tasks.register(taskName, Copy) {
|
||||
group = 'deployment'
|
||||
description = "构建并部署插件到本地 ${serverName} 测试服务器。"
|
||||
def artifact = tasks.named('shadowJar').flatMap { it.archiveFile }
|
||||
def pluginsDir = layout.projectDirectory.dir("${serverPath}/plugins")
|
||||
dependsOn(tasks.named('shadowJar'))
|
||||
from(artifact)
|
||||
into(pluginsDir)
|
||||
|
||||
tasks.register('deployToPaper12111', Copy) {
|
||||
group = 'deployment'
|
||||
description = 'Deploys the all variant to the local Paper 1.21.11 test server.'
|
||||
def artifact = tasks.named('shadowJarAll').flatMap { it.archiveFile }
|
||||
dependsOn(tasks.named('shadowJarAll'))
|
||||
from(artifact)
|
||||
into(layout.projectDirectory.dir('test-server/paper-1.21.11/plugins'))
|
||||
}
|
||||
|
||||
tasks.register('deployToPaper26') {
|
||||
group = 'deployment'
|
||||
description = 'Deploys the all variant to the local Paper 26.1.2 test server.'
|
||||
dependsOn(tasks.named('shadowJarAll'))
|
||||
|
||||
doFirst {
|
||||
def pluginsDir = file("${projectDir}/test-server/paper-26.1.2/plugins")
|
||||
if (!pluginsDir.exists()) {
|
||||
return
|
||||
}
|
||||
|
||||
fileTree(pluginsDir).matching {
|
||||
include 'EssentialsC*.jar'
|
||||
}.each { pluginJar ->
|
||||
pluginJar.delete()
|
||||
}
|
||||
}
|
||||
|
||||
doLast {
|
||||
def artifact = tasks.named('shadowJarAll').flatMap { it.archiveFile }
|
||||
copy {
|
||||
from(artifact)
|
||||
into("${projectDir}/test-server/paper-26.1.2/plugins")
|
||||
doFirst {
|
||||
delete(fileTree(pluginsDir) {
|
||||
include 'EssentialsC*.jar'
|
||||
})
|
||||
delete(pluginsDir.file('EssentialsC').asFile)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register('buildAndDeployToPaper26') {
|
||||
group = 'deployment'
|
||||
description = 'Builds and deploys the all variant to the local Paper 26.1.2 test server.'
|
||||
dependsOn(tasks.named('clean'), tasks.named('deployToPaper26'))
|
||||
}
|
||||
registerTestServerDeployTask('deployToPaper12111', 'test-server/paper-1.21.11', 'Paper 1.21.11')
|
||||
registerTestServerDeployTask('deployToPaper2612', 'test-server/paper-26.1.2', 'Paper 26.1.2')
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
// 阿里云 Gradle 插件镜像(优先)
|
||||
// 阿里云 Gradle 插件镜像,优先使用以提升国内拉取稳定性
|
||||
maven {
|
||||
name = 'aliyun-gradle-plugin'
|
||||
url = uri('https://maven.aliyun.com/repository/gradle-plugin')
|
||||
}
|
||||
// Gradle 官方插件仓库
|
||||
gradlePluginPortal()
|
||||
// PaperMC 官方仓库(用于 paperweight 插件)
|
||||
// PaperMC 官方仓库,用于解析 paperweight 插件
|
||||
maven {
|
||||
name = 'papermc'
|
||||
url = uri('https://repo.papermc.io/repository/maven-public/')
|
||||
|
||||
@@ -4,35 +4,57 @@ import cn.infstar.essentialsC.admin.AdminModeManager;
|
||||
import cn.infstar.essentialsC.commands.BaseCommand;
|
||||
import cn.infstar.essentialsC.commands.CommandRegistry;
|
||||
import cn.infstar.essentialsC.commands.HelpCommand;
|
||||
import cn.infstar.essentialsC.commands.PaperCommand;
|
||||
import cn.infstar.essentialsC.commands.VanishCommand;
|
||||
import cn.infstar.essentialsC.listeners.JeiRecipeSyncListener;
|
||||
import cn.infstar.essentialsC.listeners.MobDropListener;
|
||||
import cn.infstar.essentialsC.listeners.MobDropMenuListener;
|
||||
import cn.infstar.essentialsC.listeners.ShulkerBoxListener;
|
||||
import cn.infstar.essentialsC.listeners.VanishListener;
|
||||
import cn.infstar.essentialsC.maintenance.MaintenanceListener;
|
||||
import cn.infstar.essentialsC.maintenance.MaintenanceManager;
|
||||
import cn.infstar.essentialsC.tpsbar.TpsBarManager;
|
||||
import cn.infstar.essentialsC.tpsbar.TpsBarService;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.messaging.Messenger;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import io.papermc.paper.command.brigadier.BasicCommand;
|
||||
import io.papermc.paper.command.brigadier.CommandSourceStack;
|
||||
import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public final class EssentialsC extends JavaPlugin {
|
||||
|
||||
private static LangManager langManager;
|
||||
private ModuleManager moduleManager;
|
||||
private AdminModeManager adminModeManager;
|
||||
private MaintenanceManager maintenanceManager;
|
||||
private MaintenanceListener maintenanceListener;
|
||||
private TpsBarService tpsBarManager;
|
||||
private ShulkerBoxListener shulkerBoxListener;
|
||||
private JeiRecipeSyncListener jeiRecipeSyncListener;
|
||||
private MobDropListener mobDropListener;
|
||||
private MobDropMenuListener mobDropMenuListener;
|
||||
private VanishListener vanishListener;
|
||||
private boolean commandsRegistered;
|
||||
private final Map<String, String> moduleStatus = new LinkedHashMap<>();
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
langManager = new LangManager(this);
|
||||
adminModeManager = new AdminModeManager(this);
|
||||
getServer().getPluginManager().registerEvents(adminModeManager, this);
|
||||
tpsBarManager = createOptionalService("cn.infstar.essentialsC.tpsbar.TpsBarManager", TpsBarService.class);
|
||||
if (tpsBarManager instanceof Listener listener) {
|
||||
getServer().getPluginManager().registerEvents(listener, this);
|
||||
}
|
||||
registerPluginChannels();
|
||||
registerListeners();
|
||||
moduleManager = new ModuleManager(this);
|
||||
|
||||
reloadRuntimeModules();
|
||||
registerCommands();
|
||||
|
||||
getLogger().info("EssentialsC enabled. Version: " + getDescription().getVersion());
|
||||
logStartupSummary();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,7 +65,13 @@ public final class EssentialsC extends JavaPlugin {
|
||||
if (adminModeManager != null) {
|
||||
adminModeManager.shutdown();
|
||||
}
|
||||
getLogger().info("EssentialsC disabled.");
|
||||
if (maintenanceManager != null) {
|
||||
maintenanceManager.shutdown();
|
||||
}
|
||||
VanishCommand.clearAll(this);
|
||||
unregisterRuntimeListeners();
|
||||
unregisterPluginChannels();
|
||||
getLogger().info("EssentialsC 已禁用。");
|
||||
}
|
||||
|
||||
public static LangManager getLangManager() {
|
||||
@@ -54,66 +82,242 @@ public final class EssentialsC extends JavaPlugin {
|
||||
return adminModeManager;
|
||||
}
|
||||
|
||||
public ModuleManager getModuleManager() {
|
||||
return moduleManager;
|
||||
}
|
||||
|
||||
public MaintenanceManager getMaintenanceManager() {
|
||||
return maintenanceManager;
|
||||
}
|
||||
|
||||
public TpsBarService getTpsBarManager() {
|
||||
return tpsBarManager;
|
||||
}
|
||||
|
||||
public void reloadRuntimeModules() {
|
||||
moduleStatus.clear();
|
||||
refreshPlayer();
|
||||
refreshAdminMode();
|
||||
refreshMaintenance();
|
||||
refreshTpsBar();
|
||||
refreshBlocks();
|
||||
refreshJeiSync();
|
||||
refreshMobDrops();
|
||||
}
|
||||
|
||||
private void refreshPlayer() {
|
||||
if (!moduleManager.isEnabled(ModuleManager.PLAYER)) {
|
||||
VanishCommand.clearAll(this);
|
||||
if (vanishListener != null) {
|
||||
HandlerList.unregisterAll(vanishListener);
|
||||
vanishListener = null;
|
||||
}
|
||||
setModuleStatus("玩家功能", false, "已禁用");
|
||||
return;
|
||||
}
|
||||
|
||||
if (vanishListener == null) {
|
||||
vanishListener = new VanishListener(this);
|
||||
getServer().getPluginManager().registerEvents(vanishListener, this);
|
||||
}
|
||||
setModuleStatus("玩家功能", true, "命令可用");
|
||||
}
|
||||
|
||||
private void refreshAdminMode() {
|
||||
if (!moduleManager.isEnabled(ModuleManager.ADMIN_MODE)) {
|
||||
if (adminModeManager != null) {
|
||||
adminModeManager.shutdown();
|
||||
HandlerList.unregisterAll(adminModeManager);
|
||||
adminModeManager = null;
|
||||
}
|
||||
setModuleStatus("管理模式", false, "已禁用");
|
||||
return;
|
||||
}
|
||||
|
||||
if (adminModeManager == null) {
|
||||
adminModeManager = new AdminModeManager(this);
|
||||
getServer().getPluginManager().registerEvents(adminModeManager, this);
|
||||
}
|
||||
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);
|
||||
getServer().getPluginManager().registerEvents(maintenanceListener, this);
|
||||
}
|
||||
setModuleStatus("维护模式", true, maintenanceManager.isEnabled() ? "当前开启" : "当前关闭");
|
||||
}
|
||||
|
||||
private void refreshTpsBar() {
|
||||
if (!moduleManager.isEnabled(ModuleManager.TPSBAR)) {
|
||||
if (tpsBarManager != null) {
|
||||
tpsBarManager.shutdown();
|
||||
if (tpsBarManager instanceof Listener listener) {
|
||||
HandlerList.unregisterAll(listener);
|
||||
}
|
||||
tpsBarManager = null;
|
||||
}
|
||||
setModuleStatus("TPSBar", false, "模块已禁用");
|
||||
return;
|
||||
}
|
||||
|
||||
if (tpsBarManager == null) {
|
||||
tpsBarManager = new TpsBarManager(this);
|
||||
if (tpsBarManager instanceof Listener listener) {
|
||||
getServer().getPluginManager().registerEvents(listener, this);
|
||||
}
|
||||
} else {
|
||||
tpsBarManager.reloadSettings();
|
||||
}
|
||||
if (tpsBarManager == null) {
|
||||
setModuleStatus("TPSBar", false, "初始化失败");
|
||||
} else if (!tpsBarManager.isPluginCommandEnabled()) {
|
||||
setModuleStatus("TPSBar", false, tpsBarManager.isNativeCommandAvailable() ? "使用服务端原生命令" : "插件命令关闭");
|
||||
} else {
|
||||
setModuleStatus("TPSBar", true, "插件命令已启用");
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshBlocks() {
|
||||
if (!moduleManager.isEnabled(ModuleManager.BLOCKS)) {
|
||||
if (shulkerBoxListener != null) {
|
||||
HandlerList.unregisterAll(shulkerBoxListener);
|
||||
shulkerBoxListener = null;
|
||||
}
|
||||
setModuleStatus("便捷方块", false, "已禁用");
|
||||
return;
|
||||
}
|
||||
|
||||
if (shulkerBoxListener == null) {
|
||||
shulkerBoxListener = new ShulkerBoxListener(this);
|
||||
getServer().getPluginManager().registerEvents(shulkerBoxListener, this);
|
||||
}
|
||||
setModuleStatus("便捷方块", true, "命令和潜影盒监听器已启用");
|
||||
}
|
||||
|
||||
private void refreshJeiSync() {
|
||||
if (jeiRecipeSyncListener != null) {
|
||||
HandlerList.unregisterAll(jeiRecipeSyncListener);
|
||||
jeiRecipeSyncListener = null;
|
||||
}
|
||||
unregisterPluginChannels();
|
||||
|
||||
if (!moduleManager.isEnabled(ModuleManager.JEI_SYNC)) {
|
||||
setModuleStatus("JEI 同步", false, "已禁用");
|
||||
return;
|
||||
}
|
||||
|
||||
registerPluginChannels();
|
||||
jeiRecipeSyncListener = new JeiRecipeSyncListener(this);
|
||||
getServer().getPluginManager().registerEvents(jeiRecipeSyncListener, this);
|
||||
setModuleStatus("JEI 同步", true, "插件消息通道已注册");
|
||||
}
|
||||
|
||||
private void refreshMobDrops() {
|
||||
if (!moduleManager.isEnabled(ModuleManager.MOB_DROPS)) {
|
||||
if (mobDropListener != null) {
|
||||
HandlerList.unregisterAll(mobDropListener);
|
||||
mobDropListener = null;
|
||||
}
|
||||
if (mobDropMenuListener != null) {
|
||||
HandlerList.unregisterAll(mobDropMenuListener);
|
||||
mobDropMenuListener = null;
|
||||
}
|
||||
setModuleStatus("生物掉落", false, "已禁用");
|
||||
return;
|
||||
}
|
||||
|
||||
if (mobDropListener == null) {
|
||||
mobDropListener = new MobDropListener(this);
|
||||
getServer().getPluginManager().registerEvents(mobDropListener, this);
|
||||
} else {
|
||||
mobDropListener.reload();
|
||||
}
|
||||
if (mobDropMenuListener == null) {
|
||||
mobDropMenuListener = new MobDropMenuListener(this);
|
||||
}
|
||||
setModuleStatus("生物掉落", true, "末影人掉落控制已启用");
|
||||
}
|
||||
|
||||
private void registerPluginChannels() {
|
||||
org.bukkit.plugin.messaging.Messenger messenger = getServer().getMessenger();
|
||||
Messenger messenger = getServer().getMessenger();
|
||||
messenger.registerOutgoingPluginChannel(this, "fabric:recipe_sync");
|
||||
messenger.registerOutgoingPluginChannel(this, "neoforge:recipe_content");
|
||||
}
|
||||
|
||||
private void registerListeners() {
|
||||
if (registerListener("cn.infstar.essentialsC.listeners.ShulkerBoxListener")) {
|
||||
getLogger().info("- Shulker box module");
|
||||
}
|
||||
private void unregisterPluginChannels() {
|
||||
Messenger messenger = getServer().getMessenger();
|
||||
messenger.unregisterOutgoingPluginChannel(this, "fabric:recipe_sync");
|
||||
messenger.unregisterOutgoingPluginChannel(this, "neoforge:recipe_content");
|
||||
}
|
||||
|
||||
if (registerListener("cn.infstar.essentialsC.listeners.JeiRecipeSyncListener")) {
|
||||
getLogger().info("- JEI recipe sync");
|
||||
}
|
||||
|
||||
if (registerListener("cn.infstar.essentialsC.listeners.MobDropListener")) {
|
||||
createOptionalInstance("cn.infstar.essentialsC.listeners.MobDropMenuListener");
|
||||
getLogger().info("- Mob drop control");
|
||||
private void unregisterRuntimeListeners() {
|
||||
unregisterListener(adminModeManager);
|
||||
unregisterListener(maintenanceListener);
|
||||
unregisterListener(shulkerBoxListener);
|
||||
unregisterListener(jeiRecipeSyncListener);
|
||||
unregisterListener(mobDropListener);
|
||||
unregisterListener(mobDropMenuListener);
|
||||
unregisterListener(vanishListener);
|
||||
if (tpsBarManager instanceof Listener listener) {
|
||||
unregisterListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean registerListener(String className) {
|
||||
try {
|
||||
Class<?> listenerClass = Class.forName(className);
|
||||
Object listenerInstance = listenerClass.getConstructor(EssentialsC.class).newInstance(this);
|
||||
getServer().getPluginManager().registerEvents((org.bukkit.event.Listener) listenerInstance, this);
|
||||
return true;
|
||||
} catch (Exception ignored) {
|
||||
return false;
|
||||
private void unregisterListener(Listener listener) {
|
||||
if (listener != null) {
|
||||
HandlerList.unregisterAll(listener);
|
||||
}
|
||||
}
|
||||
|
||||
private void createOptionalInstance(String className) {
|
||||
try {
|
||||
Class<?> targetClass = Class.forName(className);
|
||||
targetClass.getConstructor(EssentialsC.class).newInstance(this);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
private void setModuleStatus(String moduleName, boolean enabled, String detail) {
|
||||
moduleStatus.put(moduleName, (enabled ? "启用" : "关闭") + " - " + detail);
|
||||
}
|
||||
|
||||
private <T> T createOptionalService(String className, Class<T> serviceType) {
|
||||
try {
|
||||
Class<?> targetClass = Class.forName(className);
|
||||
Object instance = targetClass.getConstructor(EssentialsC.class).newInstance(this);
|
||||
return serviceType.cast(instance);
|
||||
} catch (Exception ignored) {
|
||||
return null;
|
||||
private void logStartupSummary() {
|
||||
long enabledCount = moduleStatus.values().stream()
|
||||
.filter(status -> status.startsWith("启用"))
|
||||
.count();
|
||||
long disabledCount = moduleStatus.size() - enabledCount;
|
||||
|
||||
getLogger().info("EssentialsC v" + getDescription().getVersion()
|
||||
+ " 已启用 | 模块: " + enabledCount + " 启用, " + disabledCount + " 关闭");
|
||||
|
||||
if (!getConfig().getBoolean("debug", false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
getLogger().info("模块明细:");
|
||||
for (Map.Entry<String, String> entry : moduleStatus.entrySet()) {
|
||||
getLogger().info(" " + entry.getKey() + ": " + entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
private void registerCommands() {
|
||||
try {
|
||||
Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");
|
||||
bukkitCommandMap.setAccessible(true);
|
||||
org.bukkit.command.CommandMap commandMap = (org.bukkit.command.CommandMap) bukkitCommandMap.get(Bukkit.getServer());
|
||||
|
||||
if (commandsRegistered) {
|
||||
return;
|
||||
}
|
||||
commandsRegistered = true;
|
||||
getLifecycleManager().registerEventHandler(LifecycleEvents.COMMANDS, event -> {
|
||||
for (CommandRegistry.CommandSpec spec : CommandRegistry.getCommandSpecs()) {
|
||||
if (!spec.standalone()) {
|
||||
continue;
|
||||
@@ -122,52 +326,51 @@ public final class EssentialsC extends JavaPlugin {
|
||||
if (executor == null) {
|
||||
continue;
|
||||
}
|
||||
registerCommandWithAliases(commandMap, spec.name(), executor, spec.aliases().toArray(String[]::new));
|
||||
event.registrar().register(
|
||||
spec.name(),
|
||||
spec.name(),
|
||||
spec.aliases(),
|
||||
new EssentialsBasicCommand(spec.name(), executor)
|
||||
);
|
||||
}
|
||||
|
||||
registerCommandWithAliases(commandMap, "essentialsc", new HelpCommand(), "essc");
|
||||
} catch (Exception e) {
|
||||
getLogger().severe("Failed to register commands: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
event.registrar().register(
|
||||
"essentialsc",
|
||||
"essentialsc",
|
||||
List.of("essc"),
|
||||
new EssentialsBasicCommand("essentialsc", new HelpCommand())
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
private void registerCommandWithAliases(org.bukkit.command.CommandMap commandMap, String name, BaseCommand executor, String... aliases) {
|
||||
Command command = new Command(name) {
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
|
||||
return executor.onCommand(sender, this, commandLabel, args);
|
||||
private static final class EssentialsBasicCommand implements BasicCommand {
|
||||
|
||||
private final String name;
|
||||
private final BaseCommand executor;
|
||||
private final PaperCommand commandAdapter;
|
||||
|
||||
private EssentialsBasicCommand(String name, BaseCommand executor) {
|
||||
this.name = name;
|
||||
this.executor = executor;
|
||||
this.commandAdapter = new PaperCommand(name, executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSourceStack commandSourceStack, String[] args) {
|
||||
CommandSender sender = commandSourceStack.getSender();
|
||||
if (CommandRegistry.resolveCommandName(name) != null && !CommandRegistry.isAvailable(name)) {
|
||||
sender.sendMessage(EssentialsC.getLangManager().getPrefixedString("messages.module-disabled"));
|
||||
return;
|
||||
}
|
||||
executor.onCommand(sender, commandAdapter, name, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.util.List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
|
||||
if (executor instanceof org.bukkit.command.TabCompleter completer) {
|
||||
return completer.onTabComplete(sender, this, alias, args);
|
||||
}
|
||||
return super.tabComplete(sender, alias, args);
|
||||
@Override
|
||||
public Collection<String> suggest(CommandSourceStack commandSourceStack, String[] args) {
|
||||
if (executor instanceof TabCompleter completer) {
|
||||
return completer.onTabComplete(commandSourceStack.getSender(), commandAdapter, name, args);
|
||||
}
|
||||
};
|
||||
|
||||
command.setPermission(executor.getPermission());
|
||||
commandMap.register("", command);
|
||||
|
||||
for (String alias : aliases) {
|
||||
Command aliasCmd = new Command(alias) {
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
|
||||
return executor.onCommand(sender, this, commandLabel, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.util.List<String> tabComplete(CommandSender sender, String label, String[] args) throws IllegalArgumentException {
|
||||
if (executor instanceof org.bukkit.command.TabCompleter completer) {
|
||||
return completer.onTabComplete(sender, this, label, args);
|
||||
}
|
||||
return super.tabComplete(sender, label, args);
|
||||
}
|
||||
};
|
||||
aliasCmd.setPermission(executor.getPermission());
|
||||
commandMap.register("", aliasCmd);
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class LangManager {
|
||||
public String getString(String path) {
|
||||
String value = langFile.getString(path);
|
||||
if (value == null) {
|
||||
return translateColorCodes("&cMissing translation: " + path);
|
||||
return translateColorCodes("&c缺少语言文本: " + path);
|
||||
}
|
||||
return translateColorCodes(value);
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public class LangManager {
|
||||
public List<String> getStringList(String path) {
|
||||
List<String> values = langFile.getStringList(path);
|
||||
if (values.isEmpty()) {
|
||||
values = List.of("&cMissing translation: " + path);
|
||||
values = List.of("&c缺少语言文本: " + path);
|
||||
}
|
||||
|
||||
List<String> translated = new ArrayList<>();
|
||||
@@ -87,12 +87,13 @@ public class LangManager {
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
config.addDefault("config-version", CURRENT_CONFIG_VERSION);
|
||||
config.addDefault("language", "zh_CN");
|
||||
config.addDefault("debug", false);
|
||||
config.options().copyDefaults(true);
|
||||
|
||||
try {
|
||||
config.save(configFile);
|
||||
} catch (Exception e) {
|
||||
plugin.getLogger().severe("Failed to save config.yml: " + e.getMessage());
|
||||
plugin.getLogger().severe("保存 config.yml 失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,22 +104,26 @@ public class LangManager {
|
||||
return;
|
||||
}
|
||||
|
||||
String language = existingConfig.getString("language", "zh_CN");
|
||||
File backupFile = new File(plugin.getDataFolder(),
|
||||
"config.v" + existingVersion + ".bak-" + System.currentTimeMillis() + ".yml");
|
||||
|
||||
try {
|
||||
Files.copy(configFile.toPath(), backupFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
plugin.saveResource("config.yml", true);
|
||||
InputStream defaultConfigStream = plugin.getResource("config.yml");
|
||||
if (defaultConfigStream != null) {
|
||||
YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(
|
||||
new InputStreamReader(defaultConfigStream, StandardCharsets.UTF_8)
|
||||
);
|
||||
existingConfig.setDefaults(defaultConfig);
|
||||
existingConfig.options().copyDefaults(true);
|
||||
}
|
||||
existingConfig.set("config-version", CURRENT_CONFIG_VERSION);
|
||||
existingConfig.save(configFile);
|
||||
|
||||
FileConfiguration newConfig = YamlConfiguration.loadConfiguration(configFile);
|
||||
newConfig.set("language", language);
|
||||
newConfig.save(configFile);
|
||||
|
||||
plugin.getLogger().info("Migrated config.yml from version " + existingVersion
|
||||
+ " to " + CURRENT_CONFIG_VERSION + ". Backup saved to " + backupFile.getName());
|
||||
plugin.getLogger().info("已将 config.yml 从版本 " + existingVersion
|
||||
+ " 迁移到 " + CURRENT_CONFIG_VERSION + ",备份文件: " + backupFile.getName());
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe("Failed to migrate config.yml: " + e.getMessage());
|
||||
plugin.getLogger().severe("迁移 config.yml 失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +132,7 @@ public class LangManager {
|
||||
|
||||
File langFolder = new File(plugin.getDataFolder(), "lang");
|
||||
if (!langFolder.exists() && !langFolder.mkdirs()) {
|
||||
plugin.getLogger().warning("Failed to create language folder: " + langFolder.getAbsolutePath());
|
||||
plugin.getLogger().warning("创建语言文件夹失败: " + langFolder.getAbsolutePath());
|
||||
}
|
||||
|
||||
File langFileObj = new File(langFolder, currentLanguage + ".yml");
|
||||
@@ -135,7 +140,7 @@ public class LangManager {
|
||||
if (plugin.getResource("lang/" + currentLanguage + ".yml") != null) {
|
||||
plugin.saveResource("lang/" + currentLanguage + ".yml", false);
|
||||
} else {
|
||||
plugin.getLogger().warning("Language file not found: " + currentLanguage + ".yml, falling back to en_US");
|
||||
plugin.getLogger().warning("未找到语言文件: " + currentLanguage + ".yml,已回退到 en_US");
|
||||
currentLanguage = "en_US";
|
||||
plugin.saveResource("lang/en_US.yml", false);
|
||||
langFileObj = new File(langFolder, "en_US.yml");
|
||||
|
||||
78
src/main/java/cn/infstar/essentialsC/ModuleManager.java
Normal file
78
src/main/java/cn/infstar/essentialsC/ModuleManager.java
Normal file
@@ -0,0 +1,78 @@
|
||||
package cn.infstar.essentialsC;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class ModuleManager {
|
||||
|
||||
private static final int CURRENT_CONFIG_VERSION = 1;
|
||||
|
||||
public static final String BLOCKS = "blocks";
|
||||
public static final String PLAYER = "player";
|
||||
public static final String ADMIN_MODE = "admin-mode";
|
||||
public static final String TPSBAR = "tpsbar";
|
||||
public static final String JEI_SYNC = "jei-sync";
|
||||
public static final String MOB_DROPS = "mob-drops";
|
||||
public static final String MAINTENANCE = "maintenance";
|
||||
|
||||
private static final Map<String, Boolean> DEFAULT_MODULES = new LinkedHashMap<>();
|
||||
|
||||
static {
|
||||
DEFAULT_MODULES.put(BLOCKS, true);
|
||||
DEFAULT_MODULES.put(PLAYER, true);
|
||||
DEFAULT_MODULES.put(ADMIN_MODE, true);
|
||||
DEFAULT_MODULES.put(TPSBAR, true);
|
||||
DEFAULT_MODULES.put(JEI_SYNC, true);
|
||||
DEFAULT_MODULES.put(MOB_DROPS, false);
|
||||
DEFAULT_MODULES.put(MAINTENANCE, true);
|
||||
}
|
||||
|
||||
private final JavaPlugin plugin;
|
||||
private final File modulesFile;
|
||||
private FileConfiguration modulesConfig;
|
||||
|
||||
public ModuleManager(JavaPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.modulesFile = new File(plugin.getDataFolder(), "modules.yml");
|
||||
reload();
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
if (!modulesFile.exists()) {
|
||||
plugin.saveResource("modules.yml", false);
|
||||
}
|
||||
|
||||
modulesConfig = YamlConfiguration.loadConfiguration(modulesFile);
|
||||
modulesConfig.addDefault("config-version", CURRENT_CONFIG_VERSION);
|
||||
for (Map.Entry<String, Boolean> module : DEFAULT_MODULES.entrySet()) {
|
||||
modulesConfig.addDefault(path(module.getKey()), module.getValue());
|
||||
}
|
||||
modulesConfig.options().copyDefaults(true);
|
||||
save();
|
||||
}
|
||||
|
||||
public boolean isEnabled(String moduleKey) {
|
||||
if (moduleKey == null || moduleKey.isBlank()) {
|
||||
return true;
|
||||
}
|
||||
return modulesConfig.getBoolean(path(moduleKey), true);
|
||||
}
|
||||
|
||||
private String path(String moduleKey) {
|
||||
return "modules." + moduleKey + ".enabled";
|
||||
}
|
||||
|
||||
private void save() {
|
||||
try {
|
||||
modulesConfig.save(modulesFile);
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().warning("保存 modules.yml 失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -328,7 +328,7 @@ public final class AdminModeManager implements Listener {
|
||||
try {
|
||||
data.save(dataFile);
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().warning("Failed to save admin-mode.yml: " + e.getMessage());
|
||||
plugin.getLogger().warning("保存 admin-mode.yml 失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,10 @@ public class AdminCommand extends BaseCommand {
|
||||
|
||||
@Override
|
||||
protected boolean execute(Player player, String[] args) {
|
||||
if (plugin.getAdminModeManager() == null) {
|
||||
player.sendMessage(getLang().getPrefixedString("messages.module-disabled"));
|
||||
return true;
|
||||
}
|
||||
plugin.getAdminModeManager().toggle(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -33,19 +33,17 @@ public abstract class BaseCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
protected void playBlockShortcutSound(Player player, Material material, Sound fallbackSound) {
|
||||
Sound sound = resolvePlaceSound(material);
|
||||
Sound sound = fallbackSound;
|
||||
if (sound == null) {
|
||||
sound = fallbackSound;
|
||||
sound = resolvePlaceSound(material);
|
||||
}
|
||||
|
||||
if (sound != null) {
|
||||
player.playSound(player.getLocation(), sound, 1.0F, 1.0F);
|
||||
}
|
||||
playShortcutSound(player, sound);
|
||||
}
|
||||
|
||||
protected void playShortcutSound(Player player, Sound sound) {
|
||||
if (sound != null) {
|
||||
player.playSound(player.getLocation(), sound, 1.0F, 1.0F);
|
||||
player.playSound(player.getLocation(), sound, 0.65F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -70,6 +71,7 @@ public class BlocksMenuCommand extends BaseCommand implements Listener {
|
||||
return;
|
||||
}
|
||||
player.openInventory(menu);
|
||||
playShortcutSound(player, Sound.UI_BUTTON_CLICK);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -85,6 +87,7 @@ public class BlocksMenuCommand extends BaseCommand implements Listener {
|
||||
}
|
||||
|
||||
player.openInventory(menu);
|
||||
playShortcutSound(player, Sound.UI_BUTTON_CLICK);
|
||||
}
|
||||
|
||||
private int renderSections(Inventory menu, Player player, org.bukkit.configuration.ConfigurationSection sectionsConfig) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cn.infstar.essentialsC.commands;
|
||||
|
||||
import cn.infstar.essentialsC.EssentialsC;
|
||||
import cn.infstar.essentialsC.ModuleManager;
|
||||
import cn.infstar.essentialsC.tpsbar.TpsBarService;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
@@ -20,44 +21,45 @@ public final class CommandRegistry {
|
||||
private static final Set<String> UNAVAILABLE_COMMANDS = new java.util.HashSet<>();
|
||||
|
||||
static {
|
||||
register("workbench", "essentialsc.command.workbench", "cn.infstar.essentialsC.commands.WorkbenchCommand", "wb");
|
||||
register("anvil", "essentialsc.command.anvil", "cn.infstar.essentialsC.commands.AnvilCommand");
|
||||
register("cartographytable", "essentialsc.command.cartographytable", "cn.infstar.essentialsC.commands.CartographyTableCommand", "ct", "cartography");
|
||||
register("grindstone", "essentialsc.command.grindstone", "cn.infstar.essentialsC.commands.GrindstoneCommand", "gs");
|
||||
register("loom", "essentialsc.command.loom", "cn.infstar.essentialsC.commands.LoomCommand");
|
||||
register("smithingtable", "essentialsc.command.smithingtable", "cn.infstar.essentialsC.commands.SmithingTableCommand", "st", "smithing");
|
||||
register("stonecutter", "essentialsc.command.stonecutter", "cn.infstar.essentialsC.commands.StonecutterCommand", "sc");
|
||||
register("enderchest", "essentialsc.command.enderchest", "cn.infstar.essentialsC.commands.EnderChestCommand", "ec");
|
||||
register("blocks", "essentialsc.command.blocks", "cn.infstar.essentialsC.commands.BlocksMenuCommand");
|
||||
register("hat", "essentialsc.command.hat", "cn.infstar.essentialsC.commands.HatCommand");
|
||||
register("suicide", "essentialsc.command.suicide", "cn.infstar.essentialsC.commands.SuicideCommand", "die");
|
||||
register("fly", "essentialsc.command.fly", "cn.infstar.essentialsC.commands.FlyCommand");
|
||||
register("nightvision", "essentialsc.command.nightvision", "cn.infstar.essentialsC.commands.NightVisionCommand", "nv");
|
||||
register("glow", "essentialsc.command.glow", "cn.infstar.essentialsC.commands.GlowCommand");
|
||||
register("heal", "essentialsc.command.heal", "cn.infstar.essentialsC.commands.HealCommand");
|
||||
register("vanish", "essentialsc.command.vanish", "cn.infstar.essentialsC.commands.VanishCommand", "v");
|
||||
register("seen", "essentialsc.command.seen", "cn.infstar.essentialsC.commands.SeenCommand", "info");
|
||||
register("feed", "essentialsc.command.feed", "cn.infstar.essentialsC.commands.FeedCommand");
|
||||
register("repair", "essentialsc.command.repair", "cn.infstar.essentialsC.commands.RepairCommand", "rep");
|
||||
register("tpsbar", "essentialsc.command.tpsbar", "cn.infstar.essentialsC.commands.TpsBarCommand");
|
||||
register("mobdrops", "essentialsc.mobdrops.enderman", "cn.infstar.essentialsC.commands.MobDropCommand");
|
||||
registerSubCommand("admin", "essentialsc.command.admin", "cn.infstar.essentialsC.commands.AdminCommand");
|
||||
register("workbench", "essentialsc.command.workbench", ModuleManager.BLOCKS, "cn.infstar.essentialsC.commands.WorkbenchCommand", "wb");
|
||||
register("anvil", "essentialsc.command.anvil", ModuleManager.BLOCKS, "cn.infstar.essentialsC.commands.AnvilCommand");
|
||||
register("cartographytable", "essentialsc.command.cartographytable", ModuleManager.BLOCKS, "cn.infstar.essentialsC.commands.CartographyTableCommand", "ct", "cartography");
|
||||
register("grindstone", "essentialsc.command.grindstone", ModuleManager.BLOCKS, "cn.infstar.essentialsC.commands.GrindstoneCommand", "gs");
|
||||
register("loom", "essentialsc.command.loom", ModuleManager.BLOCKS, "cn.infstar.essentialsC.commands.LoomCommand");
|
||||
register("smithingtable", "essentialsc.command.smithingtable", ModuleManager.BLOCKS, "cn.infstar.essentialsC.commands.SmithingTableCommand", "st", "smithing");
|
||||
register("stonecutter", "essentialsc.command.stonecutter", ModuleManager.BLOCKS, "cn.infstar.essentialsC.commands.StonecutterCommand", "sc");
|
||||
register("enderchest", "essentialsc.command.enderchest", ModuleManager.BLOCKS, "cn.infstar.essentialsC.commands.EnderChestCommand", "ec");
|
||||
register("blocks", "essentialsc.command.blocks", ModuleManager.BLOCKS, "cn.infstar.essentialsC.commands.BlocksMenuCommand");
|
||||
register("hat", "essentialsc.command.hat", ModuleManager.PLAYER, "cn.infstar.essentialsC.commands.HatCommand");
|
||||
register("suicide", "essentialsc.command.suicide", ModuleManager.PLAYER, "cn.infstar.essentialsC.commands.SuicideCommand", "die");
|
||||
register("fly", "essentialsc.command.fly", ModuleManager.PLAYER, "cn.infstar.essentialsC.commands.FlyCommand");
|
||||
register("nightvision", "essentialsc.command.nightvision", ModuleManager.PLAYER, "cn.infstar.essentialsC.commands.NightVisionCommand", "nv");
|
||||
register("glow", "essentialsc.command.glow", ModuleManager.PLAYER, "cn.infstar.essentialsC.commands.GlowCommand");
|
||||
register("heal", "essentialsc.command.heal", ModuleManager.PLAYER, "cn.infstar.essentialsC.commands.HealCommand");
|
||||
register("vanish", "essentialsc.command.vanish", ModuleManager.PLAYER, "cn.infstar.essentialsC.commands.VanishCommand", "v");
|
||||
register("seen", "essentialsc.command.seen", ModuleManager.PLAYER, "cn.infstar.essentialsC.commands.SeenCommand", "info");
|
||||
register("feed", "essentialsc.command.feed", ModuleManager.PLAYER, "cn.infstar.essentialsC.commands.FeedCommand");
|
||||
register("repair", "essentialsc.command.repair", ModuleManager.PLAYER, "cn.infstar.essentialsC.commands.RepairCommand", "rep");
|
||||
register("tpsbar", "essentialsc.command.tpsbar", ModuleManager.TPSBAR, "cn.infstar.essentialsC.commands.TpsBarCommand");
|
||||
register("mobdrops", "essentialsc.mobdrops.enderman", ModuleManager.MOB_DROPS, "cn.infstar.essentialsC.commands.MobDropCommand");
|
||||
register("maintenance", "essentialsc.command.maintenance", ModuleManager.MAINTENANCE, "cn.infstar.essentialsC.commands.MaintenanceCommand", "maint");
|
||||
registerSubCommand("admin", "essentialsc.command.admin", ModuleManager.ADMIN_MODE, "cn.infstar.essentialsC.commands.AdminCommand");
|
||||
}
|
||||
|
||||
private CommandRegistry() {
|
||||
}
|
||||
|
||||
private static void register(String name, String permission, String className, String... aliases) {
|
||||
register(name, permission, className, true, aliases);
|
||||
private static void register(String name, String permission, String moduleKey, String className, String... aliases) {
|
||||
register(name, permission, moduleKey, className, true, aliases);
|
||||
}
|
||||
|
||||
private static void registerSubCommand(String name, String permission, String className, String... aliases) {
|
||||
register(name, permission, className, false, aliases);
|
||||
private static void registerSubCommand(String name, String permission, String moduleKey, String className, String... aliases) {
|
||||
register(name, permission, moduleKey, className, false, aliases);
|
||||
}
|
||||
|
||||
private static void register(String name, String permission, String className, boolean standalone, String... aliases) {
|
||||
private static void register(String name, String permission, String moduleKey, String className, boolean standalone, String... aliases) {
|
||||
List<String> aliasList = List.of(aliases);
|
||||
CommandSpec spec = new CommandSpec(name, permission, className, aliasList, standalone);
|
||||
CommandSpec spec = new CommandSpec(name, permission, moduleKey, className, aliasList, standalone);
|
||||
COMMANDS.put(name, spec);
|
||||
ALIAS_TO_COMMAND.put(name, name);
|
||||
for (String alias : aliasList) {
|
||||
@@ -91,6 +93,10 @@ public final class CommandRegistry {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isRuntimeDisabled(resolvedName)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
BaseCommand cached = COMMAND_CACHE.get(resolvedName);
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
@@ -98,9 +104,6 @@ public final class CommandRegistry {
|
||||
if (UNAVAILABLE_COMMANDS.contains(resolvedName)) {
|
||||
return null;
|
||||
}
|
||||
if (isRuntimeDisabled(resolvedName)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
CommandSpec spec = COMMANDS.get(resolvedName);
|
||||
if (spec == null) {
|
||||
@@ -125,6 +128,21 @@ public final class CommandRegistry {
|
||||
}
|
||||
|
||||
private static boolean isRuntimeDisabled(String resolvedName) {
|
||||
CommandSpec spec = COMMANDS.get(resolvedName);
|
||||
if (spec == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
EssentialsC plugin = EssentialsC.getPlugin(EssentialsC.class);
|
||||
ModuleManager moduleManager = plugin.getModuleManager();
|
||||
if (moduleManager != null && !moduleManager.isEnabled(spec.moduleKey())) {
|
||||
return true;
|
||||
}
|
||||
} catch (IllegalStateException ignored) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!"tpsbar".equals(resolvedName)) {
|
||||
return false;
|
||||
}
|
||||
@@ -138,6 +156,11 @@ public final class CommandRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
public record CommandSpec(String name, String permission, String className, List<String> aliases, boolean standalone) {
|
||||
public static void clearCache() {
|
||||
COMMAND_CACHE.clear();
|
||||
UNAVAILABLE_COMMANDS.clear();
|
||||
}
|
||||
|
||||
public record CommandSpec(String name, String permission, String moduleKey, String className, List<String> aliases, boolean standalone) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package cn.infstar.essentialsC.commands;
|
||||
|
||||
import cn.infstar.essentialsC.EssentialsC;
|
||||
import cn.infstar.essentialsC.LangManager;
|
||||
import cn.infstar.essentialsC.tpsbar.TpsBarService;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -34,10 +33,9 @@ public class HelpCommand extends BaseCommand implements TabCompleter {
|
||||
}
|
||||
plugin.reloadConfig();
|
||||
EssentialsC.getLangManager().reload();
|
||||
TpsBarService tpsBarService = plugin.getTpsBarManager();
|
||||
if (tpsBarService != null) {
|
||||
tpsBarService.reloadSettings();
|
||||
}
|
||||
plugin.getModuleManager().reload();
|
||||
CommandRegistry.clearCache();
|
||||
plugin.reloadRuntimeModules();
|
||||
sender.sendMessage(getLang().getPrefixedString("messages.config-reloaded"));
|
||||
return true;
|
||||
}
|
||||
@@ -56,10 +54,9 @@ public class HelpCommand extends BaseCommand implements TabCompleter {
|
||||
}
|
||||
plugin.reloadConfig();
|
||||
EssentialsC.getLangManager().reload();
|
||||
TpsBarService tpsBarService = plugin.getTpsBarManager();
|
||||
if (tpsBarService != null) {
|
||||
tpsBarService.reloadSettings();
|
||||
}
|
||||
plugin.getModuleManager().reload();
|
||||
CommandRegistry.clearCache();
|
||||
plugin.reloadRuntimeModules();
|
||||
sender.sendMessage(getLang().getPrefixedString("messages.config-reloaded"));
|
||||
return true;
|
||||
}
|
||||
@@ -188,6 +185,10 @@ public class HelpCommand extends BaseCommand implements TabCompleter {
|
||||
otherCommands.append(lang.getString("help.commands.tpsbar")).append("\n");
|
||||
hasOtherCommands = true;
|
||||
}
|
||||
if (CommandRegistry.isAvailable("maintenance") && player.hasPermission("essentialsc.command.maintenance")) {
|
||||
otherCommands.append(lang.getString("help.commands.maintenance")).append("\n");
|
||||
hasOtherCommands = true;
|
||||
}
|
||||
|
||||
if (hasOtherCommands) {
|
||||
sendPrefixed(player, lang.getString("help.section-other"));
|
||||
@@ -259,6 +260,8 @@ public class HelpCommand extends BaseCommand implements TabCompleter {
|
||||
{"repair", "essentialsc.command.repair"},
|
||||
{"rep", "essentialsc.command.repair"},
|
||||
{"tpsbar", "essentialsc.command.tpsbar"},
|
||||
{"maintenance", "essentialsc.command.maintenance"},
|
||||
{"maint", "essentialsc.command.maintenance"},
|
||||
{"mobdrops", "essentialsc.mobdrops.enderman"},
|
||||
{"admin", "essentialsc.command.admin"},
|
||||
{"version", null},
|
||||
@@ -311,6 +314,11 @@ public class HelpCommand extends BaseCommand implements TabCompleter {
|
||||
}
|
||||
return players;
|
||||
}
|
||||
|
||||
if ((subCmd.equals("maintenance") || subCmd.equals("maint"))
|
||||
&& sender.hasPermission("essentialsc.command.maintenance")) {
|
||||
return completeMaintenanceArgs(args[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return new ArrayList<>();
|
||||
@@ -326,4 +334,15 @@ public class HelpCommand extends BaseCommand implements TabCompleter {
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
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" -> {
|
||||
maintenanceManager.setEnabled(true);
|
||||
sender.sendMessage(getLang().getPrefixedString("maintenance.messages.enabled"));
|
||||
return true;
|
||||
}
|
||||
case "off", "disable", "disabled" -> {
|
||||
maintenanceManager.setEnabled(false);
|
||||
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];
|
||||
if (maintenanceManager.addWhitelistEntry(target)) {
|
||||
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];
|
||||
if (maintenanceManager.removeWhitelistEntry(target)) {
|
||||
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)
|
||||
)));
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
@@ -30,26 +30,26 @@ public class SeenCommand extends BaseCommand {
|
||||
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
StringBuilder info = new StringBuilder();
|
||||
info.append(getLang().getPrefix()).append(ChatColor.GOLD).append("Player info: ")
|
||||
info.append(getLang().getPrefix()).append(ChatColor.GOLD).append("玩家信息: ")
|
||||
.append(ChatColor.WHITE).append(target.getName()).append("\n");
|
||||
|
||||
if (target.isOnline()) {
|
||||
info.append(ChatColor.GRAY).append("Status: ").append(ChatColor.GREEN).append("Online").append("\n");
|
||||
info.append(ChatColor.GRAY).append("状态: ").append(ChatColor.GREEN).append("在线").append("\n");
|
||||
Player onlinePlayer = target.getPlayer();
|
||||
if (onlinePlayer != null) {
|
||||
info.append(ChatColor.GRAY).append("World: ").append(ChatColor.WHITE)
|
||||
info.append(ChatColor.GRAY).append("所在世界: ").append(ChatColor.WHITE)
|
||||
.append(onlinePlayer.getWorld().getName()).append("\n");
|
||||
}
|
||||
} else {
|
||||
info.append(ChatColor.GRAY).append("Status: ").append(ChatColor.RED).append("Offline").append("\n");
|
||||
info.append(ChatColor.GRAY).append("状态: ").append(ChatColor.RED).append("离线").append("\n");
|
||||
long lastSeen = target.getLastSeen();
|
||||
if (lastSeen > 0) {
|
||||
info.append(ChatColor.GRAY).append("Last seen: ").append(ChatColor.WHITE)
|
||||
info.append(ChatColor.GRAY).append("最后在线: ").append(ChatColor.WHITE)
|
||||
.append(format.format(new Date(lastSeen))).append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
info.append(ChatColor.GRAY).append("First joined: ").append(ChatColor.WHITE)
|
||||
info.append(ChatColor.GRAY).append("首次加入: ").append(ChatColor.WHITE)
|
||||
.append(format.format(new Date(target.getFirstPlayed())));
|
||||
|
||||
player.sendMessage(info.toString());
|
||||
|
||||
@@ -22,7 +22,7 @@ public class TpsBarCommand extends BaseCommand implements TabCompleter {
|
||||
protected boolean execute(Player player, String[] args) {
|
||||
TpsBarService tpsBarService = plugin.getTpsBarManager();
|
||||
if (tpsBarService == null) {
|
||||
player.sendMessage(getLang().getPrefixedString("messages.player-only"));
|
||||
player.sendMessage(getLang().getPrefixedString("messages.module-disabled"));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.infstar.essentialsC.commands;
|
||||
|
||||
import cn.infstar.essentialsC.EssentialsC;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashSet;
|
||||
@@ -20,17 +21,38 @@ public class VanishCommand extends BaseCommand {
|
||||
|
||||
if (vanishedPlayers.contains(uuid)) {
|
||||
vanishedPlayers.remove(uuid);
|
||||
showPlayerToAll(player);
|
||||
showPlayerToAll(plugin, player);
|
||||
player.sendMessage(getLang().getPrefixedString("messages.vanish-disabled"));
|
||||
} else {
|
||||
vanishedPlayers.add(uuid);
|
||||
hidePlayerFromAll(player);
|
||||
hidePlayerFromAll(plugin, player);
|
||||
player.sendMessage(getLang().getPrefixedString("messages.vanish-enabled"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void hidePlayerFromAll(Player player) {
|
||||
public static void hideVanishedPlayersFrom(EssentialsC plugin, Player observer) {
|
||||
for (Player vanished : plugin.getServer().getOnlinePlayers()) {
|
||||
if (!observer.equals(vanished) && isVanished(vanished)) {
|
||||
observer.hidePlayer(plugin, vanished);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeVanished(Player player) {
|
||||
vanishedPlayers.remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static void clearAll(EssentialsC plugin) {
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
if (isVanished(player)) {
|
||||
showPlayerToAll(plugin, player);
|
||||
}
|
||||
}
|
||||
vanishedPlayers.clear();
|
||||
}
|
||||
|
||||
private static void hidePlayerFromAll(EssentialsC plugin, Player player) {
|
||||
for (Player online : player.getServer().getOnlinePlayers()) {
|
||||
if (online != player) {
|
||||
online.hidePlayer(plugin, player);
|
||||
@@ -38,7 +60,7 @@ public class VanishCommand extends BaseCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private void showPlayerToAll(Player player) {
|
||||
private static void showPlayerToAll(EssentialsC plugin, Player player) {
|
||||
for (Player online : player.getServer().getOnlinePlayers()) {
|
||||
if (online != player) {
|
||||
online.showPlayer(plugin, player);
|
||||
|
||||
@@ -13,7 +13,7 @@ public class WorkbenchCommand extends BaseCommand {
|
||||
@Override
|
||||
protected boolean execute(Player player, String[] args) {
|
||||
player.openWorkbench(null, true);
|
||||
playBlockShortcutSound(player, Material.CRAFTING_TABLE, Sound.BLOCK_CRAFTER_CRAFT);
|
||||
playBlockShortcutSound(player, Material.CRAFTING_TABLE, Sound.UI_BUTTON_CLICK);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* 为 Fabric / NeoForge 客户端补发配方同步数据,修复 1.21.2+ 的 JEI 配方显示问题。
|
||||
@@ -32,14 +33,20 @@ public class JeiRecipeSyncListener implements Listener {
|
||||
private final boolean enabled;
|
||||
private final boolean debug;
|
||||
private final boolean sendPlayerMessage;
|
||||
private final int brandCheckDelayTicks;
|
||||
|
||||
public JeiRecipeSyncListener(EssentialsC plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
FileConfiguration config = plugin.getConfig();
|
||||
config.addDefault("jei-sync.brand-check-delay-ticks", 20);
|
||||
config.options().copyDefaults(true);
|
||||
plugin.saveConfig();
|
||||
|
||||
this.enabled = config.getBoolean("jei-sync.enabled", true);
|
||||
this.debug = config.getBoolean("jei-sync.debug", false);
|
||||
this.debug = config.getBoolean("jei-sync.debug", config.getBoolean("debug", false));
|
||||
this.sendPlayerMessage = config.getBoolean("jei-sync.send-player-message", true);
|
||||
this.brandCheckDelayTicks = Math.max(0, config.getInt("jei-sync.brand-check-delay-ticks", 20));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -49,14 +56,20 @@ public class JeiRecipeSyncListener implements Listener {
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
plugin.getServer().getScheduler().runTaskLater(plugin, () -> detectAndSync(player), brandCheckDelayTicks);
|
||||
}
|
||||
|
||||
private void detectAndSync(Player player) {
|
||||
if (!player.isOnline()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String clientBrand = player.getClientBrandName();
|
||||
|
||||
if (debug) {
|
||||
plugin.getLogger().info("========================================");
|
||||
plugin.getLogger().info("玩家 " + player.getName() + " 加入");
|
||||
plugin.getLogger().info("客户端品牌: '" + (clientBrand != null ? clientBrand : "null") + "'");
|
||||
plugin.getLogger().info("JEI 同步功能: " + (enabled ? "启用" : "禁用"));
|
||||
plugin.getLogger().info("========================================");
|
||||
plugin.getLogger().info("JEI 客户端检测: player=" + player.getName()
|
||||
+ ", brand=" + (clientBrand == null || clientBrand.isBlank() ? "unknown" : clientBrand)
|
||||
+ ", delayTicks=" + brandCheckDelayTicks);
|
||||
}
|
||||
|
||||
if (clientBrand == null || clientBrand.isEmpty()) {
|
||||
@@ -66,7 +79,7 @@ public class JeiRecipeSyncListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
String brandLower = clientBrand.toLowerCase();
|
||||
String brandLower = clientBrand.toLowerCase(Locale.ROOT);
|
||||
if (brandLower.contains("fabric")) {
|
||||
if (debug) {
|
||||
plugin.getLogger().info("检测到 Fabric 客户端,开始发送配方同步...");
|
||||
|
||||
@@ -274,12 +274,12 @@ public class ShulkerBoxListener implements Listener {
|
||||
|
||||
private void writeInventoryBack(ItemStack shulkerItem, ItemStack[] contents) {
|
||||
if (!(shulkerItem.getItemMeta() instanceof BlockStateMeta blockStateMeta)) {
|
||||
plugin.getLogger().warning("Failed to save shulker box contents: missing BlockStateMeta.");
|
||||
plugin.getLogger().warning("保存潜影盒内容失败: 缺少 BlockStateMeta。");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(blockStateMeta.getBlockState() instanceof ShulkerBox shulkerBox)) {
|
||||
plugin.getLogger().warning("Failed to save shulker box contents: block state is not a ShulkerBox.");
|
||||
plugin.getLogger().warning("保存潜影盒内容失败: 方块状态不是 ShulkerBox。");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package cn.infstar.essentialsC.listeners;
|
||||
|
||||
import cn.infstar.essentialsC.EssentialsC;
|
||||
import cn.infstar.essentialsC.commands.VanishCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public final class VanishListener implements Listener {
|
||||
|
||||
private final EssentialsC plugin;
|
||||
|
||||
public VanishListener(EssentialsC plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
VanishCommand.hideVanishedPlayersFrom(plugin, event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
VanishCommand.removeVanished(player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
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.Listener;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.server.ServerListPingEvent;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.Map;
|
||||
|
||||
public final class MaintenanceListener implements Listener {
|
||||
|
||||
private final EssentialsC plugin;
|
||||
|
||||
public MaintenanceListener(EssentialsC plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onServerListPing(ServerListPingEvent event) {
|
||||
MaintenanceManager maintenanceManager = plugin.getMaintenanceManager();
|
||||
if (!plugin.getModuleManager().isEnabled(ModuleManager.MAINTENANCE)
|
||||
|| maintenanceManager == null
|
||||
|| !maintenanceManager.isEnabled()
|
||||
|| !maintenanceManager.isMotdEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setMotd(maintenanceManager.getMotd());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
MaintenanceManager maintenanceManager = plugin.getMaintenanceManager();
|
||||
if (!plugin.getModuleManager().isEnabled(ModuleManager.MAINTENANCE)
|
||||
|| maintenanceManager == null
|
||||
|| !maintenanceManager.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (maintenanceManager.canJoin(event.getPlayer())) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, maintenanceManager.getKickMessage());
|
||||
notifyBlockedLogin(event, maintenanceManager);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
MaintenanceManager maintenanceManager = plugin.getMaintenanceManager();
|
||||
if (!plugin.getModuleManager().isEnabled(ModuleManager.MAINTENANCE) || maintenanceManager == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
maintenanceManager.addBossBarPlayer(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
MaintenanceManager maintenanceManager = plugin.getMaintenanceManager();
|
||||
if (maintenanceManager != null) {
|
||||
maintenanceManager.removeBossBarPlayer(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyBlockedLogin(PlayerLoginEvent event, MaintenanceManager maintenanceManager) {
|
||||
if (!maintenanceManager.isNotifyEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String address = "";
|
||||
InetAddress inetAddress = event.getAddress();
|
||||
if (inetAddress != null) {
|
||||
address = inetAddress.getHostAddress();
|
||||
}
|
||||
|
||||
String message = EssentialsC.getLangManager().getPrefixedString("maintenance.messages.login-blocked",
|
||||
Map.of(
|
||||
"player", event.getPlayer().getName(),
|
||||
"uuid", event.getPlayer().getUniqueId().toString(),
|
||||
"address", address
|
||||
));
|
||||
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
if (player.hasPermission(maintenanceManager.getNotifyPermission())) {
|
||||
player.sendMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,321 @@
|
||||
package cn.infstar.essentialsC.maintenance;
|
||||
|
||||
import cn.infstar.essentialsC.EssentialsC;
|
||||
import org.bukkit.ChatColor;
|
||||
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.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
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 final EssentialsC plugin;
|
||||
private final File configFile;
|
||||
private FileConfiguration config;
|
||||
private BossBar bossBar;
|
||||
|
||||
public MaintenanceManager(EssentialsC plugin) {
|
||||
this.plugin = plugin;
|
||||
this.configFile = new File(plugin.getDataFolder(), "maintenance.yml");
|
||||
reload();
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
if (!configFile.exists()) {
|
||||
plugin.saveResource("maintenance.yml", false);
|
||||
}
|
||||
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
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("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);
|
||||
save();
|
||||
refreshBossBar();
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return config.getBoolean("enabled", false);
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
config.set("enabled", enabled);
|
||||
save();
|
||||
refreshBossBar();
|
||||
}
|
||||
|
||||
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 canJoin(Player player) {
|
||||
return player != null && (player.hasPermission(getBypassPermission()) || isWhitelisted(player));
|
||||
}
|
||||
|
||||
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 boolean addWhitelistEntry(String input) {
|
||||
String normalized = normalizeEntry(input);
|
||||
if (normalized.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
UUID uuid = parseUuid(normalized);
|
||||
if (uuid != null) {
|
||||
return addWhitelistUuid(uuid.toString());
|
||||
}
|
||||
|
||||
return addWhitelistName(input);
|
||||
}
|
||||
|
||||
public boolean removeWhitelistEntry(String input) {
|
||||
String normalized = normalizeEntry(input);
|
||||
if (normalized.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
UUID uuid = parseUuid(normalized);
|
||||
if (uuid != null) {
|
||||
return removeWhitelistUuid(uuid.toString());
|
||||
}
|
||||
|
||||
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 String getMotd() {
|
||||
return colorizeLines(config.getStringList("motd.lines"));
|
||||
}
|
||||
|
||||
public String getKickMessage() {
|
||||
return colorizeLines(config.getStringList("kick-message"));
|
||||
}
|
||||
|
||||
public void refreshBossBar() {
|
||||
clearBossBar();
|
||||
if (!isEnabled() || !isBossBarEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
bossBar = plugin.getServer().createBossBar(
|
||||
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;
|
||||
}
|
||||
if (canJoin(player)) {
|
||||
bossBar.removePlayer(player);
|
||||
return;
|
||||
}
|
||||
bossBar.addPlayer(player);
|
||||
}
|
||||
|
||||
public void removeBossBarPlayer(Player player) {
|
||||
if (bossBar != null && player != null) {
|
||||
bossBar.removePlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
clearBossBar();
|
||||
}
|
||||
|
||||
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 boolean addWhitelistUuid(String uuid) {
|
||||
return updateWhitelist("whitelist.uuids", uuid.toLowerCase(Locale.ROOT), true);
|
||||
}
|
||||
|
||||
private boolean addWhitelistName(String name) {
|
||||
return updateWhitelist("whitelist.names", normalizeName(name), true);
|
||||
}
|
||||
|
||||
private boolean removeWhitelistUuid(String uuid) {
|
||||
return updateWhitelist("whitelist.uuids", uuid.toLowerCase(Locale.ROOT), false);
|
||||
}
|
||||
|
||||
private boolean removeWhitelistName(String name) {
|
||||
return updateWhitelist("whitelist.names", normalizeName(name), false);
|
||||
}
|
||||
|
||||
private boolean updateWhitelist(String path, String value, boolean add) {
|
||||
if (value == null || value.isBlank()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Set<String> entries = path.endsWith(".names") ? getWhitelistNames() : getWhitelistUuids();
|
||||
boolean changed;
|
||||
if (add) {
|
||||
changed = entries.add(value);
|
||||
} else {
|
||||
changed = entries.remove(value);
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
config.set(path, new ArrayList<>(entries));
|
||||
save();
|
||||
refreshBossBar();
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
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 String colorizeLines(List<String> lines) {
|
||||
if (lines == null || lines.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return String.join("\n", lines.stream()
|
||||
.map(this::colorize)
|
||||
.toList());
|
||||
}
|
||||
|
||||
private String colorize(String text) {
|
||||
return ChatColor.translateAlternateColorCodes('&', text == null ? "" : text);
|
||||
}
|
||||
|
||||
private void save() {
|
||||
try {
|
||||
config.save(configFile);
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().warning("保存 maintenance.yml 失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,9 @@ config-version: 2
|
||||
# 语言文件名称,对应插件数据目录下 lang/<语言名>.yml
|
||||
language: "zh_CN"
|
||||
|
||||
# 是否输出更详细的调试日志。
|
||||
debug: false
|
||||
|
||||
admin-mode:
|
||||
# 原版默认飞行速度为 0.1,这里 0.2 表示两倍飞行速度
|
||||
fly-speed: 0.2
|
||||
@@ -18,6 +21,8 @@ jei-sync:
|
||||
enabled: true
|
||||
# 是否输出调试日志
|
||||
debug: false
|
||||
# 玩家加入后延迟多少 tick 再检测客户端品牌,避免品牌信息尚未同步完成。
|
||||
brand-check-delay-ticks: 20
|
||||
# 是否在玩家加入时发送同步提示
|
||||
send-player-message: true
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ messages:
|
||||
paper-version: "&7Running on Paper {version}"
|
||||
unknown-subcommand: "&cUnknown subcommand: {command}"
|
||||
help-usage: "&7Use &f/essc help &7to view available commands."
|
||||
module-disabled: "&cThis feature module is currently disabled. Please contact an administrator."
|
||||
blocks-menu-empty: "&cYou do not currently have any available shortcut menu entries."
|
||||
|
||||
hat-success: "&aYou are now wearing {item} on your head!"
|
||||
@@ -83,6 +84,7 @@ help:
|
||||
repair: " &f/repair &7- Repair held or all items"
|
||||
admin: " &f/essc admin &7- Toggle admin mode"
|
||||
tpsbar: " &f/tpsbar [player] &7- Toggle TPS boss bar"
|
||||
maintenance: " &f/maintenance <on|off|status|reload|add|remove|list> &7- Manage maintenance mode"
|
||||
|
||||
blocks-menu:
|
||||
title: "&6&lEssentialsC &8- &e&lShortcut Menu"
|
||||
@@ -169,3 +171,23 @@ mobdrops-menu:
|
||||
name: "&dEnderman Drops"
|
||||
status: "&7Current status: {status}"
|
||||
toggle: "&eClick to toggle"
|
||||
|
||||
maintenance:
|
||||
status:
|
||||
enabled: "&cEnabled"
|
||||
disabled: "&aDisabled"
|
||||
messages:
|
||||
enabled: "&aMaintenance mode enabled."
|
||||
disabled: "&cMaintenance mode disabled."
|
||||
reloaded: "&aMaintenance configuration reloaded."
|
||||
status: "&7Maintenance mode status: {status} &8| &7Whitelist: &f{whitelist_count}"
|
||||
usage: "&cUsage: /maintenance <on|off|status|reload|add|remove|list>"
|
||||
add-usage: "&cUsage: /maintenance add <player|uuid>"
|
||||
remove-usage: "&cUsage: /maintenance remove <player|uuid>"
|
||||
whitelist-added: "&aAdded {player} to the maintenance whitelist."
|
||||
whitelist-removed: "&aRemoved {player} from the maintenance whitelist."
|
||||
whitelist-exists: "&e{player} is already on the maintenance whitelist."
|
||||
whitelist-missing: "&c{player} is not on the maintenance whitelist."
|
||||
whitelist-empty: "&7The maintenance whitelist is empty."
|
||||
whitelist-list: "&7Maintenance whitelist ({count}): &f{entries}"
|
||||
login-blocked: "&e{player} was blocked by maintenance mode. &7UUID: {uuid} &8| &7IP: {address}"
|
||||
|
||||
@@ -10,6 +10,7 @@ messages:
|
||||
paper-version: "&7当前运行于 Paper {version}"
|
||||
unknown-subcommand: "&c未知子命令:{command}"
|
||||
help-usage: "&7使用 &f/essc help &7查看可用命令。"
|
||||
module-disabled: "&c该功能模块当前已关闭,请联系管理员。"
|
||||
blocks-menu-empty: "&c你当前没有可用的便捷菜单项目。"
|
||||
|
||||
hat-success: "&a你已将 {item} 戴在头上!"
|
||||
@@ -83,6 +84,7 @@ help:
|
||||
repair: " &f/repair &7- 修复手中或全部物品"
|
||||
admin: " &f/essc admin &7- 切换管理模式"
|
||||
tpsbar: " &f/tpsbar [玩家] &7- 切换 TPS 状态栏"
|
||||
maintenance: " &f/maintenance <on|off|status|reload|add|remove|list> &7- 管理维护模式"
|
||||
|
||||
blocks-menu:
|
||||
title: "&6&lEssentialsC &8- &e&l便捷菜单"
|
||||
@@ -169,3 +171,23 @@ mobdrops-menu:
|
||||
name: "&d末影人掉落"
|
||||
status: "&7当前状态:{status}"
|
||||
toggle: "&e点击切换"
|
||||
|
||||
maintenance:
|
||||
status:
|
||||
enabled: "&c开启"
|
||||
disabled: "&a关闭"
|
||||
messages:
|
||||
enabled: "&a维护模式已开启。"
|
||||
disabled: "&c维护模式已关闭。"
|
||||
reloaded: "&a维护模式配置已重载。"
|
||||
status: "&7维护模式当前状态:{status} &8| &7白名单:&f{whitelist_count}"
|
||||
usage: "&c用法:/maintenance <on|off|status|reload|add|remove|list>"
|
||||
add-usage: "&c用法:/maintenance add <玩家|UUID>"
|
||||
remove-usage: "&c用法:/maintenance remove <玩家|UUID>"
|
||||
whitelist-added: "&a已将 {player} 加入维护白名单。"
|
||||
whitelist-removed: "&a已将 {player} 移出维护白名单。"
|
||||
whitelist-exists: "&e{player} 已在维护白名单中。"
|
||||
whitelist-missing: "&c{player} 不在维护白名单中。"
|
||||
whitelist-empty: "&7维护白名单为空。"
|
||||
whitelist-list: "&7维护白名单({count}):&f{entries}"
|
||||
login-blocked: "&e{player} 被维护模式拦截。&7UUID:{uuid} &8| &7IP:{address}"
|
||||
|
||||
43
src/main/resources/maintenance.yml
Normal file
43
src/main/resources/maintenance.yml
Normal file
@@ -0,0 +1,43 @@
|
||||
# EssentialsC 维护模式配置
|
||||
|
||||
config-version: 1
|
||||
|
||||
# 是否开启维护模式。
|
||||
enabled: false
|
||||
|
||||
# 拥有该权限的玩家可以在维护模式下进入服务器。
|
||||
bypass-permission: "essentialsc.maintenance.bypass"
|
||||
|
||||
notify:
|
||||
# 玩家因维护模式被拒绝进入时,是否通知在线管理员。
|
||||
enabled: true
|
||||
# 拥有该权限的在线玩家会收到拦截通知。
|
||||
permission: "essentialsc.maintenance.notify"
|
||||
|
||||
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
|
||||
32
src/main/resources/modules.yml
Normal file
32
src/main/resources/modules.yml
Normal file
@@ -0,0 +1,32 @@
|
||||
# EssentialsC 模块配置
|
||||
#
|
||||
# modules.yml 用于控制功能模块是否在运行时加载。
|
||||
# config.yml 仍然用于控制已启用模块内部的具体行为。
|
||||
#
|
||||
# 修改模块开关后可使用 /essc reload 刷新运行期服务和监听器。
|
||||
# 直连命令的完整热增删仍建议通过重启服务器完成。
|
||||
|
||||
config-version: 1
|
||||
|
||||
modules:
|
||||
blocks:
|
||||
# 工作台、铁砧等便捷方块命令、/essc blocks 菜单和潜影盒快捷打开。
|
||||
enabled: true
|
||||
player:
|
||||
# 玩家常用命令:飞行、夜视、发光、治疗、喂食、修复、帽子、自杀、隐身和查询玩家。
|
||||
enabled: true
|
||||
admin-mode:
|
||||
# /essc admin 管理模式,以及独立背包和状态管理。
|
||||
enabled: true
|
||||
tpsbar:
|
||||
# 插件版 TPSBar。config.yml 中的 tpsbar.mode 仍会决定遇到原生 /tpsbar 时的行为。
|
||||
enabled: true
|
||||
jei-sync:
|
||||
# Fabric / NeoForge JEI 配方同步兼容修复。
|
||||
enabled: true
|
||||
mob-drops:
|
||||
# 末影人掉落控制菜单和监听器。默认关闭,用于保留过去标准版的行为。
|
||||
enabled: false
|
||||
maintenance:
|
||||
# 维护模式。开启维护后可替换 MOTD,并阻止无绕过权限的玩家进入。
|
||||
enabled: true
|
||||
@@ -1,5 +1,5 @@
|
||||
name: EssentialsC
|
||||
description: 适用于 Paper 服务端的轻量基础插件。
|
||||
description: 适用于 Paper 服务端的轻量基础功能插件。
|
||||
version: ${version}
|
||||
|
||||
main: cn.infstar.essentialsC.EssentialsC
|
||||
@@ -69,7 +69,7 @@ permissions:
|
||||
description: 允许使用 /feed
|
||||
default: op
|
||||
essentialsc.command.feed.others:
|
||||
description: 允许为其他玩家补食
|
||||
description: 允许为其他玩家补充饥饿值
|
||||
default: op
|
||||
essentialsc.command.repair:
|
||||
description: 允许使用 /repair
|
||||
@@ -86,11 +86,26 @@ permissions:
|
||||
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.maintenance:
|
||||
description: 允许管理维护模式
|
||||
default: op
|
||||
essentialsc.maintenance.bypass:
|
||||
description: 允许在维护模式下进入服务器
|
||||
default: op
|
||||
essentialsc.maintenance.notify:
|
||||
description: 允许接收维护模式拦截通知
|
||||
default: op
|
||||
essentialsc.shulkerbox.open:
|
||||
description: 允许通过 Shift+右键快捷打开潜影盒
|
||||
default: op
|
||||
essentialsc.mobdrops.enderman:
|
||||
description: 允许控制末影人掉落
|
||||
description: 允许控制末影人掉落方块
|
||||
default: op
|
||||
essentialsc.*:
|
||||
description: 授予 EssentialsC 的全部权限
|
||||
@@ -121,5 +136,10 @@ permissions:
|
||||
essentialsc.command.admin: true
|
||||
essentialsc.command.help: true
|
||||
essentialsc.command.reload: true
|
||||
essentialsc.command.tpsbar: true
|
||||
essentialsc.command.tpsbar.others: true
|
||||
essentialsc.command.maintenance: true
|
||||
essentialsc.maintenance.bypass: true
|
||||
essentialsc.maintenance.notify: true
|
||||
essentialsc.shulkerbox.open: true
|
||||
essentialsc.mobdrops.enderman: true
|
||||
|
||||
Reference in New Issue
Block a user