PlotSquared PlaceholderAPI 扩展
一个轻量且高效的 PlotSquared PlaceholderAPI 扩展,提供实时地块所有权检测和旗帜检查功能。此扩展允许服务器管理员和插件开发者检测玩家当前是否站在自己的地块上,并查询地块旗帜,从而实现动态内容、条件权限和增强的游戏机制。
? 此扩展的功能
此扩展添加了强大的占位符,根据地块所有权和旗帜状态返回 true 或 false。这对于以下场景特别有用:
- 条件菜单:根据地块所有权或旗帜显示不同的菜单项
- 动态权限:仅在玩家位于自己的地块时授予特殊权限
- 自定义计分板:实时显示地块所有权和旗帜状态
- 聊天格式化:为地块所有者添加特殊前缀或徽章
- 动作条与 Boss 条:显示所有权和旗帜通知
- 条件命令:仅在玩家位于其地块或设置了特定旗帜时执行命令
- 经济系统:根据地块位置和旗帜收取不同价格
- 保护系统:根据地块旗帜增加额外的安全层
- PvP 区域:根据地块旗帜创建动态 PvP 区域
- 飞行控制:根据地块管理飞行权限
示例 GIF
? 可用占位符
| 占位符 |
描述 |
返回值 |
使用场景 |
%plotowner_on_own_plot% |
检查玩家是否作为所有者站在自己的地块上 |
true 或 false |
适用于支持 PlaceholderAPI 的任何插件中的条件逻辑 |
%plotowner_on_own_plot_<flag>% |
检查当前地块是否设置了特定的旗帜 |
true 或 false |
检查 PVP、FLY、USE 等地块旗帜 |
重要提示:所有权占位符专门用于检查地块所有权。仅被信任或添加为成员的玩家将收到 false。
旗帜示例
%plotowner_on_own_plot_pvp% - 如果当前地块设置了 PVP 旗帜则返回 true
%plotowner_on_own_plot_fly% - 如果当前地块设置了 FLY 旗帜则返回 true
%plotowner_on_own_plot_use% - 如果当前地块设置了 USE 旗帜则返回 true
%plotowner_on_own_plot_explosion% - 如果当前地块设置了 EXPLOSION 旗帜则返回 true
✨ 主要特性
- 轻量级:对服务器性能影响极小
- 实时检测:玩家在地块间移动时即时更新
- PlotSquared 集成:使用官方 PlotSquared API 进行可靠检测
- 旗帜支持:检查当前地块上的任何 PlotSquared 旗帜
- 易于使用:简单的 true/false 输出可与任何插件配合使用
- 无需配置:安装后即可开箱即用
- 正确的生命周期:移除和重新加载时正确注销
- 错误处理:优雅地处理边缘情况和错误
? 要求
- Minecraft Server:1.21.x (Paper 或 Spigot)
- Java Version:Java 21 或更高版本
- Required Plugins:
- PlaceholderAPI (最新版本)
- PlotSquared (Version 7.x)
? 安装指南
第 1 步:下载
下载最新的发布版 JAR 文件
第 2 步:安装
将下载的 JAR 文件放入服务器的 PlaceholderAPI 扩展文件夹中:
plugins/PlaceholderAPI/expansions/
重要:不要将此文件放在主 plugins 文件夹中。这是一个扩展,而不是独立插件。
第 3 步:重载
在服务器控制台或游戏中运行以下命令:
/papi reload
第 4 步:验证安装
检查扩展是否成功加载:
/papi list
你应该在已加载的扩展列表中看到 plotowner。
第 5 步:测试
在地块上测试占位符:
/papi parse me %plotowner_on_own_plot%
/papi parse me %plotowner_on_own_plot_pvp%
如果你在自己的地块上,你应该看到 true,否则看到 false。
? 使用示例
示例 1:DeluxeMenus - 条件物品
仅在玩家位于自己的地块时显示特殊物品:
plot_settings_item:
material: COMPARATOR
slot: 13
display_name: "&6&lPlot Settings"
lore:
- "&7Click to configure your plot"
- "&7Status: &a%plotowner_on_own_plot%"
view_requirement:
requirements:
must_be_on_plot:
type: string equals
input: "%plotowner_on_own_plot%"
output: "true"
left_click_commands:
- "[player] plot flag"
示例 2:FeatherBoard - 动态计分板
在计分板上显示地块所有权和旗帜状态:
board:
title:
text:
- "&6&lMy Server"
lines:
line1:
text: "&7━━━━━━━━━━━━━━━"
line2:
text: "&ePlot Owner: &f%plotowner_on_own_plot%"
line3:
text: "&ePVP Enabled: &f%plotowner_on_own_plot_pvp%"
line4:
text: "&eFlight: &f%plotowner_on_own_plot_fly%"
line5:
text: "&eLocation: &f%player_world%"
line6:
text: "&7━━━━━━━━━━━━━━━"
示例 3:ConditionalEvents - 基于旗帜的事件
根据地块标志执行命令:
pvp_zone_enter:
type: player_move
conditions:
- "%plotowner_on_own_plot_pvp% == true"
actions:
default:
- "message: &c&lYou entered a PVP zone!"
- "sound: ENTITY_ENDER_DRAGON_GROWL"
? 工作原理
该扩展使用官方 PlotSquared API 来:
- 将 Bukkit 玩家转换为 PlotSquared 玩家对象
- 获取玩家当前位置的地块
- 检查地块是否存在
- 对于所有权:验证玩家的 UUID 是否与地块所有者的 UUID 匹配
- 对于旗帜:检查地块上是否设置了指定的旗帜
- 相应地返回
true 或 false
此过程经过高度优化,即使有数百名玩家在线,也会造成最小的性能影响。
?️ 从源代码构建
如果你想自己编译此扩展:
前置条件
- Java 21 JDK
- Gradle(或使用自带的 Wrapper)
构建步骤
# 克隆仓库
git clone https://github.com/AlphaBlock4k/PlotSquared-PlaceholderExpansion.git
cd PlotSquared-PlaceholderExpansion
# 使用 Gradle 构建
gradle clean build
# 或者使用 Gradle Wrapper
./gradlew clean build # Linux/Mac
gradlew.bat clean build # Windows
编译后的 JAR 文件位于 build/libs/Expansion-PlotOwner-1.0.1.jar
? 与其他插件的集成
此扩展可与任何支持 PlaceholderAPI 的插件无缝配合,包括:
- 菜单插件:DeluxeMenus, ChestCommands, TrMenu
- 记分板插件:FeatherBoard, AnimatedScoreboard
- 聊天插件:ChatControl, VentureChat, EssentialsChat
- 权限插件:LuckPerms(配合 ConditionalPerms)
- 事件插件:ConditionalEvents, ExecutableEvents
- 全息图插件:HolographicDisplays, DecentHolograms
- NPC 插件:Citizens, ZNPCs
- 战斗插件:CombatLogX, DeluxeCombat
- 以及更多!
❓ 常见问题
问:为什么我在地块上被信任时显示 "false"?
答:此扩展专门检查地块所有权。只有地块所有者会返回 true。受信任的成员和添加的玩家将返回 false。
问:这适用于合并的地块吗?
答:是的!如果你拥有一个合并的地块并站在该地块的任何位置,占位符将返回 true。
问:我可以用于道路检测吗?
答:可以!如果占位符返回 false 且玩家处于地块世界中,那么他们要么在道路上,要么在别人的地块上。
问:性能影响如何?
答:微乎其微。该扩展使用高效的 PlotSquared API 调用,并包含错误处理以防止卡顿。
问:为什么标识符是 "plotowner" 而不是 "plotsquared"?
答:PlaceholderAPI 已经内置了一个标识符为 "plotsquared" 的扩展。为了避免冲突,此扩展使用了 "plotowner"。
问:如果我删除扩展并重新加载会发生什么?
答:扩展将被正确注销并从内存中移除。此问题已在版本 1.0.1 中修复。
问:我可以检查任何 PlotSquared 标志吗?
答:可以!你可以检查 PlotSquared 支持的任何标志。只需使用 %plotowner_on_own_plot_<flagname>% 并替换为相应的标志名称即可。
问:如果某个标志不存在或未设置怎么办?
答:如果标志不存在或在地块上未设置,占位符将返回 false。
? 故障排除
扩展未加载
- 确保已安装并运行 PlotSquared
- 检查 JAR 文件是否位于
plugins/PlaceholderAPI/expansions/ 目录中
- 运行
/papi reload
- 查看控制台是否有错误信息
占位符无输出
- 验证扩展已加载:
/papi list
- 测试占位符:
/papi parse me %plotowner_on_own_plot%
- 确保使用了正确的标识符:
plotowner 而非 plotsquared
始终显示 "false"
- 确认你是地块所有者(而不仅仅是受信任成员)
- 使用
/plot info 检查以验证所有权
- 确保你站在地块边界内
- 对于标志:使用
/plot flag list 验证标志是否已实际设置
删除后扩展仍注册
- 确保使用的是 1.0.1 或更高版本
- 从
plugins/PlaceholderAPI/expansions/ 中删除 JAR 文件
- 运行
/papi reload
- 通过
/papi list 验证其不再列出
? 作者
AlphaBlock4k
? 支持
如果你觉得此扩展有用,请考虑:
- ⭐ 给本仓库加星
- ? 在 Issues 部分报告错误
- ? 建议新功能
- ? 与其他服务器管理员分享
? 版本历史
v1.0.1
- 添加了标志检查占位符:
%plotowner_on_own_plot_<flag>%
- 修复了删除和重新加载后扩展仍然存在的问题
- 改进了生命周期管理
v1.0.0
- 首次发布
- 基本的地块所有权检测
- 支持 PlotSquared 7.x
- 兼容 Minecraft 1.21.x
由 ❤️ 为 Minecraft 社区制作
PlotSquared PlaceholderAPI Expansion
A lightweight and efficient PlaceholderAPI expansion for PlotSquared that provides real-time plot ownership detection and flag checking. This expansion allows server administrators and plugin developers to check whether a player is currently standing on their own plot and query plot flags, enabling dynamic content, conditional permissions, and enhanced gameplay mechanics.
? What Does This Expansion Do?
This expansion adds powerful placeholders that return true or false based on plot ownership and flag status. This is particularly useful for:
- Conditional Menus: Show different menu items based on plot ownership or flags
- Dynamic Permissions: Grant special permissions only when players are on their own plots
- Custom Scoreboards: Display plot ownership and flag status in real-time
- Chat Formatting: Add special prefixes or badges for plot owners
- Action Bars & Boss Bars: Show ownership and flag notifications
- Conditional Commands: Execute commands only when players are on their plots or when specific flags are set
- Economy Systems: Charge different prices based on plot location and flags
- Protection Systems: Add extra security layers based on plot flags
- PvP Zones: Create dynamic PvP areas based on plot flags
- Flight Control: Manage flight permissions based on plot flags
Example GIF
? Available Placeholders
| Placeholder |
Description |
Return Value |
Use Case |
%plotowner_on_own_plot% |
Checks if the player is standing on their own plot as the owner |
true or false |
Perfect for conditional logic in any plugin that supports PlaceholderAPI |
%plotowner_on_own_plot_<flag>% |
Checks if a specific flag is set on the current plot |
true or false |
Check plot flags like PVP, FLY, USE, etc. |
Important Note: The ownership placeholder specifically checks for plot ownership. Players who are only trusted or added as members will receive false.
Flag Examples
%plotowner_on_own_plot_pvp% - Returns true if the PVP flag is set on the current plot
%plotowner_on_own_plot_fly% - Returns true if the FLY flag is set on the current plot
%plotowner_on_own_plot_use% - Returns true if the USE flag is set on the current plot
%plotowner_on_own_plot_explosion% - Returns true if the EXPLOSION flag is set on the current plot
✨ Key Features
- Lightweight: Minimal performance impact on your server
- Real-time Detection: Instant updates when players move between plots
- PlotSquared Integration: Uses official PlotSquared API for reliable detection
- Flag Support: Check any PlotSquared flag on the current plot
- Easy to Use: Simple true/false output works with any plugin
- No Configuration: Works out of the box after installation
- Proper Lifecycle: Correctly unregisters when removed and reloaded
- Error Handling: Gracefully handles edge cases and errors
? Requirements
- Minecraft Server: 1.21.x (Paper or Spigot)
- Java Version: Java 21 or higher
- Required Plugins:
- PlaceholderAPI (Latest version)
- PlotSquared (Version 7.x)
? Installation Guide
Step 1: Download
Download the latest release JAR file
Step 2: Install
Place the downloaded JAR file into your server's PlaceholderAPI expansions folder:
plugins/PlaceholderAPI/expansions/
Important: Do NOT place this in the main plugins folder. This is an expansion, not a standalone plugin.
Step 3: Reload
Run the following command in your server console or in-game:
/papi reload
Step 4: Verify Installation
Check if the expansion loaded successfully:
/papi list
You should see plotowner in the list of loaded expansions.
Step 5: Test
Test the placeholders while standing on your plot:
/papi parse me %plotowner_on_own_plot%
/papi parse me %plotowner_on_own_plot_pvp%
You should see true if you're on your own plot, or false if you're not.
? Usage Examples
Example 1: DeluxeMenus - Conditional Items
Show a special item only when players are on their own plot:
plot_settings_item:
material: COMPARATOR
slot: 13
display_name: "&6&lPlot Settings"
lore:
- "&7Click to configure your plot"
- "&7Status: &a%plotowner_on_own_plot%"
view_requirement:
requirements:
must_be_on_plot:
type: string equals
input: "%plotowner_on_own_plot%"
output: "true"
left_click_commands:
- "[player] plot flag"
Example 2: FeatherBoard - Dynamic Scoreboard
Display plot ownership and flag status on your scoreboard:
board:
title:
text:
- "&6&lMy Server"
lines:
line1:
text: "&7━━━━━━━━━━━━━━━"
line2:
text: "&ePlot Owner: &f%plotowner_on_own_plot%"
line3:
text: "&ePVP Enabled: &f%plotowner_on_own_plot_pvp%"
line4:
text: "&eFlight: &f%plotowner_on_own_plot_fly%"
line5:
text: "&eLocation: &f%player_world%"
line6:
text: "&7━━━━━━━━━━━━━━━"
Example 3: ConditionalEvents - Flag-Based Events
Execute commands based on plot flags:
pvp_zone_enter:
type: player_move
conditions:
- "%plotowner_on_own_plot_pvp% == true"
actions:
default:
- "message: &c&lYou entered a PVP zone!"
- "sound: ENTITY_ENDER_DRAGON_GROWL"
? How It Works
The expansion uses the official PlotSquared API to:
- Convert the Bukkit player to a PlotSquared player object
- Get the plot at the player's current location
- Check if the plot exists
- For ownership: Verify if the player's UUID matches the plot owner's UUID
- For flags: Check if the specified flag is set on the plot
- Return
true or false accordingly
This process is highly optimized and causes minimal performance impact, even with hundreds of players online.
?️ Building from Source
If you want to compile the expansion yourself:
Prerequisites
- Java 21 JDK
- Gradle (or use the included wrapper)
Build Steps
# Clone the repository
git clone https://github.com/AlphaBlock4k/PlotSquared-PlaceholderExpansion.git
cd PlotSquared-PlaceholderExpansion
# Build with Gradle
gradle clean build
# Or use the Gradle wrapper
./gradlew clean build # Linux/Mac
gradlew.bat clean build # Windows
The compiled JAR will be located in build/libs/Expansion-PlotOwner-1.0.1.jar
? Integration with Other Plugins
This expansion works seamlessly with any plugin that supports PlaceholderAPI, including:
- Menu Plugins: DeluxeMenus, ChestCommands, TrMenu
- Scoreboard Plugins: FeatherBoard, AnimatedScoreboard
- Chat Plugins: ChatControl, VentureChat, EssentialsChat
- Permission Plugins: LuckPerms (with ConditionalPerms)
- Event Plugins: ConditionalEvents, ExecutableEvents
- Hologram Plugins: HolographicDisplays, DecentHolograms
- NPC Plugins: Citizens, ZNPCs
- Combat Plugins: CombatLogX, DeluxeCombat
- And many more!
❓ Frequently Asked Questions
Q: Why does it show "false" when I'm trusted on a plot?
A: This expansion specifically checks for plot ownership. Only the plot owner will receive true. Trusted members and added players will receive false.
Q: Does this work with merged plots?
A: Yes! If you own a merged plot and stand anywhere on it, the placeholder will return true.
Q: Can I use this for road detection?
A: Yes! If the placeholder returns false and the player is in a plot world, they're either on a road or on someone else's plot.
Q: What's the performance impact?
A: Minimal. The expansion uses efficient PlotSquared API calls and includes error handling to prevent lag.
Q: Why is the identifier "plotowner" and not "plotsquared"?
A: PlaceholderAPI already has a built-in expansion with the identifier "plotsquared". To avoid conflicts, this expansion uses "plotowner".
Q: What happens if I delete the expansion and reload?
A: The expansion will be properly unregistered and removed from memory. This was fixed in version 1.0.1.
Q: Can I check any PlotSquared flag?
A: Yes! You can check any flag that PlotSquared supports. Just use %plotowner_on_own_plot_<flagname>% with the flag's name.
Q: What if a flag doesn't exist or isn't set?
A: The placeholder will return false if the flag doesn't exist or isn't set on the plot.
? Troubleshooting
Expansion not loading
- Ensure PlotSquared is installed and running
- Check that the JAR is in
plugins/PlaceholderAPI/expansions/
- Run
/papi reload
- Check console for error messages
Placeholder shows nothing
- Verify the expansion is loaded:
/papi list
- Test the placeholder:
/papi parse me %plotowner_on_own_plot%
- Ensure you're using the correct identifier:
plotowner not plotsquared
Always shows "false"
- Confirm you are the plot owner (not just trusted)
- Check with
/plot info to verify ownership
- Ensure you're standing within plot boundaries
- For flags: Verify the flag is actually set with
/plot flag list
Expansion still registered after deletion
- Make sure you're using version 1.0.1 or higher
- Delete the JAR file from
plugins/PlaceholderAPI/expansions/
- Run
/papi reload
- Verify with
/papi list that it's no longer listed
? Author
AlphaBlock4k
? Support
If you find this expansion useful, please consider:
- ⭐ Starring this repository
- ? Reporting bugs in the Issues section
- ? Suggesting new features
- ? Sharing with other server owners
? Version History
v1.0.1
- Added flag checking placeholder:
%plotowner_on_own_plot_<flag>%
- Fixed expansion persisting after deletion and reload
- Improved lifecycle management
v1.0.0
- Initial release
- Basic plot ownership detection
- PlotSquared 7.x support
- Minecraft 1.21.x compatibility
Made with ❤️ for the Minecraft community
评论 0
登录后参与评分
还没有评论,来抢沙发吧