概述
XMBuildingProtect插件现已提供API接口,供其他插件调用以检查玩家的建筑保护状态。
API方法
IsPlayerProtected
检查玩家是否在建筑保护状态
参数:
- userIdString (string): 玩家的UserIDString
返回值:
- bool: 如果玩家在保护状态返回true,否则返回false
示例:
// 检查玩家是否在保护状态
var result = XMBuildingProtect?.Call("IsPlayerProtected", player.UserIDString);
bool isProtected = result is bool && (bool)result;
GetPlayerProtectionTimeLeft
获取玩家剩余保护时间
参数:
- userIdString (string): 玩家的UserIDString
返回值:
- float: 剩余保护时间(秒),如果没有保护返回0
示例:
// 获取玩家剩余保护时间
var result = XMBuildingProtect?.Call("GetPlayerProtectionTimeLeft", player.UserIDString);
float timeLeft = result is float ? (float)result : 0f;
ShowMainUIForOtherPlugins
为其他插件提供主UI显示方法
参数:
- player (BasePlayer): 玩家对象
返回值:
示例:
// 打开建筑保护主界面
XMBuildingProtect?.Call("ShowMainUIForOtherPlugins", player);