WorldProtection
适用于 Paper/Spigot 服务器的全面世界保护插件,允许管理员通过白名单系统保护特定世界。即使操作者(OP)也会被阻止访问受保护的世界,除非被明确列入白名单。
功能
核心功能
- 世界保护开关:启用或禁用任何世界的保护
- 白名单系统:只有列入白名单的玩家才能访问受保护的世界
- 操作者屏蔽:阻止操作者访问受保护的世界(除非被列入白名单)
- 不区分大小写的世界查找:为方便起见,世界名称匹配时不区分大小写
- 玩家传送命令:
/wp go <world> 允许玩家传送到指定世界(若未列入白名单则阻止)
- 多种访问方式被阻止:防止通过以下方式访问:
- 切换世界
- 传送命令
- 传送门使用(下界传送门、末地传送门等)
- 直接加入世界
- 数据持久化:自动保存受保护的世界和白名单
- 配置重载:无需重启服务器即可重新加载配置
- Multiverse 支持:兼容 Multiverse-Core(软依赖)
安全功能
- 默认情况下操作者会被屏蔽(可配置)
- 操作者始终会被传送离开(踢出操作者可能无效)
- 提供绕过权限,但仍尊重操作者屏蔽设置
- 当访问被拒绝时,自动传送至安全世界
- 可配置用于传送的安全世界
- 可选的访问拒绝时踢出玩家功能(默认:启用)
- 自定义踢出消息
要求
- Paper 1.21.x 或兼容版本
- Java 21
- Multiverse-Core(可选,用于 Multiverse 世界管理)
安装
- 从发布页面下载最新的 JAR 文件
- 将
WorldProtection-1.0.0.jar 放入服务器的 plugins/ 文件夹中
- 启动或重启服务器
- 根据您的偏好配置
plugins/WorldProtection/config.yml
- 使用
/wp toggle <world> 来保护世界
- 使用
/wp whitelist <world> add <player> 将玩家列入白名单
配置
config.yml
# World Protection Configuration
# 访问被拒绝时的默认消息
messages:
prefix: "&c[WorldProtection]&f "
access_denied: "&cYou do not have permission to access this world!"
world_protected: "&eWorld &6%world% &eis protected. Only whitelisted players can access it."
world_unprotected: "&aWorld &6%world% &ais now unprotected."
world_protected_enabled: "&aWorld &6%world% &ais now protected."
player_whitelisted: "&aPlayer &e%player% &ahas been whitelisted for world &6%world%&a."
player_unwhitelisted: "&cPlayer &e%player% &ahas been removed from whitelist for world &6%world%&c."
not_whitelisted: "&cYou are not whitelisted for world &6%world%&c."
world_not_found: "&cWorld &6%world% &cnot found!"
no_worlds_protected: "&7No worlds are currently protected."
teleport_success: "&aTeleported to world &6%world%&a."
teleport_denied: "&cYou do not have permission to teleport to world &6%world%&c."
# 阻止操作者访问受保护的世界(除非被列入白名单)
block_operators: true
# 踢出尝试访问受保护世界的玩家
kick_on_deny: true
# 当访问被拒绝且 kick_on_deny 为 false 时,传送玩家到的安全世界
# 留空以自动查找安全世界
safe_world: ""
# 玩家因未列入白名单而被踢出时的消息
kick_message: "&4You are not whitelisted on this world"
配置选项
messages
- 所有消息均可使用颜色代码进行自定义
- 使用
%world% 占位符表示世界名称
- 使用
%player% 占位符表示玩家名称
block_operators
true:操作者被阻止访问受保护的世界(除非被列入白名单)
false:操作者可以访问受保护的世界(不建议)
kick_on_deny
true:当玩家尝试访问受保护的世界时会被踢出(默认)
false:玩家会被传送回安全世界
- 注意:操作者始终会被传送(踢出操作者可能无效)
safe_world
- 当访问被拒绝且
kick_on_deny 为 false 时,传送玩家到的世界名称
- 留空 (
"") 以自动查找安全世界
- 必须是有效的世界名称
kick_message
- 玩家因尝试访问受保护的世界而被踢出时显示的消息
- 支持颜色代码(使用
& 前缀)
- 默认值:
"&4You are not whitelisted on this world"
命令
玩家命令
/worldprotection go <world> 或 /wp go <world>
- 传送到指定世界(所有玩家可用)
- 如果世界受保护且您未被列入白名单,则阻止传送
- 示例:
/wp go creative
- 注意:世界名称不区分大小写
管理员命令
所有管理员命令都需要 worldprotection.admin 权限(默认:OP)。
/worldprotection toggle <world> 或 /wp toggle <world>
- 启用或禁用世界的保护
- 示例:
/wp toggle creative
- 注意:世界名称不区分大小写
/worldprotection whitelist <world> add <player> 或 /wp whitelist <world> add <player>
- 将玩家添加到受保护世界的白名单中
- 示例:
/wp whitelist creative add PlayerName
- 注意:世界名称不区分大小写
/worldprotection whitelist <world> remove <player> 或 /wp whitelist <world> remove <player>
- 从受保护世界的白名单中移除玩家
- 示例:
/wp whitelist creative remove PlayerName
- 注意:世界名称不区分大小写
/worldprotection list 或 /wp list
- 列出当前所有受保护的世界
- 显示每个世界列入白名单的玩家数量
/worldprotection info <world> 或 /wp info <world>
- 显示世界保护状态的详细信息
- 显示保护状态和列入白名单的玩家
- 注意:世界名称不区分大小写
/worldprotection reload 或 /wp reload
- 重新加载配置文件和数据
- 需要管理员权限
- 示例:
/wp reload
权限
worldprotection.admin
- 拥有所有世界保护命令的完全管理员权限
- 默认:
op(仅限操作者)
- 允许:切换保护状态、管理白名单、查看信息
worldprotection.bypass
- 绕过世界保护(不推荐)
- 默认:
op(仅限操作者)
- 注意:如果配置中设置了
block_operators: true,则仍然会被阻止
使用示例
保护一个世界
-
保护一个世界:
/wp toggle creative
输出:[WorldProtection] World creative is now protected.
-
添加玩家到白名单:
/wp whitelist creative add PlayerName
/wp whitelist creative add AnotherPlayer
-
检查保护状态:
/wp info creative
取消保护一个世界
-
移除保护:
/wp toggle creative
输出:[WorldProtection] World creative is now unprotected.
-
注意:当世界未受保护时,白名单会被保留但不再强制执行
管理白名单
添加玩家:
/wp whitelist creative add PlayerName
移除玩家:
/wp whitelist creative remove PlayerName
查看所有受保护的世界:
/wp list
工作原理
保护机制
当玩家尝试访问受保护的世界时,插件会执行以下操作:
-
检查世界是否受保护
-
检查玩家是否在白名单中
-
检查是否有绕过权限
- 如果玩家拥有
worldprotection.bypass 权限,则允许访问
- 例外情况:如果
block_operators: true 且玩家是 OP,则仍然被阻止
-
如果所有检查均未通过,则阻止访问
- 如果
kick_on_deny: true:使用配置的踢出消息踢出玩家
- 如果
kick_on_deny: false:将玩家传送至安全世界(配置的或自动查找的)
- 操作者始终会被传送离开(对操作者可能无法使用踢出功能)
- 发送访问被拒绝的消息
- 多个事件处理器确保无论通过何种方式访问都能被阻止
被阻止的访问方式
插件会阻止以下方式的访问:
- 世界切换:当玩家通过任何方法切换世界时
- 玩家加入:当玩家在受保护的世界中登录服务器时
- 传送:所有传送命令和事件(包括
/wp go)
- 传送门:下界传送门、末地传送门以及其他类型的传送门
操作者阻止
操作者的处理方式较为特殊:
- 当
block_operators: true 时,他们始终被禁止进入受保护的世界
- 他们始终会被传送离开(对操作者可能无法使用踢出功能)
- 多个事件处理器确保操作者无法停留在受保护的世界中
- 即使踢出失败,操作者也会立即被传送至安全世界
数据存储
受保护的世界和白名单存储在:
plugins/WorldProtection/data.yml
该文件会在以下情况自动创建和更新:
- 世界被保护或取消保护时
- 玩家被添加或移除出白名单时
文件结构
plugins/WorldProtection/
├── config.yml # 配置文件
└── data.yml # 受保护的世界和白名单(自动生成)
故障排除
操作者仍能访问受保护的世界:
- 检查 config.yml 中的
block_operators(应为 true)
- 确保操作者未被列入白名单
- 验证他们没有
worldprotection.bypass 权限
- 操作者应立即被传送离开——如果没有,请检查服务器日志
- 尝试以操作者身份使用
/wp go <world> ——你应该被阻止并传送离开
玩家仍能访问受保护的世界:
- 检查世界是否确实受到保护:
/wp list
- 验证玩家未被列入白名单:
/wp info <world>
- 检查玩家是否拥有绕过权限
白名单无效:
- 确保世界已受保护:
/wp toggle <world>
- 验证玩家是否正确添加:
/wp info <world>
- 检查 data.yml 文件中 UUID 是否正确
玩家卡住:
- 如果在启用保护时玩家位于受保护的世界中,他们会立即被传送离开
- 使用
/wp whitelist <world> add <player> 允许其访问
- 或者暂时取消世界保护:
/wp toggle <world>
- 玩家可以使用
/wp go <world> 尝试传送(如果未列入白名单将被阻止)
Multiverse 世界不起作用:
- 确保已安装 Multiverse-Core(可选但推荐)
- 世界名称匹配不区分大小写,因此你可以使用任意大小写形式
- 使用
/mv list 查看世界名称,但你可以使用任意大小写变体
安全注意事项
操作者阻止
默认情况下,操作者被禁止访问受保护的世界。这是有意为之,并提供额外的安全性:
- 防止管理员意外访问
- 确保只有明确列入白名单的玩家才能访问
- 保持严格的访问控制
- 操作者始终会被传送离开(对操作者可能无法使用踢出功能)
- 多个事件处理器确保操作者无法绕过保护
要允许操作者访问,你必须:
- 将其列入白名单:
/wp whitelist <world> add <operator_name>
- 或在 config.yml 中设置
block_operators: false(不推荐)
重要提示:即使启用了 kick_on_deny,操作者也会被传送而非踢出,因为服务器保护机制可能会阻止踢出操作者。
绕过权限
worldprotection.bypass 权限的存在是为了特殊情况,但:
- 它仍受
block_operators 设置的约束
- 应谨慎使用
- 考虑使用白名单以实现更好的追踪
API
公共方法
// 检查世界是否受保护
boolean isWorldProtected(String worldName)
// 检查玩家是否在世界的白名单中
boolean isPlayerWhitelisted(UUID playerUUID, String worldName)
// 检查玩家是否可以访问世界
boolean canAccessWorld(Player player, String worldName)
事件
插件监听并处理以下事件:
PlayerJoinEvent - 阻止玩家在受保护的世界中登录
PlayerChangedWorldEvent - 阻止世界切换
PlayerTeleportEvent - 阻止传送
PlayerPortalEvent - 阻止使用传送门
版本
当前版本:1.0.0
支持
如有问题、功能请求或疑问,请在项目仓库中提交 issue。
许可证
本插件按原样提供,供 Minecraft 服务器使用。
致谢
专为 Paper 1.21.x 服务器开发,可选集成 Multiverse-Core。
WorldProtection
A comprehensive world protection plugin for Paper/Spigot servers that allows administrators to protect specific worlds with a whitelist system. Even operators are blocked from accessing protected worlds unless explicitly whitelisted.
Features
Core Features
- World Protection Toggle: Enable or disable protection on any world
- Whitelist System: Only whitelisted players can access protected worlds
- Operator Blocking: Blocks operators from accessing protected worlds (unless whitelisted)
- Case-Insensitive World Lookup: World names are matched case-insensitively for convenience
- Player Teleport Command:
/wp go <world> allows players to teleport to worlds (blocks if not whitelisted)
- Multiple Access Methods Blocked: Prevents access via:
- World changes
- Teleportation commands
- Portal usage (nether portals, end portals, etc.)
- Direct world joining
- Data Persistence: Protected worlds and whitelists are saved automatically
- Config Reload: Reload configuration without restarting server
- Multiverse Support: Compatible with Multiverse-Core (soft dependency)
Security Features
- Operators are blocked by default (configurable)
- Operators are always teleported away (kicks may not work on ops)
- Bypass permission available but still respects operator blocking
- Automatic teleportation to safe world when access is denied
- Configurable safe world for teleportation
- Optional kick on access denial (default: enabled)
- Customizable kick message
Requirements
- Paper 1.21.x or compatible
- Java 21
- Multiverse-Core (optional, for Multiverse world management)
Installation
- Download the latest JAR from the releases page
- Place
WorldProtection-1.0.0.jar in your server's plugins/ folder
- Start or restart your server
- Configure
plugins/WorldProtection/config.yml to your preferences
- Use
/wp toggle <world> to protect worlds
- Use
/wp whitelist <world> add <player> to whitelist players
Configuration
config.yml
# World Protection Configuration
# Default message when access is denied
messages:
prefix: "&c[WorldProtection]&f "
access_denied: "&cYou do not have permission to access this world!"
world_protected: "&eWorld &6%world% &eis protected. Only whitelisted players can access it."
world_unprotected: "&aWorld &6%world% &ais now unprotected."
world_protected_enabled: "&aWorld &6%world% &ais now protected."
player_whitelisted: "&aPlayer &e%player% &ahas been whitelisted for world &6%world%&a."
player_unwhitelisted: "&cPlayer &e%player% &ahas been removed from whitelist for world &6%world%&c."
not_whitelisted: "&cYou are not whitelisted for world &6%world%&c."
world_not_found: "&cWorld &6%world% &cnot found!"
no_worlds_protected: "&7No worlds are currently protected."
teleport_success: "&aTeleported to world &6%world%&a."
teleport_denied: "&cYou do not have permission to teleport to world &6%world%&c."
# Block operators from accessing protected worlds (unless whitelisted)
block_operators: true
# Kick players who try to access protected worlds
kick_on_deny: true
# Safe world to teleport players to when access is denied (if kick_on_deny is false)
# Leave empty to auto-find a safe world
safe_world: ""
# Kick message when player is not whitelisted
kick_message: "&4You are not whitelisted on this world"
Configuration Options
messages
- All messages can be customized with color codes
- Use
%world% placeholder for world names
- Use
%player% placeholder for player names
block_operators
true: Operators are blocked from protected worlds (unless whitelisted)
false: Operators can access protected worlds (not recommended)
kick_on_deny
true: Players are kicked when they try to access a protected world (default)
false: Players are teleported back to a safe world
- Note: Operators are always teleported (kicks may not work on ops)
safe_world
- Name of the world to teleport players to when access is denied and
kick_on_deny is false
- Leave empty (
"") to automatically find a safe world
- Must be a valid world name
kick_message
- Custom message shown when a player is kicked for accessing a protected world
- Supports color codes (use
& prefix)
- Default:
"&4You are not whitelisted on this world"
Commands
Player Commands
/worldprotection go <world> or /wp go <world>
- Teleport to a world (available to all players)
- Blocks teleportation if the world is protected and you're not whitelisted
- Example:
/wp go creative
- Note: World names are case-insensitive
Admin Commands
All admin commands require worldprotection.admin permission (default: OP).
/worldprotection toggle <world> or /wp toggle <world>
- Enable or disable protection on a world
- Example:
/wp toggle creative
- Note: World names are case-insensitive
/worldprotection whitelist <world> add <player> or /wp whitelist <world> add <player>
- Add a player to the whitelist for a protected world
- Example:
/wp whitelist creative add PlayerName
- Note: World names are case-insensitive
/worldprotection whitelist <world> remove <player> or /wp whitelist <world> remove <player>
- Remove a player from the whitelist for a protected world
- Example:
/wp whitelist creative remove PlayerName
- Note: World names are case-insensitive
/worldprotection list or /wp list
- List all currently protected worlds
- Shows the number of whitelisted players per world
/worldprotection info <world> or /wp info <world>
- Show detailed information about a world's protection status
- Displays protection status and whitelisted players
- Note: World names are case-insensitive
/worldprotection reload or /wp reload
- Reload the configuration file and data
- Requires admin permission
- Example:
/wp reload
Permissions
worldprotection.admin
- Full admin access to all world protection commands
- Default:
op (operators only)
- Allows: toggle protection, manage whitelist, view info
worldprotection.bypass
- Bypass world protection (not recommended)
- Default:
op (operators only)
- Note: Still blocked if
block_operators: true in config
Usage Examples
Protecting a World
-
Protect a world:
/wp toggle creative
Output: [WorldProtection] World creative is now protected.
-
Whitelist players:
/wp whitelist creative add PlayerName
/wp whitelist creative add AnotherPlayer
-
Check protection status:
/wp info creative
Unprotecting a World
-
Remove protection:
/wp toggle creative
Output: [WorldProtection] World creative is now unprotected.
-
Note: Whitelist is preserved but not enforced when world is unprotected
Managing Whitelist
Add a player:
/wp whitelist creative add PlayerName
Remove a player:
/wp whitelist creative remove PlayerName
View all protected worlds:
/wp list
How It Works
Protection Mechanism
When a player attempts to access a protected world, the plugin:
-
Checks if world is protected
- If not protected, access is allowed
-
Checks if player is whitelisted
- If whitelisted, access is allowed
-
Checks bypass permission
- If player has
worldprotection.bypass, access is allowed
- Exception: If
block_operators: true and player is OP, still blocked
-
Blocks access if all checks fail
- If
kick_on_deny: true: Kicks player with configured kick message
- If
kick_on_deny: false: Teleports player to safe world (configured or auto-found)
- Operators are always teleported away (kicks may not work on ops)
- Sends access denied message
- Multiple event handlers ensure blocking works regardless of access method
Access Methods Blocked
The plugin blocks access through:
- World Changes: When a player changes worlds (via any method)
- Player Join: When a player joins the server in a protected world
- Teleportation: All teleportation commands and events (including
/wp go)
- Portals: Nether portals, end portals, and other portal types
Operator Blocking
Operators are handled specially:
- They are always blocked from protected worlds (when
block_operators: true)
- They are always teleported away (kicks may not work on operators)
- Multiple event handlers ensure operators cannot stay in protected worlds
- Even if a kick fails, operators are immediately teleported to a safe world
Data Storage
Protected worlds and whitelists are stored in:
plugins/WorldProtection/data.yml
This file is automatically created and updated when:
- Worlds are protected/unprotected
- Players are added/removed from whitelists
File Structure
plugins/WorldProtection/
├── config.yml # Configuration file
└── data.yml # Protected worlds and whitelists (auto-generated)
Troubleshooting
Operators can still access protected worlds:
- Check
block_operators in config.yml (should be true)
- Ensure operators are not whitelisted
- Verify they don't have
worldprotection.bypass permission
- Operators should be teleported away immediately - if not, check server logs
- Try using
/wp go <world> as an operator - you should be blocked and teleported away
Players can still access protected worlds:
- Check if world is actually protected:
/wp list
- Verify player is not whitelisted:
/wp info <world>
- Check if player has bypass permission
Whitelist not working:
- Ensure world is protected:
/wp toggle <world>
- Verify player was added correctly:
/wp info <world>
- Check data.yml file for correct UUIDs
Players getting stuck:
- If a player is in a protected world when protection is enabled, they will be teleported out immediately
- Use
/wp whitelist <world> add <player> to allow them access
- Or temporarily unprotect the world:
/wp toggle <world>
- Players can use
/wp go <world> to attempt teleportation (will be blocked if not whitelisted)
Multiverse worlds not working:
- Ensure Multiverse-Core is installed (optional but recommended)
- World names are matched case-insensitively, so you can use any case
- Use
/mv list to see world names, but you can use any case variation
Security Considerations
Operator Blocking
By default, operators are blocked from accessing protected worlds. This is intentional and provides additional security:
- Prevents accidental access by admins
- Ensures only explicitly whitelisted players can access
- Maintains strict access control
- Operators are always teleported away (kicks may not work on operators)
- Multiple event handlers ensure operators cannot bypass protection
To allow operators access, you must:
- Whitelist them:
/wp whitelist <world> add <operator_name>
- Or set
block_operators: false in config.yml (not recommended)
Important: Even if kick_on_deny is enabled, operators are teleported instead of kicked, as server protections may prevent kicking operators.
Bypass Permission
The worldprotection.bypass permission exists for special cases but:
- Still respects
block_operators setting
- Should be used sparingly
- Consider whitelisting instead for better tracking
API
Public Methods
// Check if a world is protected
boolean isWorldProtected(String worldName)
// Check if a player is whitelisted for a world
boolean isPlayerWhitelisted(UUID playerUUID, String worldName)
// Check if a player can access a world
boolean canAccessWorld(Player player, String worldName)
Events
The plugin listens to and handles:
PlayerJoinEvent - Blocks players joining in protected worlds
PlayerChangedWorldEvent - Blocks world changes
PlayerTeleportEvent - Blocks teleportation
PlayerPortalEvent - Blocks portal usage
Version
Current Version: 1.0.0
Support
For issues, feature requests, or questions, please open an issue on the project repository.
License
This plugin is provided as-is for use on Minecraft servers.
Credits
Developed for Paper 1.21.x servers with optional Multiverse-Core integration.
评论 0
登录后参与评分
还没有评论,来抢沙发吧