13 Commits

Author SHA1 Message Date
22708cf75d Merge branch 'main' into dev-26.1 2026-04-21 17:31:52 +08:00
505c59fb68 docs(readme): 添加项目完整文档和使用指南
- 创建了详细的 README.md 文件介绍 EssentialsC 插件
- 添加了核心特性和功能方块使用说明
- 包含了安装步骤和系统要求文档
- 提供了完整的命令列表和权限节点说明
- 添加了配置文件说明和多语言支持介绍
- 包含了从源码构建和贡献指南信息
2026-04-21 17:24:17 +08:00
Coldsmile_7
29c456d4bd 更新项目配置和新增功能 2026-04-21 16:20:12 +08:00
Coldsmile_7
fc209ba5b8 ci: 添加 release 权限 2026-04-15 01:52:38 +08:00
Coldsmile_7
32af98afcb fix: 修复 pom.xml 语法错误 2026-04-15 01:50:09 +08:00
Coldsmile_7
9ba475f9eb fix: 移除 antrun 插件 2026-04-15 01:48:31 +08:00
Coldsmile_7
298c14e706 fix: 修复 CI 构建失败 2026-04-15 01:43:51 +08:00
Coldsmile_7
cce34236cf ci: 添加自动发行工作流 2026-04-15 01:37:08 +08:00
Coldsmile_7
633b7beaa3 docs: 优化 README 结构和格式 2026-04-15 01:31:02 +08:00
Coldsmile_7
bcda5e8578 chore: 将临时文件移至 references 文件夹并添加到 .gitignore 2026-04-15 01:26:23 +08:00
Coldsmile_7
2364ddee97 docs: 更新 README 添加潜影盒和末影箱功能说明 2026-04-15 01:20:05 +08:00
Coldsmile_7
cc07647551 feat: 添加潜影盒快捷打开和末影箱自定义标题功能 2026-04-15 00:55:31 +08:00
Coldsmile_7
f6364ac36b 修复管理员菜单:从config.yml读取配置,添加权限过滤的Tab补全,优化代码性能 2026-04-14 06:01:01 +08:00
25 changed files with 2030 additions and 451 deletions

35
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,35 @@
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 检出代码
uses: actions/checkout@v4
- name: 设置 Java
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: maven
- name: 构建插件
run: mvn clean package -B
- name: 创建发行版
uses: softprops/action-gh-release@v1
with:
files: target/essentialsc-*.jar
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

15
.gitignore vendored
View File

@@ -13,18 +13,6 @@
*.tar.gz *.tar.gz
*.rar *.rar
# Maven
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
# Gradle # Gradle
.gradle/ .gradle/
build/ build/
@@ -68,5 +56,8 @@ Thumbs.db
# Test server (不要上传测试服务器文件) # Test server (不要上传测试服务器文件)
test-server/ test-server/
# Reference files (不要上传参考资料)
references/
# Plugin build output # Plugin build output
*.jar.asc *.jar.asc

192
README.md
View File

@@ -1,109 +1,125 @@
# EssentialsC # EssentialsC
一个轻量级的 Paper 服务器核心插件,灵感来自 CMI但更加精简、易用且现代化。 > 一个轻量级的 Paper 服务器插件,灵感来自 CMI但更加精简、易用且现代化。
## ✨ 功能特性 [![Version](https://img.shields.io/github/v/release/Coldsmiles/EssentialsC?style=flat-square)](https://github.com/Coldsmiles/EssentialsC/releases)
[![License](https://img.shields.io/github/license/Coldsmiles/EssentialsC?style=flat-square)](LICENSE)
[![Paper](https://img.shields.io/badge/Paper-1.21+-8A2BE2?style=flat-square)](https://papermc.io/)
[![Java](https://img.shields.io/badge/Java-21+-orange?style=flat-square)](https://www.oracle.com/java/)
## ✨ 核心特性
### 🎯 随身功能方块 ### 🎯 随身功能方块
随时随地打开各种功能性方块,无需放置实体方块: 随时随地打开各种功能性方块,无需放置实体方块:
- 工作台 (`/workbench`) - **工作台** (`/workbench`, `/wb`)
- 铁砧 (`/anvil`) - **铁砧** (`/anvil`)
- 附魔台 (`/enchantingtable`) - **制图台** (`/cartographytable`, `/ct`)
- 制图台 (`/cartographytable`) - **砂轮** (`/grindstone`, `/gs`)
- 砂轮 (`/grindstone`) - **织布机** (`/loom`)
- 织布机 (`/loom`) - **锻造台** (`/smithingtable`, `/st`)
- 锻造台 (`/smithingtable`) - **切石机** (`/stonecutter`, `/sc`)
- 切石机 (`/stonecutter`) - **末影箱** (`/enderchest`, `/ec`)
### 📦 智能容器管理
- **潜影盒快捷打开** - 潜行+右键直接打开(类似 CMI
- ✅ 支持自定义标题(可配置)
- ✅ 防刷物品机制(快照验证 + 数量检查)
- ✅ 防止套娃(不能放入另一个潜影盒)
- ✅ 异常恢复(物品丢失自动掉落)
### 🔧 实用工具 ### 🔧 实用工具
- **末影箱** (`/enderchest`) - 随时访问末影箱
- **帽子** (`/hat`) - 将手中物品戴在头上 - **帽子** (`/hat`) - 将手中物品戴在头上
- **自杀** (`/suicide`) - 快速自杀 - **自杀** (`/suicide`, `/die`) - 快速自杀
- **飞行** (`/fly`) - 切换飞行模式 - **飞行** (`/fly`) - 切换飞行模式
- **修复** (`/repair`, `/rep`) - 修复手中或所有物品
- **饱食** (`/feed`) - 补满饱食度
### 💚 生存辅助 ### 💚 生存辅助
- **治疗** (`/heal`) - 恢复生命值和饱食度 - **治疗** (`/heal`) - 恢复生命值和饱食度
- **隐身** (`/vanish`) - 管理员隐身模式 - **隐身** (`/vanish`, `/v`) - 管理员隐身模式
### 📊 管理功能 ### 📊 管理功能
- **玩家查询** (`/seen`) - 查看玩家上线时间和信息 - **玩家查询** (`/seen`, `/info`) - 查看玩家上线时间和信息
- **管理菜单** (`/admin`) - 可视化 GUI 管理面板 - **功能方块菜单** (`/essc blocks`) - GUI 方块集合面板
- 时间/天气控制 - **配置重载** (`/essc reload`) - 重新加载配置文件
- 快捷状态恢复
- 插件重载
### 🌍 多语言支持 ---
- 完整的中文和英文配置
- 方块标题自动跟随客户端语言
- 可自定义所有消息文本
### ⚡ 权限控制 ## 🌍 多语言支持
- 精细的权限管理系统
- 帮助菜单智能显示(只显示有权限的命令)
- 默认仅 OP 可用,可通过权限插件授权
## 📦 安装 - ✅ 完整的中文和英文配置
- ✅ 方块标题自动跟随客户端语言
- ✅ 可自定义所有消息文本
### 要求 ## ⚡ 权限系统
- Paper 1.21+ 服务器
- Java 21+
### 步骤 - ✅ 精细的权限管理
- ✅ 帮助菜单智能显示(只显示有权限的命令)
- ✅ 默认仅 OP 可用,可通过权限插件授权
- ✅ CMI 风格的命令别名支持
## 📦 快速开始
### 系统要求
- **服务器**: Paper 1.21+
- **Java**: 21+
### 安装步骤
1. 下载最新版本的 [`essentialsc-*.jar`](https://github.com/Coldsmiles/EssentialsC/releases) 1. 下载最新版本的 [`essentialsc-*.jar`](https://github.com/Coldsmiles/EssentialsC/releases)
2. 将文件放入服务器的 `plugins` 文件夹 2. 将文件放入服务器的 `plugins` 文件夹
3. 重启服务器 3. 重启服务器
4. 编辑 `plugins/EssentialsC/config.yml` 配置语言 4. 编辑 `plugins/EssentialsC/config.yml` 配置语言
5. (可选)使用权限插件为玩家授予相应权限 5. (可选)使用权限插件为玩家授予相应权限
## 🎮 命令 ## 🎮 命令列表
### 基础命令 ### 基础命令
``` | 命令 | 说明 |
/essc help # 显示帮助菜单(根据权限动态显示) |------|------|
``` | `/essc help` | 显示帮助菜单(根据权限动态显示) |
| `/essc reload` | 重载配置(管理员) |
| `/essc blocks` | 打开功能方块菜单 |
### 功能方块命令 ### 功能方块命令
``` | 命令 | 别名 | 说明 |
/workbench # 打开工作台 |------|------|------|
/anvil # 打开铁砧 | `/workbench` | `/wb` | 打开工作台 |
/enchantingtable # 打开附魔台 | `/anvil` | - | 打开铁砧 |
/cartographytable # 打开制图台 | `/cartographytable` | `/ct` | 打开制图台 |
/grindstone # 打开砂轮 | `/grindstone` | `/gs` | 打开砂轮 |
/loom # 打开织布机 | `/loom` | - | 打开织布机 |
/smithingtable # 打开锻造台 | `/smithingtable` | `/st` | 打开锻造台 |
/stonecutter # 打开切石机 | `/stonecutter` | `/sc` | 打开切石机 |
/enderchest # 打开末影箱 | `/enderchest` | `/ec` | 打开末影箱 |
```
### 其他命令 ### 其他命令
``` | 命令 | 别名 | 说明 |
/hat # 将手中物品戴在头上 |------|------|------|
/suicide # 自杀 | `/hat` | - | 将手中物品戴在头上 |
/fly # 切换飞行模式 | `/suicide` | `/die` | 自杀 |
/heal # 恢复生命值和饱食度 | `/fly` | - | 切换飞行模式 |
/vanish # 切换隐身模式(管理员) | `/heal` | - | 恢复生命值和饱食度 |
/seen <玩家> # 查看玩家信息(管理员) | `/vanish` | `/v` | 切换隐身模式(管理员) |
/admin # 打开管理菜单(管理员) | `/seen` | `/info` | 查看玩家信息(管理员) |
``` | `/feed` | - | 补满饱食度 |
| `/repair` | `/rep` | 修复手中或所有物品 |
### 命令别名 > 💡 **提示**: 使用 `/repair all` 可以修复背包中的所有物品
- `/essentialsc` = `/essc`
## ⚙️ 配置 ## ⚙️ 配置说明
### config.yml ### config.yml
```yaml ```yaml
# 语言设置 # 语言设置 (en_US, zh_CN)
# 可用语言: en_US, zh_CN
language: "zh_CN" language: "zh_CN"
# 通用设置 # 通用设置
settings: settings:
# 启用或禁用命令反馈消息 enable-feedback: true # 启用命令反馈消息
enable-feedback: true
# 所有插件消息的前缀 # 潜影盒设置
message-prefix: "&6[EssentialsC] &r" shulkerbox:
default-title: "&e潜影盒" # 默认标题(支持颜色代码)
``` ```
### 自定义语言 ### 自定义语言
@@ -111,12 +127,12 @@ settings:
## 🔐 权限节点 ## 🔐 权限节点
所有命令默认需要 OP 权限。使用权限插件(如 LuckPerms授予权限: 所有命令默认需要 OP 权限。使用权限插件授予权限:
### 基础权限
``` ```
essentialsc.command.workbench # 工作台 essentialsc.command.workbench # 工作台
essentialsc.command.anvil # 铁砧 essentialsc.command.anvil # 铁砧
essentialsc.command.enchantingtable # 附魔台
essentialsc.command.cartographytable # 制图台 essentialsc.command.cartographytable # 制图台
essentialsc.command.grindstone # 砂轮 essentialsc.command.grindstone # 砂轮
essentialsc.command.loom # 织布机 essentialsc.command.loom # 织布机
@@ -129,41 +145,32 @@ essentialsc.command.fly # 飞行
essentialsc.command.heal # 治疗 essentialsc.command.heal # 治疗
essentialsc.command.vanish # 隐身 essentialsc.command.vanish # 隐身
essentialsc.command.seen # 玩家查询 essentialsc.command.seen # 玩家查询
essentialsc.command.admin # 管理菜单 essentialsc.command.feed # 饱食度
essentialsc.command.repair # 修复
essentialsc.shulkerbox.open # 潜行+右键潜影盒
```
### 管理权限
```
essentialsc.command.blocks # 功能方块菜单
essentialsc.command.reload # 重载配置
essentialsc.command.help # 帮助(默认开放) essentialsc.command.help # 帮助(默认开放)
```
### 通配符
```
essentialsc.* # 所有权限 essentialsc.* # 所有权限
``` ```
### 示例:使用 LuckPerms 授权 ## 🔨 从源码构建
```bash
# 给单个玩家授权
/lp user <玩家名> permission set essentialsc.command.workbench true
# 给用户组授权
/lp group vip permission set essentialsc.command.workbench true
# 授权所有命令
/lp group admin permission set essentialsc.* true
```
## 🔨 构建
从源代码构建插件:
```bash ```bash
git clone https://github.com/Coldsmiles/EssentialsC.git git clone https://github.com/Coldsmiles/EssentialsC.git
cd EssentialsC cd EssentialsC
mvn clean package ./gradlew build
``` ```
编译后的文件位于 `target/essentialsc-*.jar` 编译后的文件位于 `build/libs/essentialsc-*.jar`
## 📝 开发计划
- [ ] 冷却时间系统
- [ ] 更多管理功能
- [ ] 数据统计
- [ ] API 支持
## 🤝 贡献 ## 🤝 贡献
@@ -174,9 +181,6 @@ mvn clean package
本项目采用 MIT 许可证 - 详见 [LICENSE](LICENSE) 文件 本项目采用 MIT 许可证 - 详见 [LICENSE](LICENSE) 文件
## 👨‍💻 作者 ## 👨‍💻 作者
**Coldsmiles_7**
- GitHub: [@Coldsmiles](https://github.com/Coldsmiles) - GitHub: [@Coldsmiles](https://github.com/Coldsmiles)
- 网站: www.infstar.cn - 网站: www.infstar.cn

229
build.gradle Normal file
View File

@@ -0,0 +1,229 @@
plugins {
id 'java'
id 'io.papermc.paperweight.userdev' version '2.0.0-beta.21'
id 'com.gradleup.shadow' version '8.3.6'
}
group = 'cn.infstar'
version = '1.3.0'
repositories {
mavenCentral()
maven {
name = 'papermc'
url = uri('https://repo.papermc.io/repository/maven-public/')
}
}
dependencies {
paperweight.paperDevBundle('1.21.11-R0.1-SNAPSHOT')
}
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
}
def excludedModules = project.hasProperty('excludeModules') ?
project.property('excludeModules').split(',')*.trim() : []
def includeBlocks = !excludedModules.contains('blocks')
def includePlayer = !excludedModules.contains('player')
def includeJeiFix = !excludedModules.contains('jei-fix')
def includeMobDrops = !excludedModules.contains('mob-drops')
println "\n📦 EssentialsC 模块配置:"
println " ✅ Core (核心)"
println " ${includeBlocks ? '✅' : '❌'} Blocks (便捷方块)"
println " ${includePlayer ? '✅' : '❌'} Player (玩家管理)"
println " ${includeJeiFix ? '✅' : '❌'} JEI Fix (JEI 修复)"
println " ${includeMobDrops ? '✅' : '❌'} Mob Drops (生物掉落物)"
println ""
sourceSets {
main {
java {
if (!includeBlocks) {
exclude '**/commands/WorkbenchCommand.java'
exclude '**/commands/AnvilCommand.java'
exclude '**/commands/CartographyTableCommand.java'
exclude '**/commands/GrindstoneCommand.java'
exclude '**/commands/LoomCommand.java'
exclude '**/commands/SmithingTableCommand.java'
exclude '**/commands/StonecutterCommand.java'
exclude '**/commands/EnderChestCommand.java'
exclude '**/commands/BlocksMenuCommand.java'
exclude '**/listeners/ShulkerBoxListener.java'
}
if (!includePlayer) {
exclude '**/commands/FlyCommand.java'
exclude '**/commands/HealCommand.java'
exclude '**/commands/FeedCommand.java'
exclude '**/commands/VanishCommand.java'
exclude '**/commands/SeenCommand.java'
exclude '**/commands/HatCommand.java'
exclude '**/commands/SuicideCommand.java'
exclude '**/commands/RepairCommand.java'
}
if (!includeJeiFix) {
exclude '**/listeners/JeiRecipeSyncListener.java'
}
if (!includeMobDrops) {
exclude '**/listeners/MobDropListener.java'
exclude '**/listeners/MobDropMenuListener.java'
exclude '**/commands/MobDropCommand.java'
}
}
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}
processResources {
filteringCharset = 'UTF-8'
inputs.property('version', project.version)
filesMatching('paper-plugin.yml') {
expand('version': project.version)
}
}
shadowJar {
enabled = false
}
// ========== 多版本构建任务 ==========
task shadowJarStandard(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
from sourceSets.main.output
configurations = [project.configurations.runtimeClasspath]
exclude '**/listeners/MobDropListener.class'
exclude '**/listeners/MobDropMenuListener.class'
exclude '**/commands/MobDropCommand.class'
archiveFileName.set("EssentialsC-${project.version}.jar")
}
task shadowJarAll(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
from sourceSets.main.output
configurations = [project.configurations.runtimeClasspath]
archiveFileName.set("EssentialsC-all-${project.version}.jar")
}
task shadowJarLite(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
from sourceSets.main.output
configurations = [project.configurations.runtimeClasspath]
exclude '**/commands/WorkbenchCommand.class'
exclude '**/commands/AnvilCommand.class'
exclude '**/commands/CartographyTableCommand.class'
exclude '**/commands/GrindstoneCommand.class'
exclude '**/commands/LoomCommand.class'
exclude '**/commands/SmithingTableCommand.class'
exclude '**/commands/StonecutterCommand.class'
exclude '**/commands/EnderChestCommand.class'
exclude '**/commands/BlocksMenuCommand.class'
exclude '**/listeners/ShulkerBoxListener.class'
archiveFileName.set("EssentialsC-lite-${project.version}.jar")
}
build {
dependsOn shadowJarAll
}
// ========== 部署任务 ==========
task deployToPaper12111(type: Copy) {
group = 'deployment'
description = '部署到 Paper 1.21.11 测试服务器(仅完整版)'
dependsOn shadowJarAll
from shadowJarAll
into "${projectDir}/test-server/paper-1.21.11/plugins"
doLast {
println "✅ 插件已部署到 Paper 1.21.11: ${projectDir}/test-server/paper-1.21.11/plugins"
}
}
task deployToPaper26 {
group = 'deployment'
description = '部署到 Paper 26.1.2 测试服务器(仅完整版)'
dependsOn shadowJarAll
doFirst {
def pluginsDir = file("${projectDir}/test-server/paper-26.1.2/plugins")
if (pluginsDir.exists()) {
// 删除所有 EssentialsC 相关的 JAR 文件
fileTree(pluginsDir).include('EssentialsC*.jar').each { file ->
println "🗑️ 删除旧插件: ${file.name}"
file.delete()
}
// 删除配置文件夹
def configDir = file("${pluginsDir}/EssentialsC")
if (configDir.exists()) {
println "🗑️ 删除旧配置文件夹"
configDir.deleteDir()
}
println "✅ 清理完成"
} else {
println "⚠️ plugins 目录不存在,跳过清理"
}
}
doLast {
copy {
from shadowJarAll.archiveFile
into "${projectDir}/test-server/paper-26.1.2/plugins"
}
println "✅ 插件已部署到 Paper 26.1.2: ${projectDir}/test-server/paper-26.1.2/plugins"
}
}
// Paper 26.1.2 一键构建和部署任务
task buildAndDeployToPaper26 {
group = 'deployment'
description = '一键构建并部署到 Paper 26.1.2'
dependsOn clean, deployToPaper26
}
// 默认部署到 Paper 1.21.11
task deployToTestServer {
dependsOn deployToPaper12111
}
build.finalizedBy deployToTestServer
task buildAllVersions {
group = 'build'
description = '构建所有版本的插件'
dependsOn shadowJarStandard, shadowJarAll, shadowJarLite
doLast {
println "\n🎉 所有版本构建完成!"
println "📦 标准版: EssentialsC-${project.version}.jar"
println "📦 完整版: EssentialsC-all-${project.version}.jar"
println "📦 轻量版: EssentialsC-lite-${project.version}.jar"
println "📁 输出目录: ${buildDir}/libs/"
def standardFile = file("${buildDir}/libs/EssentialsC-${project.version}.jar")
def allFile = file("${buildDir}/libs/EssentialsC-all-${project.version}.jar")
def liteFile = file("${buildDir}/libs/EssentialsC-lite-${project.version}.jar")
if (!standardFile.exists()) {
throw new GradleException("❌ 标准版文件不存在!")
}
if (!allFile.exists()) {
throw new GradleException("❌ 完整版文件不存在!")
}
if (!liteFile.exists()) {
throw new GradleException("❌ 轻量版文件不存在!")
}
println "✅ 所有文件验证通过!"
}
}

View File

@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

103
pom.xml
View File

@@ -1,103 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cn.infstar</groupId>
<artifactId>essentialsc</artifactId>
<version>1.1.0</version>
<packaging>jar</packaging>
<name>essentialsc</name>
<properties>
<java.version>21</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<test.server.path>${project.basedir}/test-server/plugins</test.server.path>
</properties>
<build>
<defaultGoal>clean package</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>copy-to-test-server</id>
<phase>package</phase>
<configuration>
<target>
<echo message="Cleaning old plugin files..."/>
<!-- 删除测试服务器中所有旧版本的插件文件 -->
<delete>
<fileset dir="${test.server.path}" includes="essentialsc-*.jar"/>
</delete>
<echo message="Copying plugin to test server..."/>
<copy file="${project.build.directory}/${project.build.finalName}.jar"
tofile="${test.server.path}/${project.build.finalName}.jar"
overwrite="true"/>
<echo message="Plugin copied successfully!"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<!-- 阿里云 Maven 镜像 -->
<repository>
<id>aliyunmaven</id>
<url>https://maven.aliyun.com/repository/public</url>
</repository>
<!-- PaperMC 仓库 -->
<repository>
<id>papermc-repo</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.21.11-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

18
settings.gradle Normal file
View File

@@ -0,0 +1,18 @@
pluginManagement {
repositories {
// 阿里云 Gradle 插件镜像(优先)
maven {
name = 'aliyun-gradle-plugin'
url = uri('https://maven.aliyun.com/repository/gradle-plugin')
}
// Gradle 官方插件仓库
gradlePluginPortal()
// PaperMC 官方仓库(用于 paperweight 插件)
maven {
name = 'papermc'
url = uri('https://repo.papermc.io/repository/maven-public/')
}
}
}
rootProject.name = 'EssentialsC'

View File

@@ -14,12 +14,12 @@ public final class EssentialsC extends JavaPlugin {
@Override @Override
public void onEnable() { public void onEnable() {
// 初始化语言管理器
langManager = new LangManager(this); langManager = new LangManager(this);
registerPluginChannels();
registerListeners();
registerCommands(); registerCommands();
getLogger().info("EssentialsC 插件已启用!");
getLogger().info("当前语言: " + langManager.getCurrentLanguage()); getLogger().info("插件已启用!版本: " + getDescription().getVersion());
} }
@Override @Override
@@ -27,63 +27,195 @@ public final class EssentialsC extends JavaPlugin {
getLogger().info("EssentialsC 插件已禁用!"); getLogger().info("EssentialsC 插件已禁用!");
} }
/**
* 获取语言管理器实例
*/
public static LangManager getLangManager() { public static LangManager getLangManager() {
return langManager; return langManager;
} }
/**
* 注册 JEI 配方同步所需的插件频道
*/
private void registerPluginChannels() {
org.bukkit.plugin.messaging.Messenger messenger = getServer().getMessenger();
// 注册 Fabric 和 NeoForge 的配方同步频道
messenger.registerOutgoingPluginChannel(this, "fabric:recipe_sync");
messenger.registerOutgoingPluginChannel(this, "neoforge:recipe_content");
}
private void registerListeners() {
if (registerListener("cn.infstar.essentialsC.listeners.ShulkerBoxListener")) {
getLogger().info("- 潜影盒模块");
}
if (registerListener("cn.infstar.essentialsC.listeners.JeiRecipeSyncListener")) {
getLogger().info("- JEI 配方同步");
}
if (registerListener("cn.infstar.essentialsC.listeners.MobDropListener")) {
try {
Class.forName("cn.infstar.essentialsC.listeners.MobDropMenuListener");
new cn.infstar.essentialsC.listeners.MobDropMenuListener(this);
} catch (ClassNotFoundException e) {
}
getLogger().info("- 生物掉落控制");
}
}
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 e) {
return false;
}
}
private void registerCommands() { private void registerCommands() {
try { try {
// 获取 CommandMap
Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap"); Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");
bukkitCommandMap.setAccessible(true); bukkitCommandMap.setAccessible(true);
org.bukkit.command.CommandMap commandMap = (org.bukkit.command.CommandMap) bukkitCommandMap.get(Bukkit.getServer()); org.bukkit.command.CommandMap commandMap = (org.bukkit.command.CommandMap) bukkitCommandMap.get(Bukkit.getServer());
// 注册所有命令 int commandCount = 0;
registerCommand(commandMap, "workbench", new WorkbenchCommand());
registerCommand(commandMap, "anvil", new AnvilCommand());
registerCommand(commandMap, "enchantingtable", new EnchantingTableCommand());
registerCommand(commandMap, "cartographytable", new CartographyTableCommand());
registerCommand(commandMap, "grindstone", new GrindstoneCommand());
registerCommand(commandMap, "loom", new LoomCommand());
registerCommand(commandMap, "smithingtable", new SmithingTableCommand());
registerCommand(commandMap, "stonecutter", new StonecutterCommand());
registerCommand(commandMap, "enderchest", new EnderChestCommand());
registerCommand(commandMap, "hat", new HatCommand());
registerCommand(commandMap, "suicide", new SuicideCommand());
registerCommand(commandMap, "fly", new FlyCommand());
registerCommand(commandMap, "heal", new HealCommand());
registerCommand(commandMap, "vanish", new VanishCommand());
registerCommand(commandMap, "seen", new SeenCommand());
registerCommand(commandMap, "admin", new AdminMenuCommand());
registerCommand(commandMap, "feed", new FeedCommand());
registerCommand(commandMap, "repair", new RepairCommand());
registerCommand(commandMap, "essentialsc", new HelpCommand());
getLogger().info("成功注册 18 个命令!"); if (classExists("cn.infstar.essentialsC.commands.WorkbenchCommand")) {
registerCommandWithAliases(commandMap, "workbench", new WorkbenchCommand(), "wb");
commandCount++;
}
if (classExists("cn.infstar.essentialsC.commands.AnvilCommand")) {
registerCommandWithAliases(commandMap, "anvil", new AnvilCommand());
commandCount++;
}
if (classExists("cn.infstar.essentialsC.commands.CartographyTableCommand")) {
registerCommandWithAliases(commandMap, "cartographytable", new CartographyTableCommand(), "ct", "cartography");
commandCount++;
}
if (classExists("cn.infstar.essentialsC.commands.GrindstoneCommand")) {
registerCommandWithAliases(commandMap, "grindstone", new GrindstoneCommand(), "gs");
commandCount++;
}
if (classExists("cn.infstar.essentialsC.commands.LoomCommand")) {
registerCommandWithAliases(commandMap, "loom", new LoomCommand());
commandCount++;
}
if (classExists("cn.infstar.essentialsC.commands.SmithingTableCommand")) {
registerCommandWithAliases(commandMap, "smithingtable", new SmithingTableCommand(), "st", "smithing");
commandCount++;
}
if (classExists("cn.infstar.essentialsC.commands.StonecutterCommand")) {
registerCommandWithAliases(commandMap, "stonecutter", new StonecutterCommand(), "sc");
commandCount++;
}
if (classExists("cn.infstar.essentialsC.commands.EnderChestCommand")) {
registerCommandWithAliases(commandMap, "enderchest", new EnderChestCommand(), "ec");
commandCount++;
}
if (classExists("cn.infstar.essentialsC.commands.BlocksMenuCommand")) {
registerCommandWithAliases(commandMap, "blocks", new BlocksMenuCommand());
commandCount++;
}
if (classExists("cn.infstar.essentialsC.commands.FlyCommand")) {
registerCommandWithAliases(commandMap, "fly", new FlyCommand());
commandCount++;
}
if (classExists("cn.infstar.essentialsC.commands.HealCommand")) {
registerCommandWithAliases(commandMap, "heal", new HealCommand());
commandCount++;
}
if (classExists("cn.infstar.essentialsC.commands.FeedCommand")) {
registerCommandWithAliases(commandMap, "feed", new FeedCommand());
commandCount++;
}
if (classExists("cn.infstar.essentialsC.commands.VanishCommand")) {
registerCommandWithAliases(commandMap, "vanish", new VanishCommand(), "v");
commandCount++;
}
if (classExists("cn.infstar.essentialsC.commands.SeenCommand")) {
registerCommandWithAliases(commandMap, "seen", new SeenCommand(), "info");
commandCount++;
}
if (classExists("cn.infstar.essentialsC.commands.HatCommand")) {
registerCommandWithAliases(commandMap, "hat", new HatCommand());
commandCount++;
}
if (classExists("cn.infstar.essentialsC.commands.SuicideCommand")) {
registerCommandWithAliases(commandMap, "suicide", new SuicideCommand(), "die");
commandCount++;
}
if (classExists("cn.infstar.essentialsC.commands.RepairCommand")) {
registerCommandWithAliases(commandMap, "repair", new RepairCommand(), "rep");
commandCount++;
}
if (classExists("cn.infstar.essentialsC.commands.MobDropCommand")) {
registerCommandWithAliases(commandMap, "mobdrops", new MobDropCommand());
commandCount++;
}
registerCommandWithAliases(commandMap, "essentialsc", new HelpCommand(), "essc");
commandCount++;
} catch (Exception e) { } catch (Exception e) {
getLogger().severe("无法注册命令: " + e.getMessage()); getLogger().severe("无法注册命令: " + e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
} }
private void registerCommand(org.bukkit.command.CommandMap commandMap, String name, cn.infstar.essentialsC.commands.BaseCommand executor) { private boolean classExists(String className) {
try {
Class.forName(className);
return true;
} catch (ClassNotFoundException e) {
return false;
}
}
/**
* 注册命令并支持别名
* @param commandMap Bukkit CommandMap
* @param name 主命令名
* @param executor 命令执行器
* @param aliases 别名列表(可选)
*/
private void registerCommandWithAliases(org.bukkit.command.CommandMap commandMap, String name, cn.infstar.essentialsC.commands.BaseCommand executor, String... aliases) {
Command command = new Command(name) { Command command = new Command(name) {
@Override @Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) { public boolean execute(CommandSender sender, String commandLabel, String[] args) {
return executor.onCommand(sender, this, commandLabel, args); return executor.onCommand(sender, this, commandLabel, args);
} }
};
// 为 essentialsc 命令添加简化别名 @Override
if (name.equals("essentialsc")) { public java.util.List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
command.setAliases(java.util.Arrays.asList("essc")); if (executor instanceof org.bukkit.command.TabCompleter) {
return ((org.bukkit.command.TabCompleter) executor).onTabComplete(sender, this, alias, args);
} }
return super.tabComplete(sender, alias, args);
}
};
command.setPermission(executor.getPermission()); command.setPermission(executor.getPermission());
// 注册到默认命名空间,使玩家可以直接使用 /workbench 而不是 /essentialsc:workbench // 注册到默认命名空间,使玩家可以直接使用 /workbench 而不是 /essentialsc:workbench
commandMap.register("", command); 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 alias, String[] args) throws IllegalArgumentException {
if (executor instanceof org.bukkit.command.TabCompleter) {
return ((org.bukkit.command.TabCompleter) executor).onTabComplete(sender, this, alias, args);
}
return super.tabComplete(sender, alias, args);
}
};
aliasCmd.setPermission(executor.getPermission());
commandMap.register("", aliasCmd);
}
} }
} }

View File

@@ -82,6 +82,13 @@ public class LangManager {
} }
} }
/**
* 获取插件前缀
*/
public String getPrefix() {
return translateColorCodes(langFile.getString("prefix", "&6[EssentialsC] &r"));
}
/** /**
* 获取翻译文本 * 获取翻译文本
*/ */
@@ -104,6 +111,23 @@ public class LangManager {
return value; return value;
} }
/**
* 获取字符串列表(用于 Lore 等多行文本)
*/
public java.util.List<String> getStringList(String path) {
java.util.List<String> values = langFile.getStringList(path);
if (values.isEmpty()) {
// 如果找不到,返回包含错误信息的列表
return java.util.Arrays.asList("&cMissing translation: " + path);
}
// 翻译颜色代码
java.util.List<String> translated = new java.util.ArrayList<>();
for (String value : values) {
translated.add(translateColorCodes(value));
}
return translated;
}
/** /**
* 重新加载配置和语言 * 重新加载配置和语言
*/ */

View File

@@ -1,128 +0,0 @@
package cn.infstar.essentialsC.commands;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
public class AdminMenuCommand extends BaseCommand implements Listener {
private static final int MENU_SIZE = 27;
public AdminMenuCommand() {
super("essentialsc.command.admin");
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@Override
protected boolean execute(@NotNull Player player, String[] args) {
openMenu(player);
return true;
}
private void openMenu(Player player) {
String title = getLang().getString("admin-menu-title");
Inventory menu = Bukkit.createInventory(null, MENU_SIZE, title);
// 时间控制
addItem(menu, 10, Material.CLOCK, getLang().getString("admin-time-control"),
Arrays.asList("§7左键: 设为白天", "§7右键: 设为夜晚"));
addItem(menu, 11, Material.SUNFLOWER, getLang().getString("admin-weather-control"),
Arrays.asList("§7左键: 晴天", "§7右键: 雨天"));
// 状态恢复
addItem(menu, 13, Material.GOLDEN_APPLE, getLang().getString("admin-heal-self"),
Arrays.asList("§7补满生命值和饱食度"));
addItem(menu, 14, Material.BREAD, getLang().getString("admin-feed-self"),
Arrays.asList("§7补满饱食度"));
addItem(menu, 15, Material.ANVIL, getLang().getString("admin-repair-hand"),
Arrays.asList("§7修复当前手持物品"));
// 管理员功能
addItem(menu, 21, Material.ENDER_PEARL, getLang().getString("admin-vanish"),
Arrays.asList("§7点击切换隐身状态"));
addItem(menu, 22, Material.BOOK, getLang().getString("admin-reload"),
Arrays.asList("§7重新加载配置文件"));
player.openInventory(menu);
}
private void addItem(Inventory inv, int slot, Material material, String name, java.util.List<String> lore) {
ItemStack item = new ItemStack(material);
ItemMeta meta = item.getItemMeta();
if (meta != null) {
meta.setDisplayName(name);
meta.setLore(lore);
item.setItemMeta(meta);
}
inv.setItem(slot, item);
}
@EventHandler
public void onMenuClick(InventoryClickEvent event) {
String title = getLang().getString("admin-menu-title");
if (!event.getView().getTitle().equals(title)) return;
if (!(event.getWhoClicked() instanceof Player player)) return;
event.setCancelled(true);
ItemStack clicked = event.getCurrentItem();
if (clicked == null || !clicked.hasItemMeta()) return;
String name = clicked.getItemMeta().getDisplayName();
String timeControl = getLang().getString("admin-time-control");
String weatherControl = getLang().getString("admin-weather-control");
String healSelf = getLang().getString("admin-heal-self");
String feedSelf = getLang().getString("admin-feed-self");
String repairHand = getLang().getString("admin-repair-hand");
String vanish = getLang().getString("admin-vanish");
String reload = getLang().getString("admin-reload");
switch (name) {
case String t when t.equals(timeControl) -> {
if (event.isLeftClick()) player.getWorld().setTime(1000);
else player.getWorld().setTime(13000);
player.sendMessage(getLang().getString("admin-time-set"));
}
case String w when w.equals(weatherControl) -> {
if (event.isLeftClick()) player.getWorld().setStorm(false);
else player.getWorld().setStorm(true);
player.sendMessage(getLang().getString("admin-weather-set"));
}
case String h when h.equals(healSelf) -> {
player.setHealth(player.getMaxHealth());
player.setFoodLevel(20);
player.sendMessage(getLang().getString("admin-heal-success"));
}
case String f when f.equals(feedSelf) -> {
player.setFoodLevel(20);
player.setSaturation(20f);
player.sendMessage(getLang().getString("admin-feed-success"));
}
case String r when r.equals(repairHand) -> {
var item = player.getInventory().getItemInMainHand();
if (item.getItemMeta() instanceof org.bukkit.inventory.meta.Damageable d) {
d.setDamage(0);
item.setItemMeta((org.bukkit.inventory.meta.ItemMeta) d);
player.sendMessage(getLang().getString("admin-repair-success"));
}
}
case String v when v.equals(vanish) -> {
new VanishCommand().execute(player, new String[]{});
openMenu(player); // 刷新菜单
}
case String rl when rl.equals(reload) -> {
plugin.reloadConfig();
player.sendMessage(getLang().getString("admin-reload-success"));
}
default -> {} // 忽略其他点击
}
}
}

View File

@@ -10,8 +10,8 @@ public class AnvilCommand extends BaseCommand {
@Override @Override
protected boolean execute(Player player, String[] args) { protected boolean execute(Player player, String[] args) {
// 使用 Paper API 打开铁砧(标题跟随客户端语言)
player.openAnvil(null, true); player.openAnvil(null, true);
player.sendMessage(getLang().getString("anvil-opened"));
return true; return true;
} }
} }

View File

@@ -33,20 +33,23 @@ public abstract class BaseCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (!(sender instanceof Player player)) { if (sender instanceof Player player) {
sender.sendMessage(getLang().getString("messages.player-only"));
return true;
}
if (!player.hasPermission(permission)) { if (!player.hasPermission(permission)) {
String message = getLang().getString("messages.no-permission", String message = getLang().getString("messages.no-permission",
java.util.Map.of("permission", permission)); java.util.Map.of("permission", permission));
player.sendMessage(message); player.sendMessage(message);
return true; return true;
} }
return execute(player, args); return execute(player, args);
} else {
return executeConsole(sender, args);
}
} }
protected abstract boolean execute(Player player, String[] args); protected abstract boolean execute(Player player, String[] args);
protected boolean executeConsole(CommandSender sender, String[] args) {
sender.sendMessage(getLang().getString("messages.player-only"));
return true;
}
} }

View File

@@ -0,0 +1,128 @@
package cn.infstar.essentialsC.commands;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.jetbrains.annotations.NotNull;
public class BlocksMenuCommand extends BaseCommand implements Listener {
private static final int MENU_SIZE = 36;
private final NamespacedKey blockKey;
public BlocksMenuCommand() {
super("essentialsc.command.blocks");
plugin.getServer().getPluginManager().registerEvents(this, plugin);
blockKey = new NamespacedKey(plugin, "block_key");
}
@Override
protected boolean execute(@NotNull Player player, String[] args) {
openMenu(player);
return true;
}
private void openMenu(Player player) {
String title = plugin.getConfig().getString("blocks-menu.title", "&6&lEssentialsC &8- &e&l功能方块菜单");
Inventory menu = Bukkit.createInventory(null, MENU_SIZE, translateColor(title));
// 从配置中读取所有物品
var itemsConfig = plugin.getConfig().getConfigurationSection("blocks-menu.items");
if (itemsConfig == null) return;
for (String key : itemsConfig.getKeys(false)) {
var section = itemsConfig.getConfigurationSection(key);
if (section == null) continue;
// 检查权限
String permission = section.getString("permission");
if (permission != null && !player.hasPermission(permission)) {
continue;
}
int slot = section.getInt("slot");
Material material = Material.matchMaterial(section.getString("material", "STONE"));
if (material == null) material = Material.STONE;
String name = translateColor(section.getString("name", "&fItem"));
java.util.List<String> lore = section.getStringList("lore").stream()
.map(this::translateColor)
.collect(java.util.stream.Collectors.toList());
addItem(menu, slot, material, name, lore, key);
}
player.openInventory(menu);
}
private void addItem(Inventory inv, int slot, Material material, String name, java.util.List<String> lore, String key) {
ItemStack item = new ItemStack(material);
ItemMeta meta = item.getItemMeta();
if (meta != null) {
meta.setDisplayName(name);
meta.setLore(lore);
meta.getPersistentDataContainer().set(this.blockKey, PersistentDataType.STRING, key);
item.setItemMeta(meta);
}
inv.setItem(slot, item);
}
@EventHandler
public void onMenuClick(InventoryClickEvent event) {
// 动态获取配置的标题
String configTitle = plugin.getConfig().getString("blocks-menu.title", "&6&lEssentialsC &8- &e&l功能方块菜单");
String actualTitle = translateColor(configTitle);
if (!event.getView().getTitle().equals(actualTitle)) return;
if (!(event.getWhoClicked() instanceof Player player)) return;
event.setCancelled(true);
ItemStack clicked = event.getCurrentItem();
if (clicked == null || !clicked.hasItemMeta()) return;
ItemMeta meta = clicked.getItemMeta();
String key = meta.getPersistentDataContainer().get(this.blockKey, PersistentDataType.STRING);
// 点击后执行对应命令并播放音效(如果有)
if (key != null && HelpCommand.COMMAND_CACHE.containsKey(key)) {
playBlockOpenSound(player, key);
HelpCommand.COMMAND_CACHE.get(key).execute(player, new String[]{});
}
}
/**
* 播放对应方块的打开音效(优先使用交互音效)
*/
private void playBlockOpenSound(Player player, String key) {
org.bukkit.Sound sound = switch (key) {
case "workbench" -> org.bukkit.Sound.BLOCK_WOOD_HIT;
case "anvil" -> org.bukkit.Sound.BLOCK_ANVIL_USE;
case "cartographytable" -> org.bukkit.Sound.UI_CARTOGRAPHY_TABLE_TAKE_RESULT;
case "grindstone" -> org.bukkit.Sound.BLOCK_GRINDSTONE_USE;
case "loom" -> org.bukkit.Sound.UI_LOOM_TAKE_RESULT;
case "smithingtable" -> org.bukkit.Sound.BLOCK_SMITHING_TABLE_USE;
case "stonecutter" -> org.bukkit.Sound.BLOCK_STONE_HIT;
case "enderchest" -> org.bukkit.Sound.BLOCK_ENDER_CHEST_OPEN;
default -> null;
};
if (sound != null) {
player.playSound(player.getLocation(), sound, 1.0f, 1.0f);
}
}
/**
* 转换颜色代码 & -> §
*/
private String translateColor(String text) {
return text.replace("&", "§");
}
}

View File

@@ -1,17 +0,0 @@
package cn.infstar.essentialsC.commands;
import org.bukkit.entity.Player;
public class EnchantingTableCommand extends BaseCommand {
public EnchantingTableCommand() {
super("essentialsc.command.enchantingtable");
}
@Override
protected boolean execute(Player player, String[] args) {
player.openEnchanting(null, true);
player.sendMessage(getLang().getString("enchantingtable-opened"));
return true;
}
}

View File

@@ -2,6 +2,10 @@ package cn.infstar.essentialsC.commands;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
/**
* 末影箱命令 - 参考 EssentialsX 实现
* 直接打开玩家的末影箱,确保数据安全
*/
public class EnderChestCommand extends BaseCommand { public class EnderChestCommand extends BaseCommand {
public EnderChestCommand() { public EnderChestCommand() {
@@ -10,7 +14,9 @@ public class EnderChestCommand extends BaseCommand {
@Override @Override
protected boolean execute(Player player, String[] args) { protected boolean execute(Player player, String[] args) {
// 打开玩家的末影箱(标题由客户端决定 // 直接打开玩家的末影箱(EssentialsX 方式
// 优点100% 安全,不会吞物品或刷物品
// 缺点:标题显示为 "Ender Chest"(由客户端语言决定)
player.openInventory(player.getEnderChest()); player.openInventory(player.getEnderChest());
return true; return true;
} }

View File

@@ -2,10 +2,42 @@ package cn.infstar.essentialsC.commands;
import cn.infstar.essentialsC.EssentialsC; import cn.infstar.essentialsC.EssentialsC;
import cn.infstar.essentialsC.LangManager; import cn.infstar.essentialsC.LangManager;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class HelpCommand extends BaseCommand { import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class HelpCommand extends BaseCommand implements TabCompleter {
// 缓存命令实例,避免重复创建
static final java.util.Map<String, BaseCommand> COMMAND_CACHE = new java.util.HashMap<>();
static {
COMMAND_CACHE.put("workbench", new WorkbenchCommand());
COMMAND_CACHE.put("anvil", new AnvilCommand());
COMMAND_CACHE.put("cartographytable", new CartographyTableCommand());
COMMAND_CACHE.put("grindstone", new GrindstoneCommand());
COMMAND_CACHE.put("loom", new LoomCommand());
COMMAND_CACHE.put("smithingtable", new SmithingTableCommand());
COMMAND_CACHE.put("stonecutter", new StonecutterCommand());
COMMAND_CACHE.put("enderchest", new EnderChestCommand());
COMMAND_CACHE.put("hat", new HatCommand());
COMMAND_CACHE.put("suicide", new SuicideCommand());
COMMAND_CACHE.put("fly", new FlyCommand());
COMMAND_CACHE.put("heal", new HealCommand());
COMMAND_CACHE.put("vanish", new VanishCommand());
COMMAND_CACHE.put("seen", new SeenCommand());
COMMAND_CACHE.put("feed", new FeedCommand());
COMMAND_CACHE.put("repair", new RepairCommand());
COMMAND_CACHE.put("blocks", new BlocksMenuCommand());
COMMAND_CACHE.put("mobdrops", new MobDropCommand());
}
public HelpCommand() { public HelpCommand() {
super("essentialsc.command.help"); super("essentialsc.command.help");
@@ -13,6 +45,72 @@ public class HelpCommand extends BaseCommand {
@Override @Override
protected boolean execute(@NotNull Player player, String[] args) { protected boolean execute(@NotNull Player player, String[] args) {
return handleCommand(player, player, args);
}
@Override
protected boolean executeConsole(org.bukkit.command.CommandSender sender, String[] args) {
if (args.length > 0 && args[0].equalsIgnoreCase("reload")) {
if (!sender.hasPermission("essentialsc.command.reload")) {
sender.sendMessage(getLang().getString("messages.no-permission"));
return true;
}
plugin.reloadConfig();
EssentialsC.getLangManager().reload();
sender.sendMessage(getLang().getString("prefix") + "§a配置已重载");
return true;
}
sender.sendMessage(getLang().getString("messages.player-only"));
return true;
}
private boolean handleCommand(CommandSender sender, Player player, String[] args) {
if (args.length > 0) {
String subCommand = args[0].toLowerCase();
if (subCommand.equals("reload")) {
if (!sender.hasPermission("essentialsc.command.reload")) {
sender.sendMessage(getLang().getString("messages.no-permission"));
return true;
}
plugin.reloadConfig();
EssentialsC.getLangManager().reload();
sender.sendMessage(getLang().getString("prefix") + "§a配置已重载");
return true;
}
// 功能方块和其他命令 - 使用别名映射
String actualCommand = getActualCommand(subCommand);
if (actualCommand != null && COMMAND_CACHE.containsKey(actualCommand)) {
String permission = getPermissionForCommand(actualCommand);
if (!player.hasPermission(permission)) {
player.sendMessage(getLang().getString("messages.no-permission"));
return true;
}
// seen 需要特殊处理参数
if (actualCommand.equals("seen")) {
if (args.length < 2) {
player.sendMessage(getLang().getString("prefix") + getLang().getString("messages.seen-usage-console"));
return true;
}
COMMAND_CACHE.get("seen").execute(player, new String[]{args[1]});
} else {
COMMAND_CACHE.get(actualCommand).execute(player, new String[]{});
}
return true;
} else if (subCommand.equals("version") || subCommand.equals("v")) {
player.sendMessage(getLang().getString("prefix") + "§6EssentialsC §fv" + plugin.getDescription().getVersion());
player.sendMessage(getLang().getString("prefix") + "§7运行在 Paper " + Bukkit.getVersion());
return true;
} else {
player.sendMessage(getLang().getString("prefix") + getLang().getString("messages.unknown-subcommand",
java.util.Map.of("command", subCommand)));
player.sendMessage(getLang().getString("prefix") + getLang().getString("messages.help-usage"));
return true;
}
}
// 显示帮助
LangManager lang = getLang(); LangManager lang = getLang();
String version = plugin.getDescription().getVersion(); String version = plugin.getDescription().getVersion();
@@ -33,10 +131,6 @@ public class HelpCommand extends BaseCommand {
blockCommands.append(lang.getString("help.commands.anvil")).append("\n"); blockCommands.append(lang.getString("help.commands.anvil")).append("\n");
hasBlockCommands = true; hasBlockCommands = true;
} }
if (player.hasPermission("essentialsc.command.enchantingtable")) {
blockCommands.append(lang.getString("help.commands.enchantingtable")).append("\n");
hasBlockCommands = true;
}
if (player.hasPermission("essentialsc.command.cartographytable")) { if (player.hasPermission("essentialsc.command.cartographytable")) {
blockCommands.append(lang.getString("help.commands.cartographytable")).append("\n"); blockCommands.append(lang.getString("help.commands.cartographytable")).append("\n");
hasBlockCommands = true; hasBlockCommands = true;
@@ -96,10 +190,6 @@ public class HelpCommand extends BaseCommand {
otherCommands.append(lang.getString("help.commands.seen")).append("\n"); otherCommands.append(lang.getString("help.commands.seen")).append("\n");
hasOtherCommands = true; hasOtherCommands = true;
} }
if (player.hasPermission("essentialsc.command.admin")) {
otherCommands.append(lang.getString("help.commands.admin")).append("\n");
hasOtherCommands = true;
}
if (hasOtherCommands) { if (hasOtherCommands) {
player.sendMessage(lang.getString("help.section-other")); player.sendMessage(lang.getString("help.section-other"));
@@ -110,4 +200,98 @@ public class HelpCommand extends BaseCommand {
player.sendMessage(lang.getString("help.footer")); player.sendMessage(lang.getString("help.footer"));
return true; return true;
} }
/**
* 将别名映射到实际命令名
*/
private String getActualCommand(String alias) {
return switch (alias) {
case "wb" -> "workbench";
case "cartography", "ct" -> "cartographytable";
case "gs" -> "grindstone";
case "smithing", "st" -> "smithingtable";
case "sc" -> "stonecutter";
case "ec" -> "enderchest";
case "die" -> "suicide";
case "info" -> "seen";
case "rep" -> "repair";
default -> alias;
};
}
/**
* 获取命令对应的权限节点
*/
private String getPermissionForCommand(String command) {
return "essentialsc.command." + command;
}
@Override
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (args.length == 1) {
List<String> completions = new ArrayList<>();
String partial = args[0].toLowerCase();
// 所有可能的子命令及其权限(包括别名)
String[][] subCommands = {
{"reload", "essentialsc.command.reload"},
{"blocks", "essentialsc.command.blocks"},
{"workbench", "essentialsc.command.workbench"},
{"wb", "essentialsc.command.workbench"},
{"anvil", "essentialsc.command.anvil"},
{"cartographytable", "essentialsc.command.cartographytable"},
{"cartography", "essentialsc.command.cartographytable"},
{"ct", "essentialsc.command.cartographytable"},
{"grindstone", "essentialsc.command.grindstone"},
{"gs", "essentialsc.command.grindstone"},
{"loom", "essentialsc.command.loom"},
{"smithingtable", "essentialsc.command.smithingtable"},
{"smithing", "essentialsc.command.smithingtable"},
{"st", "essentialsc.command.smithingtable"},
{"stonecutter", "essentialsc.command.stonecutter"},
{"sc", "essentialsc.command.stonecutter"},
{"enderchest", "essentialsc.command.enderchest"},
{"ec", "essentialsc.command.enderchest"},
{"hat", "essentialsc.command.hat"},
{"suicide", "essentialsc.command.suicide"},
{"die", "essentialsc.command.suicide"},
{"fly", "essentialsc.command.fly"},
{"heal", "essentialsc.command.heal"},
{"vanish", "essentialsc.command.vanish"},
{"v", "essentialsc.command.vanish"},
{"seen", "essentialsc.command.seen"},
{"info", "essentialsc.command.seen"},
{"feed", "essentialsc.command.feed"},
{"repair", "essentialsc.command.repair"},
{"rep", "essentialsc.command.repair"},
{"mobdrops", "essentialsc.mobdrops.enderman"},
{"version", null},
{"help", null}
};
for (String[] subCmd : subCommands) {
if (subCmd[0].startsWith(partial)) {
if (subCmd[1] == null || sender.hasPermission(subCmd[1])) {
completions.add(subCmd[0]);
}
}
}
return completions;
} else if (args.length == 2) {
String subCmd = args[0].toLowerCase();
if ((subCmd.equals("seen") || subCmd.equals("info")) && sender.hasPermission("essentialsc.command.seen")) {
List<String> players = new ArrayList<>();
String partial = args[1].toLowerCase();
for (Player p : Bukkit.getOnlinePlayers()) {
if (p.getName().toLowerCase().startsWith(partial)) {
players.add(p.getName());
}
}
return players;
}
}
return new ArrayList<>();
}
} }

View File

@@ -0,0 +1,67 @@
package cn.infstar.essentialsC.commands;
import cn.infstar.essentialsC.EssentialsC;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.Arrays;
/**
* 生物掉落物控制命令
* /mobdrops - 打开控制菜单
*/
public class MobDropCommand extends BaseCommand {
public MobDropCommand() {
super("essentialsc.mobdrops.enderman");
}
@Override
protected boolean execute(Player player, String[] args) {
openMobDropMenu(player);
return true;
}
/**
* 打开生物掉落控制菜单
*/
private void openMobDropMenu(Player player) {
// 读取当前配置
boolean endermanEnabled = plugin.getConfig().getBoolean("mob-drops.enderman.enabled", true);
// 创建菜单
Inventory menu = Bukkit.createInventory(null, 27, "§6§l生物掉落控制");
// 末影人控制项
ItemStack endermanItem = new ItemStack(Material.ENDER_PEARL);
ItemMeta endermanMeta = endermanItem.getItemMeta();
endermanMeta.setDisplayName("§d末影人掉落");
endermanMeta.setLore(Arrays.asList(
"§7当前状态: " + (endermanEnabled ? "§a✅ 开启" : "§c❌ 关闭"),
"",
"§e点击切换状态"
));
endermanItem.setItemMeta(endermanMeta);
// 放置在中间
menu.setItem(13, endermanItem);
// 装饰物品
ItemStack glass = new ItemStack(Material.BLACK_STAINED_GLASS_PANE);
ItemMeta glassMeta = glass.getItemMeta();
glassMeta.setDisplayName(" ");
glass.setItemMeta(glassMeta);
for (int i = 0; i < 27; i++) {
if (menu.getItem(i) == null) {
menu.setItem(i, glass);
}
}
player.openInventory(menu);
}
}

View File

@@ -0,0 +1,391 @@
package cn.infstar.essentialsC.listeners;
import cn.infstar.essentialsC.EssentialsC;
import io.netty.buffer.Unpooled;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket;
import net.minecraft.network.protocol.common.custom.DiscardedPayload;
import net.minecraft.resources.Identifier;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.item.crafting.RecipeHolder;
import net.minecraft.world.item.crafting.RecipeMap;
import net.minecraft.world.item.crafting.RecipeSerializer;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* JEI 配方同步监听器
* 解决 Minecraft 1.21.2+ 配方不同步问题
* 支持 Fabric 和 NeoForge 客户端
*/
public class JeiRecipeSyncListener implements Listener {
private final EssentialsC plugin;
private final boolean enabled;
private final boolean debug;
private final boolean sendPlayerMessage;
public JeiRecipeSyncListener(EssentialsC plugin) {
this.plugin = plugin;
FileConfiguration config = plugin.getConfig();
this.enabled = config.getBoolean("jei-sync.enabled", true);
this.debug = config.getBoolean("jei-sync.debug", false);
this.sendPlayerMessage = config.getBoolean("jei-sync.send-player-message", true);
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
if (!enabled) {
return;
}
Player player = event.getPlayer();
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("========================================");
}
if (clientBrand == null || clientBrand.isEmpty()) {
if (debug) {
plugin.getLogger().info("跳过 " + player.getName() + ":客户端品牌为空");
}
return;
}
// 统一转换为小写进行比较,支持更多变体
String brandLower = clientBrand.toLowerCase();
if (brandLower.contains("fabric")) {
if (debug) {
plugin.getLogger().info("检测到 Fabric 客户端,开始发送配方同步...");
}
sendPlayerMessage(player, "Fabric");
sendFabricRecipeSync(player);
} else if (brandLower.contains("neoforge") || brandLower.contains("forge")) {
if (debug) {
plugin.getLogger().info("检测到 NeoForge/Forge 客户端,开始发送配方同步...");
}
sendPlayerMessage(player, "NeoForge");
sendNeoForgeRecipeSync(player);
} else {
if (debug) {
plugin.getLogger().info("跳过 " + player.getName() + ":不支持的客户端类型 '" + clientBrand + "'");
}
}
}
/**
* 发送提示消息给玩家
*/
private void sendPlayerMessage(Player player, String clientType) {
if (!sendPlayerMessage) {
return;
}
String messageKey;
if (clientType.equalsIgnoreCase("fabric")) {
messageKey = "messages.jei-sync-fabric";
} else if (clientType.equalsIgnoreCase("neoforge")) {
messageKey = "messages.jei-sync-neoforge";
} else {
return;
}
// 使用统一前缀 + 消息内容
String prefix = EssentialsC.getLangManager().getString("prefix");
String message = EssentialsC.getLangManager().getString(messageKey);
String fullMessage = prefix + " " + message;
net.kyori.adventure.text.Component component = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacyAmpersand().deserialize(fullMessage);
player.sendMessage(component);
}
/**
* 发送 Fabric 格式的配方同步数据包
*/
@SuppressWarnings({"unchecked", "deprecation"})
private void sendFabricRecipeSync(Player player) {
try {
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
MinecraftServer server = serverPlayer.level().getServer();
if (server == null) {
if (debug) plugin.getLogger().warning("服务器实例为 null");
return;
}
RecipeMap recipeMap = server.getRecipeManager().recipes;
if (debug) {
plugin.getLogger().info("开始构建 Fabric 配方数据");
}
// 创建 Fabric Payload与参考插件完全一致
var list = new ArrayList<FabricRecipeEntry>();
var seen = new HashSet<RecipeSerializer<?>>();
for (RecipeSerializer<?> serializer : BuiltInRegistries.RECIPE_SERIALIZER) {
if (!seen.add(serializer)) continue;
List<RecipeHolder<?>> recipes = new ArrayList<>();
for (RecipeHolder<?> holder : recipeMap.values()) {
if (holder.value().getSerializer() == serializer) {
recipes.add(holder);
}
}
if (!recipes.isEmpty()) {
RecipeSerializer<?> entrySerializer = recipes.get(0).value().getSerializer();
list.add(new FabricRecipeEntry(entrySerializer, recipes));
}
}
var payload = new FabricRecipeSyncPayload(list);
if (debug) {
plugin.getLogger().info("Fabric 配方条目数: " + list.size());
}
// 构建 buffer
RegistryFriendlyByteBuf buffer = new RegistryFriendlyByteBuf(
Unpooled.buffer(),
server.registryAccess()
);
// 使用 CODEC 编码(与参考插件完全一致)
var codec = getFabricCodec();
codec.encode(buffer, payload);
// 发送数据包
byte[] bytes = new byte[buffer.writerIndex()];
buffer.getBytes(0, bytes);
Identifier id = Identifier.fromNamespaceAndPath("fabric", "recipe_sync");
DiscardedPayload discardedPayload = new DiscardedPayload(id, bytes);
serverPlayer.connection.send(new ClientboundCustomPayloadPacket(discardedPayload));
if (debug) {
plugin.getLogger().info("已发送 Fabric 配方同步 [" + id + "], 大小: " + bytes.length + " bytes");
}
} catch (Exception e) {
plugin.getLogger().warning("发送 Fabric 配方同步失败: " + e.getMessage());
e.printStackTrace();
}
}
/**
* 获取 Fabric Codec
*/
@SuppressWarnings({"unchecked", "deprecation"})
private net.minecraft.network.codec.StreamCodec<RegistryFriendlyByteBuf, FabricRecipeSyncPayload> getFabricCodec() {
return FabricRecipeEntry.CODEC.apply(net.minecraft.network.codec.ByteBufCodecs.list())
.map(FabricRecipeSyncPayload::new, FabricRecipeSyncPayload::entries);
}
/**
* 发送 NeoForge 格式的配方同步数据包
*/
@SuppressWarnings({"unchecked", "deprecation"})
private void sendNeoForgeRecipeSync(Player player) {
try {
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
MinecraftServer server = serverPlayer.level().getServer();
if (server == null) {
if (debug) plugin.getLogger().warning("服务器实例为 null");
return;
}
RecipeMap recipeMap = server.getRecipeManager().recipes;
if (debug) {
plugin.getLogger().info("开始构建 NeoForge 配方数据");
}
// 获取所有配方类型
java.util.List<net.minecraft.world.item.crafting.RecipeType<?>> allRecipeTypes =
BuiltInRegistries.RECIPE_TYPE.stream().toList();
if (debug) {
plugin.getLogger().info("NeoForge 配方类型数: " + allRecipeTypes.size());
}
// 创建 NeoForge Payload与参考插件完全一致
var payload = createNeoForgePayload(allRecipeTypes, recipeMap);
// 构建 buffer
RegistryFriendlyByteBuf buffer = new RegistryFriendlyByteBuf(
Unpooled.buffer(),
server.registryAccess()
);
// 使用 STREAM_CODEC 编码(与参考插件完全一致)
var streamCodec = getNeoForgeStreamCodec();
streamCodec.encode(buffer, payload);
// 发送数据包
byte[] bytes = new byte[buffer.writerIndex()];
buffer.getBytes(0, bytes);
Identifier id = Identifier.fromNamespaceAndPath("neoforge", "recipe_content");
DiscardedPayload discardedPayload = new DiscardedPayload(id, bytes);
serverPlayer.connection.send(new ClientboundCustomPayloadPacket(discardedPayload));
// 发送 Tags 同步NeoForge 需要)
serverPlayer.connection.send(new net.minecraft.network.protocol.common.ClientboundUpdateTagsPacket(
net.minecraft.tags.TagNetworkSerialization.serializeTagsToNetwork(server.registries())
));
if (debug) {
plugin.getLogger().info("已发送 NeoForge 配方同步 [" + id + "], 大小: " + bytes.length + " bytes");
}
} catch (Exception e) {
plugin.getLogger().warning("发送 NeoForge 配方同步失败: " + e.getMessage());
e.printStackTrace();
}
}
/**
* 创建 NeoForge 配载对象
*/
private NeoForgeRecipeSyncPayload createNeoForgePayload(
java.util.List<net.minecraft.world.item.crafting.RecipeType<?>> recipeTypes,
RecipeMap recipeMap) {
var recipeTypeSet = new java.util.HashSet<>(recipeTypes);
if (recipeTypeSet.isEmpty()) {
return new NeoForgeRecipeSyncPayload(recipeTypeSet, java.util.List.of());
} else {
var recipeSubset = recipeMap.values().stream()
.filter(h -> recipeTypeSet.contains(h.value().getType()))
.toList();
return new NeoForgeRecipeSyncPayload(recipeTypeSet, recipeSubset);
}
}
/**
* 获取 NeoForge StreamCodec
*/
@SuppressWarnings({"unchecked", "deprecation"})
private net.minecraft.network.codec.StreamCodec<RegistryFriendlyByteBuf, NeoForgeRecipeSyncPayload> getNeoForgeStreamCodec() {
return net.minecraft.network.codec.StreamCodec.composite(
net.minecraft.network.codec.ByteBufCodecs.registry(net.minecraft.core.registries.Registries.RECIPE_TYPE)
.apply(net.minecraft.network.codec.ByteBufCodecs.collection(java.util.HashSet::new)),
NeoForgeRecipeSyncPayload::recipeTypes,
RecipeHolder.STREAM_CODEC.apply(net.minecraft.network.codec.ByteBufCodecs.list()),
NeoForgeRecipeSyncPayload::recipes,
NeoForgeRecipeSyncPayload::new
);
}
/**
* Fabric 配方条目
*/
@SuppressWarnings("deprecation")
private static class FabricRecipeEntry {
final Object serializer; // 使用 Object 避免 NMS 类型不兼容
final List<RecipeHolder<?>> recipes;
FabricRecipeEntry(Object serializer, List<RecipeHolder<?>> recipes) {
this.serializer = serializer;
this.recipes = recipes;
}
static final net.minecraft.network.codec.StreamCodec<RegistryFriendlyByteBuf, FabricRecipeEntry> CODEC =
net.minecraft.network.codec.StreamCodec.ofMember(
FabricRecipeEntry::write,
FabricRecipeEntry::read
);
@SuppressWarnings("unchecked")
private static FabricRecipeEntry read(RegistryFriendlyByteBuf buf) {
Identifier recipeSerializerId = buf.readIdentifier();
RecipeSerializer<?> recipeSerializer = BuiltInRegistries.RECIPE_SERIALIZER.getValue(recipeSerializerId);
if (recipeSerializer == null) {
throw new RuntimeException("Tried syncing unsupported packet serializer '" + recipeSerializerId + "'!");
}
int count = buf.readVarInt();
var list = new ArrayList<RecipeHolder<?>>();
for (int i = 0; i < count; i++) {
net.minecraft.resources.ResourceKey<net.minecraft.world.item.crafting.Recipe<?>> id =
buf.readResourceKey(net.minecraft.core.registries.Registries.RECIPE);
// 使用反射获取 streamCodec避免 NMS 类型不兼容
try {
var streamCodecMethod = recipeSerializer.getClass().getMethod("streamCodec");
var streamCodec = streamCodecMethod.invoke(recipeSerializer);
net.minecraft.world.item.crafting.Recipe<?> recipe =
((net.minecraft.network.codec.StreamCodec<RegistryFriendlyByteBuf, net.minecraft.world.item.crafting.Recipe<?>>) streamCodec)
.decode(buf);
list.add(new RecipeHolder<>(id, recipe));
} catch (Exception e) {
throw new RuntimeException("Failed to decode recipe: " + e.getMessage(), e);
}
}
return new FabricRecipeEntry(recipeSerializer, list);
}
private void write(RegistryFriendlyByteBuf buf) {
// 使用反射获取 key避免 NMS 类型不兼容
try {
var getKeyMethod = BuiltInRegistries.RECIPE_SERIALIZER.getClass().getMethod("getKey", Object.class);
Identifier identifier = (Identifier) getKeyMethod.invoke(BuiltInRegistries.RECIPE_SERIALIZER, this.serializer);
buf.writeIdentifier(identifier);
} catch (Exception e) {
throw new RuntimeException("Failed to get serializer key: " + e.getMessage(), e);
}
buf.writeVarInt(this.recipes.size());
// 使用反射获取 streamCodec避免 NMS 类型不兼容
try {
var streamCodecMethod = this.serializer.getClass().getMethod("streamCodec");
@SuppressWarnings("unchecked")
var codec = (net.minecraft.network.codec.StreamCodec<RegistryFriendlyByteBuf, net.minecraft.world.item.crafting.Recipe<?>>)
streamCodecMethod.invoke(this.serializer);
for (RecipeHolder<?> recipe : this.recipes) {
buf.writeResourceKey(recipe.id());
codec.encode(buf, recipe.value());
}
} catch (Exception e) {
throw new RuntimeException("Failed to encode recipe: " + e.getMessage(), e);
}
}
}
/**
* Fabric 配方同步 Payload
*/
private record FabricRecipeSyncPayload(List<FabricRecipeEntry> entries) {
}
/**
* NeoForge 配方同步 Payload
*/
private record NeoForgeRecipeSyncPayload(
java.util.Set<net.minecraft.world.item.crafting.RecipeType<?>> recipeTypes,
java.util.List<RecipeHolder<?>> recipes) {
}
}

View File

@@ -0,0 +1,64 @@
package cn.infstar.essentialsC.listeners;
import cn.infstar.essentialsC.EssentialsC;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDeathEvent;
/**
* 生物掉落物控制监听器
* 当前仅支持末影人
*/
public class MobDropListener implements Listener {
private final EssentialsC plugin;
private boolean endermanDropEnabled;
public MobDropListener(EssentialsC plugin) {
this.plugin = plugin;
loadConfig();
// 注册监听器
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
/**
* 加载配置
*/
private void loadConfig() {
FileConfiguration config = plugin.getConfig();
config.addDefault("mob-drops.enderman.enabled", true);
config.options().copyDefaults(true);
try {
config.save(plugin.getDataFolder().toPath().resolve("config.yml").toFile());
} catch (Exception e) {
plugin.getLogger().warning("无法保存配置文件: " + e.getMessage());
}
this.endermanDropEnabled = config.getBoolean("mob-drops.enderman.enabled", true);
}
@EventHandler
public void onEntityDeath(EntityDeathEvent event) {
if (event.getEntityType() != EntityType.ENDERMAN) {
return;
}
boolean enabled = plugin.getConfig().getBoolean("mob-drops.enderman.enabled", true);
if (!enabled) {
event.getDrops().clear();
}
}
/**
* 重新加载配置
*/
public void reload() {
loadConfig();
plugin.getLogger().info("生物掉落物配置已重载(末影人: " + (endermanDropEnabled ? "开启" : "关闭") + "");
}
}

View File

@@ -0,0 +1,101 @@
package cn.infstar.essentialsC.listeners;
import cn.infstar.essentialsC.EssentialsC;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.Arrays;
public class MobDropMenuListener implements Listener {
private final EssentialsC plugin;
public MobDropMenuListener(EssentialsC plugin) {
this.plugin = plugin;
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
if (!event.getView().getTitle().equals("§6§l生物掉落控制")) {
return;
}
event.setCancelled(true);
if (!(event.getWhoClicked() instanceof Player player)) {
return;
}
ItemStack clickedItem = event.getCurrentItem();
if (clickedItem == null) {
return;
}
if (event.getSlot() == 13) {
toggleEndermanDrops(player);
Bukkit.getScheduler().runTaskLater(plugin, () -> openMobDropMenu(player), 2L);
}
}
private void toggleEndermanDrops(Player player) {
FileConfiguration config = plugin.getConfig();
boolean currentValue = config.getBoolean("mob-drops.enderman.enabled", true);
boolean newValue = !currentValue;
config.set("mob-drops.enderman.enabled", newValue);
try {
config.save(plugin.getDataFolder().toPath().resolve("config.yml").toFile());
} catch (Exception e) {
player.sendMessage(EssentialsC.getLangManager().getString("prefix") +
EssentialsC.getLangManager().getString("messages.mobdrop-save-failed",
java.util.Map.of("error", e.getMessage())));
return;
}
String status = newValue ? "§a开启" : "§c关闭";
player.sendMessage(EssentialsC.getLangManager().getString("prefix") +
EssentialsC.getLangManager().getString("messages.mobdrop-toggled",
java.util.Map.of("status", status)));
}
private void openMobDropMenu(Player player) {
boolean endermanEnabled = plugin.getConfig().getBoolean("mob-drops.enderman.enabled", true);
Inventory menu = Bukkit.createInventory(null, 27, "§6§l生物掉落控制");
ItemStack endermanItem = new ItemStack(Material.ENDER_PEARL);
ItemMeta endermanMeta = endermanItem.getItemMeta();
endermanMeta.setDisplayName("§d末影人掉落");
endermanMeta.setLore(Arrays.asList(
"§7当前状态: " + (endermanEnabled ? "§a✅ 开启" : "§c❌ 关闭"),
"",
"§e点击切换状态"
));
endermanItem.setItemMeta(endermanMeta);
menu.setItem(13, endermanItem);
ItemStack glass = new ItemStack(Material.BLACK_STAINED_GLASS_PANE);
ItemMeta glassMeta = glass.getItemMeta();
glassMeta.setDisplayName(" ");
glass.setItemMeta(glassMeta);
for (int i = 0; i < 27; i++) {
if (menu.getItem(i) == null) {
menu.setItem(i, glass);
}
}
player.openInventory(menu);
}
}

View File

@@ -0,0 +1,356 @@
package cn.infstar.essentialsC.listeners;
import cn.infstar.essentialsC.EssentialsC;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.ShulkerBox;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BlockStateMeta;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
public class ShulkerBoxListener implements Listener {
private final EssentialsC plugin;
// 存储玩家打开的潜影盒玩家UUID -> (原始物品快照, 当前物品引用)
private final Map<UUID, ShulkerBoxData> openShulkerBoxes = new HashMap<>();
// 预定义所有潜影盒材质(性能优化)
private static final Set<Material> SHULKER_BOX_MATERIALS = Set.of(
Material.SHULKER_BOX,
Material.WHITE_SHULKER_BOX,
Material.ORANGE_SHULKER_BOX,
Material.MAGENTA_SHULKER_BOX,
Material.LIGHT_BLUE_SHULKER_BOX,
Material.YELLOW_SHULKER_BOX,
Material.LIME_SHULKER_BOX,
Material.PINK_SHULKER_BOX,
Material.GRAY_SHULKER_BOX,
Material.LIGHT_GRAY_SHULKER_BOX,
Material.CYAN_SHULKER_BOX,
Material.PURPLE_SHULKER_BOX,
Material.BLUE_SHULKER_BOX,
Material.BROWN_SHULKER_BOX,
Material.GREEN_SHULKER_BOX,
Material.RED_SHULKER_BOX,
Material.BLACK_SHULKER_BOX
);
/**
* 潜影盒 Inventory Holder - 用于识别自定义 inventory
*/
private static class ShulkerBoxHolder implements org.bukkit.inventory.InventoryHolder {
private final Inventory inventory;
private final ItemStack shulkerBoxItem;
private final ItemStack[] currentContents; // 实时追踪的物品内容
ShulkerBoxHolder(ItemStack shulkerBoxItem, String title) {
this.shulkerBoxItem = shulkerBoxItem;
this.inventory = Bukkit.createInventory(this, 27, title);
this.currentContents = new ItemStack[27];
}
@Override
public @NotNull Inventory getInventory() {
return this.inventory;
}
public ItemStack getShulkerBoxItem() {
return shulkerBoxItem;
}
/**
* 更新指定槽位的物品(供外部调用)
*/
public void updateSlot(int slot, ItemStack item) {
if (slot >= 0 && slot < 27) {
currentContents[slot] = item;
}
}
/**
* 获取当前追踪的所有物品内容
*/
public ItemStack[] getCurrentContents() {
return currentContents.clone();
}
}
/**
* 潜影盒数据记录
*/
private static class ShulkerBoxData {
int slotIndex; // 玩家背包中的槽位索引
ItemStack originalSnapshot; // 打开时的物品快照(用于验证)
int totalItems; // 打开时的物品总数(用于防刷)
ShulkerBoxData(int slot, ItemStack snapshot, int items) {
this.slotIndex = slot;
this.originalSnapshot = snapshot;
this.totalItems = items;
}
}
public ShulkerBoxListener(EssentialsC plugin) {
this.plugin = plugin;
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
// 只处理右键点击空气或方块的事件
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) {
return;
}
Player player = event.getPlayer();
// 检查权限
if (!player.hasPermission("essentialsc.shulkerbox.open")) {
return;
}
ItemStack item = event.getItem();
if (item == null || !isShulkerBox(item)) {
return;
}
// 只有潜行+右键才打开潜影盒
if (!player.isSneaking()) {
return;
}
// 取消默认行为(防止放置潜影盒)
event.setCancelled(true);
// 查找物品在玩家背包中的槽位
int slotIndex = -1;
for (int i = 0; i < player.getInventory().getSize(); i++) {
ItemStack invItem = player.getInventory().getItem(i);
if (invItem != null && invItem.isSimilar(item)) {
slotIndex = i;
break;
}
}
// 打开潜影盒(传入槽位索引)
openShulkerBox(player, item, slotIndex);
}
@EventHandler
public void onInventoryClose(InventoryCloseEvent event) {
if (!(event.getPlayer() instanceof Player player)) {
return;
}
Inventory closedInventory = event.getInventory();
// 检查是否是潜影盒 inventory
if (!(closedInventory.getHolder(false) instanceof ShulkerBoxHolder holder)) {
return;
}
UUID playerId = player.getUniqueId();
ShulkerBoxData data = openShulkerBoxes.remove(playerId);
if (data == null) {
return;
}
plugin.getLogger().info("=== 潜影盒关闭(数据已在点击时实时保存) ===");
}
@EventHandler
public void onInventoryOpen(org.bukkit.event.inventory.InventoryOpenEvent event) {
if (!(event.getPlayer() instanceof Player player)) {
return;
}
Inventory openedInventory = event.getInventory();
if (openedInventory.getHolder(false) instanceof ShulkerBoxHolder) {
plugin.getLogger().info("[Open] ✅ 潜影盒 inventory 已打开");
}
}
@EventHandler(priority = org.bukkit.event.EventPriority.LOWEST)
public void onInventoryClickDebug(InventoryClickEvent event) {
if (!(event.getWhoClicked() instanceof Player player)) {
return;
}
Inventory clickedInventory = event.getClickedInventory();
if (clickedInventory == null) {
return;
}
if (clickedInventory.getHolder(false) instanceof ShulkerBoxHolder) {
plugin.getLogger().info("[Click-LOWEST] 检测到点击事件 | 槽位: " + event.getSlot() +
" | 物品: " + (event.getCurrentItem() != null ? event.getCurrentItem().getType() : "null"));
}
}
if (!(event.getWhoClicked() instanceof Player player)) {
return;
}
Inventory clickedInventory = event.getClickedInventory();
if (clickedInventory == null) {
return;
}
// 检查是否是潜影盒 inventory
if (!(clickedInventory.getHolder(false) instanceof ShulkerBoxHolder holder)) {
return;
}
UUID playerId = player.getUniqueId();
ShulkerBoxData data = openShulkerBoxes.get(playerId);
if (data == null) {
return;
}
// 阻止嵌套潜影盒
ItemStack clickedItem = event.getCurrentItem();
if (clickedItem != null && isShulkerBox(clickedItem)) {
event.setCancelled(true);
player.sendMessage(EssentialsC.getLangManager().getString("prefix") +
EssentialsC.getLangManager().getString("messages.shulkerbox-nested"));
return;
}
// ✅ CMILib 方式:延迟 1 tick 后立即保存到潜影盒 NBT
plugin.getServer().getScheduler().runTask(plugin, () -> {
plugin.getLogger().info("[Click] === 开始处理点击事件 ===");
// 读取当前 inventory 内容
ItemStack[] contents = clickedInventory.getContents();
// 调试
int nonEmpty = 0;
StringBuilder items = new StringBuilder();
for (int i = 0; i < contents.length; i++) {
if (contents[i] != null && !contents[i].getType().isAir()) {
nonEmpty++;
items.append(String.format("\n [%d] %s x%d", i, contents[i].getType(), contents[i].getAmount()));
}
}
plugin.getLogger().info("[Click] 非空槽位: " + nonEmpty);
plugin.getLogger().info("[Click] 物品详情:" + items);
// 获取玩家背包中的潜影盒物品
ItemStack shulkerItem = null;
if (data.slotIndex >= 0 && data.slotIndex < player.getInventory().getSize()) {
shulkerItem = player.getInventory().getItem(data.slotIndex);
plugin.getLogger().info("[Click] 槽位 " + data.slotIndex + " 物品: " +
(shulkerItem != null ? shulkerItem.getType() : "null"));
}
if (shulkerItem == null || shulkerItem.getType().isAir()) {
plugin.getLogger().warning("[Click] ❌ 潜影盒物品不存在");
return;
}
// 更新潜影盒的 BlockState
if (shulkerItem.getItemMeta() instanceof BlockStateMeta blockStateMeta) {
if (blockStateMeta.getBlockState() instanceof ShulkerBox shulkerBox) {
// 设置 inventory 内容
for (int i = 0; i < 27 && i < contents.length; i++) {
shulkerBox.getInventory().setItem(i, contents[i]);
}
// 更新元数据
blockStateMeta.setBlockState(shulkerBox);
shulkerItem.setItemMeta(blockStateMeta);
// 写回玩家背包
player.getInventory().setItem(data.slotIndex, shulkerItem);
plugin.getLogger().info("[Click] ✅ 已实时保存 " + nonEmpty + " 个物品槽");
} else {
plugin.getLogger().warning("[Click] ❌ BlockState 不是 ShulkerBox");
}
} else {
plugin.getLogger().warning("[Click] ❌ 没有 BlockStateMeta");
}
});
}
/**
* 检查物品是否为潜影盒O(1) 时间复杂度)
*/
private boolean isShulkerBox(ItemStack item) {
return SHULKER_BOX_MATERIALS.contains(item.getType());
}
/**
* 打开潜影盒
*/
private void openShulkerBox(Player player, ItemStack shulkerBox, int slotIndex) {
// 获取潜影盒的 BlockStateMeta
if (!(shulkerBox.getItemMeta() instanceof BlockStateMeta blockStateMeta)) {
return;
}
// 获取潜影盒的方块状态
if (!(blockStateMeta.getBlockState() instanceof ShulkerBox shulkerBoxBlock)) {
return;
}
// 创建物品快照(用于后续验证)
ItemStack snapshot = shulkerBox.clone();
// 计算当前物品总数(用于防刷检查)
int totalItems = 0;
for (ItemStack item : shulkerBoxBlock.getInventory().getContents()) {
if (item != null && !item.getType().isAir()) {
totalItems += item.getAmount();
}
}
// 获取潜影盒的自定义名称,如果没有则使用配置中的默认标题
String title;
if (shulkerBox.hasItemMeta() && shulkerBox.getItemMeta().hasDisplayName()) {
// 使用潜影盒的自定义名称
title = shulkerBox.getItemMeta().getDisplayName();
} else {
// 使用配置文件中的默认标题
String defaultTitle = plugin.getConfig().getString("shulkerbox.default-title", "");
if (defaultTitle != null && !defaultTitle.isEmpty()) {
// 转换颜色代码 & -> §
title = defaultTitle.replace('&', '§');
} else {
// 如果配置为空,使用 "Shulker Box"(客户端会自动翻译)
title = "Shulker Box";
}
}
// 创建 ShulkerBoxHolder会自动创建 inventory
ShulkerBoxHolder holder = new ShulkerBoxHolder(shulkerBox, title);
Inventory inventory = holder.getInventory();
// 复制潜影盒的内容到 inventory
ItemStack[] contents = shulkerBoxBlock.getInventory().getContents();
for (int i = 0; i < 27 && i < contents.length; i++) {
inventory.setItem(i, contents[i]);
}
// 记录玩家打开的潜影盒(保存槽位索引和快照)
openShulkerBoxes.put(player.getUniqueId(), new ShulkerBoxData(slotIndex, snapshot, totalItems));
// 打开 inventory
player.openInventory(inventory);
}
}

View File

@@ -10,5 +10,95 @@ settings:
# 启用或禁用命令反馈消息 # 启用或禁用命令反馈消息
enable-feedback: true enable-feedback: true
# 所有插件消息的前缀 # 功能方块菜单配置
message-prefix: "&6[EssentialsC] &r" blocks-menu:
title: "&6&lEssentialsC &8- &e&l功能方块菜单"
items:
workbench:
slot: 10
material: CRAFTING_TABLE
name: "&e工作台"
lore:
- "&7/workbench"
- "&7打开工作台"
permission: essentialsc.command.workbench
anvil:
slot: 11
material: ANVIL
name: "&e铁砧"
lore:
- "&7/anvil"
- "&7打开铁砧"
permission: essentialsc.command.anvil
cartographytable:
slot: 19
material: CARTOGRAPHY_TABLE
name: "&e制图台"
lore:
- "&7/cartographytable"
- "&7打开制图台"
permission: essentialsc.command.cartographytable
grindstone:
slot: 20
material: GRINDSTONE
name: "&e砂轮"
lore:
- "&7/grindstone"
- "&7打开砂轮"
permission: essentialsc.command.grindstone
loom:
slot: 21
material: LOOM
name: "&e织布机"
lore:
- "&7/loom"
- "&7打开织布机"
permission: essentialsc.command.loom
smithingtable:
slot: 22
material: SMITHING_TABLE
name: "&e锻造台"
lore:
- "&7/smithingtable"
- "&7打开锻造台"
permission: essentialsc.command.smithingtable
stonecutter:
slot: 23
material: STONECUTTER
name: "&e切石机"
lore:
- "&7/stonecutter"
- "&7打开切石机"
permission: essentialsc.command.stonecutter
enderchest:
slot: 31
material: ENDER_CHEST
name: "&e末影箱"
lore:
- "&7/enderchest"
- "&7打开末影箱"
permission: essentialsc.command.enderchest
# 潜影盒设置
shulkerbox:
# 潜影盒默认标题(当潜影盒没有自定义名称时使用)
# 支持颜色代码(使用 & 符号)
# 留空则使用 "Shulker Box"(客户端语言)
default-title: "&e潜影盒"
# JEI/REI 配方同步设置MC 1.21.2+
# 解决 Fabric/NeoForge 客户端配方不同步问题
jei-sync:
# 是否启用 JEI 配方同步功能
enabled: true
# 是否在控制台显示同步日志
debug: true
# 是否向玩家发送同步提示消息
send-player-message: true
# 生物掉落物控制
mob-drops:
# 末影人掉落物控制
enderman:
# 是否允许末影人死亡后掉落物品和经验
enabled: true

View File

@@ -1,6 +1,9 @@
# English Language File (en_US) # English Language File (en_US)
# You can customize all messages here # You can customize all messages here
# Plugin prefix
prefix: "&6[EssentialsC] &r"
# Command messages # Command messages
messages: messages:
no-permission: "&cYou don't have permission to use this command!\n&7Required permission: {permission}" no-permission: "&cYou don't have permission to use this command!\n&7Required permission: {permission}"
@@ -14,20 +17,6 @@ messages:
vanish-enabled: "&aYou are now vanished!" vanish-enabled: "&aYou are now vanished!"
vanish-disabled: "&cYou are no longer vanished!" vanish-disabled: "&cYou are no longer vanished!"
seen-usage: "&cUsage: /seen <player>" seen-usage: "&cUsage: /seen <player>"
admin-menu-title: "&6EssentialsC Admin Menu"
admin-time-control: "&eTime Control"
admin-weather-control: "&eWeather Control"
admin-heal-self: "&aHeal Self"
admin-feed-self: "&aFeed Self"
admin-repair-hand: "&aRepair Hand Item"
admin-vanish: "&dVanish Mode"
admin-reload: "&dReload Plugin"
admin-time-set: "&aTime set!"
admin-weather-set: "&aWeather set!"
admin-heal-success: "&aHealed!"
admin-feed-success: "&aFed!"
admin-repair-success: "&aRepaired!"
admin-reload-success: "&aConfig reloaded!"
anvil-opened: "&aAnvil opened!" anvil-opened: "&aAnvil opened!"
enchantingtable-opened: "&aEnchanting table opened!" enchantingtable-opened: "&aEnchanting table opened!"
heal-self: "&aYour health and hunger have been restored!" heal-self: "&aYour health and hunger have been restored!"
@@ -69,6 +58,5 @@ help:
heal: " &f/heal &7- Restore health and hunger" heal: " &f/heal &7- Restore health and hunger"
vanish: " &f/vanish &7- Toggle vanish mode" vanish: " &f/vanish &7- Toggle vanish mode"
seen: " &f/seen &7- View player information" seen: " &f/seen &7- View player information"
admin: " &f/admin &7- Open admin menu"
feed: " &f/feed &7- Restore hunger" feed: " &f/feed &7- Restore hunger"
repair: " &f/repair &7- Repair hand or all items" repair: " &f/repair &7- Repair hand or all items"

View File

@@ -1,6 +1,9 @@
# Chinese Language File (zh_CN) # Chinese Language File (zh_CN)
# 中文语言文件 # 中文语言文件
# 插件前缀
prefix: "&7[&6EssentialsC&7]&f:"
# 命令消息 # 命令消息
messages: messages:
no-permission: "&c你没有权限执行此命令\n&7需要权限: {permission}" no-permission: "&c你没有权限执行此命令\n&7需要权限: {permission}"
@@ -14,20 +17,6 @@ messages:
vanish-enabled: "&a你已进入隐身模式" vanish-enabled: "&a你已进入隐身模式"
vanish-disabled: "&c你已退出隐身模式" vanish-disabled: "&c你已退出隐身模式"
seen-usage: "&c用法: /seen <玩家名>" seen-usage: "&c用法: /seen <玩家名>"
admin-menu-title: "&6EssentialsC 管理菜单"
admin-time-control: "&e时间控制"
admin-weather-control: "&e天气控制"
admin-heal-self: "&a治疗自己"
admin-feed-self: "&a喂饱自己"
admin-repair-hand: "&a修复手中物品"
admin-vanish: "&d隐身模式"
admin-reload: "&d重载插件"
admin-time-set: "&a时间已设置"
admin-weather-set: "&a天气已设置"
admin-heal-success: "&a已治疗"
admin-feed-success: "&a已喂饱"
admin-repair-success: "&a已修复"
admin-reload-success: "&a配置已重载"
anvil-opened: "&a已打开铁砧" anvil-opened: "&a已打开铁砧"
enchantingtable-opened: "&a已打开附魔台" enchantingtable-opened: "&a已打开附魔台"
heal-self: "&a你的生命值和饱食度已补满" heal-self: "&a你的生命值和饱食度已补满"
@@ -44,6 +33,14 @@ messages:
no-permission-repair-all: "&c你没有权限修复所有物品" no-permission-repair-all: "&c你没有权限修复所有物品"
player-not-found: "&c未找到玩家: {player}" player-not-found: "&c未找到玩家: {player}"
no-permission-others: "&c你没有权限治疗其他玩家" no-permission-others: "&c你没有权限治疗其他玩家"
seen-usage-console: "&c用法: /seen <玩家名>"
unknown-subcommand: "&c未知子命令: {command}"
help-usage: "&7使用 §f/essc help &7查看所有可用命令"
mobdrop-save-failed: "&c保存配置失败: {error}"
mobdrop-toggled: "&a末影人掉落已{status}"
shulkerbox-nested: "&c不能在潜影盒中放入另一个潜影盒"
jei-sync-fabric: "&6JEI-FIX&8(&bFabric&8):&e正在同步合成配方..."
jei-sync-neoforge: "&6JEI-FIX&8(&bNeoForge&8):&e正在同步合成配方..."
# 帮助命令 # 帮助命令
help: help:
@@ -69,6 +66,6 @@ help:
heal: " &f/heal &7- 恢复生命值和饱食度" heal: " &f/heal &7- 恢复生命值和饱食度"
vanish: " &f/vanish &7- 切换隐身模式" vanish: " &f/vanish &7- 切换隐身模式"
seen: " &f/seen &7- 查看玩家信息" seen: " &f/seen &7- 查看玩家信息"
admin: " &f/admin &7- 打开管理菜单"
feed: " &f/feed &7- 补满饱食度" feed: " &f/feed &7- 补满饱食度"
repair: " &f/repair &7- 修复手中或所有物品" repair: " &f/repair &7- 修复手中或所有物品"
blocks: " &f/blocks &7- 打开功能方块菜单"

View File

@@ -1,10 +1,11 @@
name: EssentialsC name: EssentialsC
description: 精简版基础插件 description: 精简版基础插件
version: '${version}' version: ${version}
main: cn.infstar.essentialsC.EssentialsC main: cn.infstar.essentialsC.EssentialsC
api-version: '1.21' api-version: '1.21'
load: POSTWORLD load: POSTWORLD
folia-supported: true
authors: [ Coldsmiles_7 ] authors: [ Coldsmiles_7 ]
website: www.infstar.cn website: www.infstar.cn
@@ -55,18 +56,27 @@ permissions:
essentialsc.command.seen: essentialsc.command.seen:
description: Allows use of /seen command description: Allows use of /seen command
default: op default: op
essentialsc.command.admin:
description: Allows use of /admin command
default: op
essentialsc.command.feed: essentialsc.command.feed:
description: Allows use of /feed command description: Allows use of /feed command
default: op default: op
essentialsc.command.repair: essentialsc.command.repair:
description: Allows use of /repair command description: Allows use of /repair command
default: op default: op
essentialsc.command.blocks:
description: Allows use of /essc blocks command
default: true
essentialsc.command.help: essentialsc.command.help:
description: Allows use of /essentialsc help command description: Allows use of /essentialsc help command
default: true default: true
essentialsc.command.reload:
description: Allows use of /essc reload command
default: op
essentialsc.shulkerbox.open:
description: Allows right-click to open shulker boxes without placing them
default: op
essentialsc.mobdrops.enderman:
description: Allows control of enderman drops
default: op
essentialsc.*: essentialsc.*:
description: All EssentialsC permissions description: All EssentialsC permissions
default: false default: false
@@ -86,7 +96,9 @@ permissions:
essentialsc.command.heal: true essentialsc.command.heal: true
essentialsc.command.vanish: true essentialsc.command.vanish: true
essentialsc.command.seen: true essentialsc.command.seen: true
essentialsc.command.admin: true essentialsc.command.reload: true
essentialsc.command.feed: true essentialsc.command.feed: true
essentialsc.command.repair: true essentialsc.command.repair: true
essentialsc.command.help: true essentialsc.command.help: true
essentialsc.shulkerbox.open: true
essentialsc.mobdrops.enderman: true