Skip to content

Commit 34153e1

Browse files
committed
[Refactor] refactor entire plugin and rename to WorldUtils
0 parents  commit 34153e1

16 files changed

Lines changed: 1580 additions & 0 deletions

File tree

‎.github/workflows/build.yml‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: WorldUtils Build
2+
3+
on:
4+
push:
5+
branches:
6+
- "**"
7+
pull_request:
8+
branches:
9+
- "**"
10+
11+
jobs:
12+
build:
13+
if: contains(github.event.head_commit.message, '[actions skip]') == false
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout Git Repository
17+
uses: actions/checkout@v6
18+
19+
- name: Set Up JDK
20+
uses: actions/setup-java@v5
21+
with:
22+
distribution: zulu
23+
java-version: 21
24+
25+
- name: Build with Maven
26+
run: mvn -B package
27+
28+
- name: Upload Artifact
29+
uses: actions/upload-artifact@v5
30+
with:
31+
name: Build Artifacts
32+
path: target/WorldUtils-*-SNAPSHOT.jar

‎LICENSE‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 StarryMC
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎README.md‎

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
<div align="center">
2+
<h1>WorldUtils</h1>
3+
4+
[![Build Status](https://img.shields.io/badge/build-passing-brightgreen.svg)](https://github.com/StarCodeClub/WorldUtils) [![Version](https://img.shields.io/badge/version-1.3.3--SNAPSHOT-blue.svg)](https://github.com/StarCodeClub/WorldUtils/releases) [![Minecraft](https://img.shields.io/badge/minecraft-1.20.X--latest-green.svg)](https://www.spigotmc.org/) [![Folia](https://img.shields.io/badge/folia-supported-pink)](https://papermc.io/downloads/folia) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
5+
6+
<h4>适用于高版本 Paper、Folia 的 Minecraft 服务端的插件,提供许多有关世界的实用功能和设置</h4>
7+
<h4>Language: 简体中文 | [English](README_en.md)</h4>
8+
</div>
9+
10+
## ✨ 特性
11+
12+
- **🔧 灵活**:层次化配置系统,支持配置继承,简单明确地完成功能设置
13+
- **🔒 世界保护**:提供 9 种世界保护
14+
- **🌍 独立世界属性**: 为每个世界设置单独的 GameMode
15+
- **💬 消息**:支持使用下一代 MiniMessage 格式,ActionBar 提示玩家更加优雅,已做频繁触发优化
16+
- **⚡ High Performance**:极度轻量,无冗余代码,插件大小仅65KB
17+
- **🎯 权限系统**:精细的权限控制,支持使用权限绕过特定保护
18+
19+
## 🚀 快速开始
20+
21+
### 1.使用预编译二进制文件
22+
**进入 [Releases](https://github.com/StarCodeClub/WorldUtils/releases) 获取最新的预编译版本**
23+
24+
### 2.自行编译
25+
26+
- **Java 21** 或更高版本
27+
- **Maven 3.6+** (仅编译时需要)
28+
29+
1. 克隆仓库:
30+
```bash
31+
git clone https://github.com/StarCodeClub/WorldUtils.git
32+
cd WorldUtils
33+
```
34+
35+
2. 编译插件:
36+
```bash
37+
mvn clean package
38+
```
39+
40+
3. 编译完成后,在 `target/` 目录下找到 `WorldUtils-1.3.0-SNAPSHOT.jar`
41+
42+
## 📖 使用方法
43+
44+
### 配置文件结构
45+
46+
```yaml
47+
# 插件前缀 (MiniMessage 格式)
48+
plugin-prefix: "<shadow:#000000FF><gradient:#ff7300:#ff3c00><b>[WU]</b></gradient></shadow>"
49+
50+
# 世界配置文件
51+
configs:
52+
# 配置文件必须包含 default 节点,请勿删除!!!
53+
default:
54+
# 禁止玩家修改世界(放置方块,填充水、岩浆,放置画,修改物品展示框和花盆...)
55+
anti-world-edit: false
56+
# 禁止玩家 pvp (玩家互相伤害)
57+
anti-pvp: false
58+
# 禁止玩家进入世界 (folia 上无法立刻拦截,但于在2s内将会传送至 Fallback World)
59+
anti-player-enter: false
60+
# 如果发现玩家处于禁止进入的世界,将会将玩家传送至该世界出生点
61+
world-enter-fallback: "world"
62+
# 使爆炸在该世界不破坏方块 (EntityExplodeEvent)
63+
anti-explosion: false
64+
# 禁止玩家与该世界的方块交互 (打开容器,使用工作台等) (PlayerInteractEvent)
65+
anti-block-interaction: false
66+
# 禁止玩家在此世界使用物品 (丢雪球、鸡蛋,射箭,使用刷怪蛋等)
67+
anti-use-item: false
68+
# 禁止玩家攻击该世界的实体 (不包含玩家互相伤害)
69+
anti-attack-entity: false
70+
# 禁止玩家在该世界与实体交互 (骑乘坐骑,与村民交易等) (onPlayerInteractEntity)
71+
anti-entity-interaction: false
72+
# 禁止玩家在该世界捡起或丢弃物品 (PlayerPickupItemEvent, PlayerDropItemEvent)
73+
anti-pickup-drop-items: false
74+
75+
# 为每个世界切换单独的游戏模式, 设置为空则为不更改
76+
world-gamemode: ""
77+
# 强制保持玩家在此世界的游戏模式
78+
# 需设置 world-gamemode 才会生效
79+
force-world-gamemode: false
80+
81+
# 玩家无权限时 ActionBar 显示的提示 (MiniMessage 格式)
82+
# 已做频繁触发优化,1s 内只会发送一次, 填空字符串 "" 则不会向玩家发送
83+
message:
84+
anti-world-edit: "{plugin-prefix} <red>你没有权限修改这个世界.</red>"
85+
anti-pvp: "{plugin-prefix} <red>已禁止在该世界 PVP.</red>"
86+
# ... 其他消息
87+
88+
# 继承配置示例
89+
common:
90+
parent: default # 继承 default 配置
91+
anti-world-edit: true
92+
anti-explosion: true
93+
94+
hub-config:
95+
parent: common # 继承 common 配置
96+
anti-block-interaction: true
97+
anti-attack-entity: true
98+
99+
# 指定哪些世界使用哪个配置
100+
world-config:
101+
"world": common # world 世界使用 common 配置
102+
"hub": hub-config # hub 世界使用 hub-config 配置
103+
"world_the_end": disable # 在此世界禁用 WorldUtils
104+
```
105+
106+
### 功能说明
107+
108+
| 保护类型 | 说明 | 涵盖事件 | Folia 支持 |
109+
|---------------------------|-----------|-------------------------|----------------------------------|
110+
| `anti-world-edit` | 禁止修改世界 | 禁止方块放置/破坏、桶操作、画/物品展示框交互 | 完整支持✅ |
111+
| `anti-pvp` | 禁止玩家之间战斗 | 取消玩家间伤害 | 完整支持✅ |
112+
| `anti-player-enter` | 禁止玩家进入世界 | 拦截世界切换传送 | 无法立刻拦截,但可以在2s内传送至 fallback world |
113+
| `anti-explosion` | 禁止爆炸破坏方块 | 阻止TNT、苦力怕、烈焰弹爆炸 (非实体破坏) | 完整支持✅ |
114+
| `anti-block-interaction` | 禁止与方块交互 | 拦截打开容器,使用工作台等 | 完整支持✅ |
115+
| `anti-attack-entity` | 禁止攻击实体 | 禁止攻击或杀死非玩家实体 | 完整支持✅ |
116+
| `anti-entity-interaction` | 禁止与实体交互 | 拦截骑乘坐骑,使用栓绳,与村民交易等 | 完整支持✅ |
117+
| `anti-pickup-drop-items` | 禁止丢弃/拿取物品 | 禁止玩家在该世界捡起或丢弃物品 | 完整支持✅ |
118+
| `anti-use-item` | 禁止使用物品 | 拦截丢雪球、鸡蛋,射箭,使用刷怪蛋等 | 完整支持✅ |
119+
| `world-gamemode` | 独立世界游戏模式 | 切换世界时更改游戏模式 | 完整支持✅ |
120+
121+
## 🎮 命令与权限
122+
123+
### 命令列表
124+
125+
| 命令 | 说明 | 权限 |
126+
|---------------------------------------------------|------------|------------|
127+
| `/wu help` | 显示帮助信息 | `wu.admin` |
128+
| `/wu status` | 查看保护设置总览 | `wu.admin` |
129+
| `/wu status <world>` | 查看指定世界保护设置 | `wu.admin` |
130+
| `/wu set-config <world> <protect_config/disable>` | 切换某世界的保护配置 | `wu.admin` |
131+
| `/wu reload` | 重载配置文件 | `wu.admin` |
132+
| `/wu version` | 显示插件版本 | `wu.admin` |
133+
134+
### 权限系统
135+
本插件无任何默认权限
136+
#### 管理员权限
137+
- `wu.admin` - 使用所有 /wu 命令(默认:OP)
138+
139+
#### 绕过权限
140+
- `wu.bypass.*` - 绕过所有世界保护(默认:OP)
141+
- `wu.bypass.<world>.anti-world-edit` - 绕过指定世界的世界编辑保护
142+
- `wu.bypass.<world>.anti-pvp` - 绕过指定世界的 PVP 保护
143+
- `wu.bypass.<world>.anti-player-enter` - 绕过指定世界的进入保护
144+
- `wu.bypass.<world>.anti-block-interaction` - 绕过指定世界的方块交互保护
145+
- `wu.bypass.<world>.anti-attack-entity` - 绕过指定世界的攻击实体保护
146+
- `wu.bypass.<world>.anti-entity-interaction` - 绕过指定世界的实体交互保护
147+
- `wu.bypass.<world>.anti-pickup-drop-items` - 绕过指定世界的丢弃/拿取物品保护
148+
- `wu.bypass.<world>.anti-use-item` - 绕过指定世界的使用物品保护
149+
- `wu.bypass.change-gamemode` - 拥有次权限 WU 将不会修改您的游戏模式
150+
---
151+
152+
如果您遇到问题或有功能建议,请在 [GitHub Issues](https://github.com/StarCodeClub/WorldUtils/issues) 提交。
153+
本项目采用 MIT 许可证,详见 [LICENSE](LICENSE) 文件。

‎README_en.md‎

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
<div align="center">
2+
<h1>WorldUtils</h1>
3+
4+
[![Build Status](https://img.shields.io/badge/build-passing-brightgreen.svg)](https://github.com/StarCodeClub/WorldUtils) [![Version](https://img.shields.io/badge/version-1.3.3--SNAPSHOT-blue.svg)](https://github.com/StarCodeClub/WorldUtils/releases) [![Minecraft](https://img.shields.io/badge/minecraft-1.20.X--latest-green.svg)](https://www.spigotmc.org/) [![Folia](https://img.shields.io/badge/folia-supported-pink)](https://papermc.io/downloads/folia) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
5+
6+
<h4>A plugin for high-version Paper, Folia Minecraft servers, providing many practical world-related features and settings</h4>
7+
</div>
8+
9+
> [!WARNING]
10+
>
11+
> This plugin does not yet support multiple languages and currently only has a Simplified Chinese version.
12+
> If you are a user of other languages, please wait for further updates.
13+
14+
## ✨ Features
15+
16+
- **🔧 Flexible**: Hierarchical configuration system with support for configuration inheritance, making feature settings simple and clear
17+
- **🔒 World Protection**: Provides 9 types of world protection
18+
- **🌍 Independent World Properties**: Set separate GameMode for each world
19+
- **💬 Messages**: Supports next-generation MiniMessage format, ActionBar notifications for players are more elegant, optimized for frequent triggers
20+
- **⚡ High Performance**: Extremely lightweight, no redundant code, plugin size only 65KB
21+
- **🎯 Permission System**: Fine-grained permission control, supports using permissions to bypass specific protections
22+
23+
## 🚀 Quick Start
24+
25+
### 1. Using Pre-compiled Binaries
26+
**Visit [Releases](https://github.com/StarCodeClub/WorldUtils/releases) to get the latest pre-compiled version**
27+
28+
### 2. Build Yourself
29+
30+
- **Java 21** or higher
31+
- **Maven 3.6+** (only required for compilation)
32+
33+
1. Clone the repository:
34+
```bash
35+
git clone https://github.com/StarCodeClub/WorldUtils.git
36+
cd WorldUtils
37+
```
38+
39+
2. Compile the plugin:
40+
```bash
41+
mvn clean package
42+
```
43+
44+
3. After compilation, find `WorldUtils-1.3.0-SNAPSHOT.jar` in the `target/` directory
45+
46+
## 📖 Usage
47+
48+
### Configuration File Structure
49+
50+
```yaml
51+
# Plugin prefix (MiniMessage format)
52+
plugin-prefix: "<shadow:#000000FF><gradient:#ff7300:#ff3c00><b>[WU]</b></gradient></shadow>"
53+
54+
# World configuration files
55+
configs:
56+
# The configuration file must include the default node, please do not delete!!!
57+
default:
58+
# Prevent players from modifying the world (placing blocks, filling with water/lava, placing paintings, modifying item frames and flower pots...)
59+
anti-world-edit: false
60+
# Prevent players from PVP (players damaging each other)
61+
anti-pvp: false
62+
# Prevent players from entering the world (cannot be intercepted immediately on Folia, but will be teleported to Fallback World within 2s)
63+
anti-player-enter: false
64+
# If a player is found in a world where entry is prohibited, the player will be teleported to that world's spawn point
65+
world-enter-fallback: "world"
66+
# Make explosions not destroy blocks in this world (EntityExplodeEvent)
67+
anti-explosion: false
68+
# Prevent players from interacting with blocks in this world (opening containers, using workbenches, etc.) (PlayerInteractEvent)
69+
anti-block-interaction: false
70+
# Prevent players from using items in this world (throwing snowballs, eggs, shooting arrows, using spawn eggs, etc.)
71+
anti-use-item: false
72+
# Prevent players from attacking entities in this world (does not include player vs player damage)
73+
anti-attack-entity: false
74+
# Prevent players from interacting with entities in this world (riding mounts, trading with villagers, etc.) (onPlayerInteractEntity)
75+
anti-entity-interaction: false
76+
# Prevent players from picking up or dropping items in this world (PlayerPickupItemEvent, PlayerDropItemEvent)
77+
anti-pickup-drop-items: false
78+
79+
# Set separate game mode for each world, leave empty to not change
80+
world-gamemode: ""
81+
# Force maintain player's game mode in this world
82+
# Requires world-gamemode to be set to take effect
83+
force-world-gamemode: false
84+
85+
# ActionBar notification displayed when player lacks permission (MiniMessage format)
86+
# Optimized for frequent triggers, will only send once within 1s, fill with empty string "" to not send to player
87+
message:
88+
anti-world-edit: "{plugin-prefix} <red>You don't have permission to modify this world.</red>"
89+
anti-pvp: "{plugin-prefix} <red>PVP is disabled in this world.</red>"
90+
# ... other messages
91+
92+
# Inheritance configuration example
93+
common:
94+
parent: default # Inherit default configuration
95+
anti-world-edit: true
96+
anti-explosion: true
97+
98+
hub-config:
99+
parent: common # Inherit common configuration
100+
anti-block-interaction: true
101+
anti-attack-entity: true
102+
103+
# Specify which worlds use which configuration
104+
world-config:
105+
"world": common # world world uses common configuration
106+
"hub": hub-config # hub world uses hub-config configuration
107+
"world_the_end": disable # Disable WorldUtils in this world
108+
```
109+
110+
### Feature Description
111+
112+
| Protection Type | Description | Covered Events | Folia Support |
113+
|---------------------------|--------------------------|--------------------------------------------------|----------------------------------------|
114+
| `anti-world-edit` | Prevent world modification| Prevent block placement/destruction, bucket operations, painting/item frame interaction | Full support✅ |
115+
| `anti-pvp` | Prevent player combat | Cancel damage between players | Full support✅ |
116+
| `anti-player-enter` | Prevent world entry | Intercept world switching teleportation | Cannot intercept immediately, but can teleport to fallback world within 2s |
117+
| `anti-explosion` | Prevent explosion block damage | Prevent TNT, creeper, fireball explosions (non-entity damage) | Full support✅ |
118+
| `anti-block-interaction` | Prevent block interaction | Intercept opening containers, using workbenches, etc. | Full support✅ |
119+
| `anti-attack-entity` | Prevent entity attack | Prevent attacking or killing non-player entities | Full support✅ |
120+
| `anti-entity-interaction` | Prevent entity interaction| Intercept riding mounts, using leads, trading with villagers, etc. | Full support✅ |
121+
| `anti-pickup-drop-items` | Prevent item pickup/drop | Prevent players from picking up or dropping items in this world | Full support✅ |
122+
| `anti-use-item` | Prevent item usage | Intercept throwing snowballs, eggs, shooting arrows, using spawn eggs, etc. | Full support✅ |
123+
| `world-gamemode` | Independent world game mode| Change game mode when switching worlds | Full support✅ |
124+
125+
## 🎮 Commands & Permissions
126+
127+
### Command List
128+
129+
| Command | Description | Permission |
130+
|---------------------------------------------------|----------------------------|--------------|
131+
| `/wu help` | Show help information | `wu.admin` |
132+
| `/wu status` | View protection settings overview | `wu.admin` |
133+
| `/wu status <world>` | View specified world protection settings | `wu.admin` |
134+
| `/wu set-config <world> <protect_config/disable>` | Switch world protection configuration | `wu.admin` |
135+
| `/wu reload` | Reload configuration file | `wu.admin` |
136+
| `/wu version` | Show plugin version | `wu.admin` |
137+
138+
### Permission System
139+
This plugin has no default permissions
140+
#### Admin Permissions
141+
- `wu.admin` - Use all /wu commands (default: OP)
142+
143+
#### Bypass Permissions
144+
- `wu.bypass.*` - Bypass all world protections (default: OP)
145+
- `wu.bypass.<world>.anti-world-edit` - Bypass world edit protection in specified world
146+
- `wu.bypass.<world>.anti-pvp` - Bypass PVP protection in specified world
147+
- `wu.bypass.<world>.anti-player-enter` - Bypass entry protection in specified world
148+
- `wu.bypass.<world>.anti-block-interaction` - Bypass block interaction protection in specified world
149+
- `wu.bypass.<world>.anti-attack-entity` - Bypass entity attack protection in specified world
150+
- `wu.bypass.<world>.anti-entity-interaction` - Bypass entity interaction protection in specified world
151+
- `wu.bypass.<world>.anti-pickup-drop-items` - Bypass item pickup/drop protection in specified world
152+
- `wu.bypass.<world>.anti-use-item` - Bypass item usage protection in specified world
153+
- `wu.bypass.change-gamemode` - With this permission, WU will not modify your game mode
154+
---
155+
156+
If you encounter problems or have feature suggestions, please submit them at [GitHub Issues](https://github.com/StarCodeClub/WorldUtils/issues).
157+
This project is licensed under the MIT License, see [LICENSE](LICENSE) file for details.

0 commit comments

Comments
 (0)