feat: adapt to GMLIB v1.0.2
This commit is contained in:
Vendored
+3
@@ -1556,6 +1556,9 @@ interface Player {
|
||||
slot: number
|
||||
): Item;
|
||||
|
||||
/** (GMLIB & Glacie)获取客户端版本协议*/
|
||||
getNetworkProtocolVersion(): number
|
||||
|
||||
/** (GMLIB)发送更新更新物品数据包 */
|
||||
sendInventorySlotPacket(
|
||||
/** 容器ID */
|
||||
|
||||
@@ -376,6 +376,8 @@ const GMLIB_API = {
|
||||
entityHasType: ll.import("GMLIB_API", "entityHasType"),
|
||||
/** 获取实体类型ID @type {function(Entity):number} */
|
||||
getEntityTypeId: ll.import("GMLIB_API", "getEntityTypeId"),
|
||||
/** 获取实体类型ID @type {function(Entity):number} */
|
||||
getPlayerProtocolVersion: ll.import("GMLIB_API", "getPlayerProtocolVersion"),
|
||||
};
|
||||
|
||||
/** LRCA的二进制流数据包导出接口 */
|
||||
@@ -3034,6 +3036,15 @@ LLSE_Player.prototype.sendInventorySlotPacket =
|
||||
GMLIB_API.sendInventorySlotPacket(this, containerId, slot, item);
|
||||
};
|
||||
|
||||
LLSE_Player.prototype.getNetworkProtocolVersion =
|
||||
/**
|
||||
* 获取客户端版本协议
|
||||
* @returns {number}
|
||||
*/
|
||||
function (containerId, slot, item) {
|
||||
GMLIB_API.getPlayerProtocolVersion(this);
|
||||
};
|
||||
|
||||
LLSE_Container.prototype.getContainerType =
|
||||
/**
|
||||
* 获取容器类型
|
||||
|
||||
@@ -152,7 +152,8 @@ void Export_Compatibility_API() {
|
||||
);
|
||||
RemoteCall::exportAs("GMLIB_API", "getVersion_LRCA", []() -> std::string { return LIB_VERSION.to_string(); });
|
||||
RemoteCall::exportAs("GMLIB_API", "getVersion_GMLIB", []() -> std::string {
|
||||
return GMLIB_VERSION_TO_STRING(GMLIB_VERSION_MAJOR) "." GMLIB_VERSION_TO_STRING(GMLIB_VERSION_MINOR
|
||||
return GMLIB_VERSION_TO_STRING(GMLIB_VERSION_MAJOR) "." GMLIB_VERSION_TO_STRING(
|
||||
GMLIB_VERSION_MINOR
|
||||
) "." GMLIB_VERSION_TO_STRING(GMLIB_VERSION_PATCH);
|
||||
});
|
||||
RemoteCall::exportAs(
|
||||
@@ -951,4 +952,7 @@ void Export_Compatibility_API() {
|
||||
RemoteCall::exportAs("GMLIB_API", "getEntityTypeId", [](Actor* entity) -> int {
|
||||
return (int)entity->getEntityTypeId();
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getPlayerProtocolVersion", [](Player* player) -> int {
|
||||
return ((GMPlayer*)player)->getNetworkProtocolVersion();
|
||||
});
|
||||
}
|
||||
+32
-12
@@ -23,10 +23,14 @@ void registerPlayerPlaceholder(
|
||||
[Call = RemoteCall::importAs<std::string(Player * pl, std::unordered_map<std::string, std::string>)>(
|
||||
PluginName,
|
||||
FuncName
|
||||
)](optional_ref<GMActor> actor, std::unordered_map<std::string, std::string> const& params, auto&&...
|
||||
)](optional_ref<Actor> actor, ll::StringMap<std::string> const& params, auto&&...
|
||||
) -> std::optional<std::string> {
|
||||
if (actor.has_value() && ((Actor*)actor.as_ptr())->isPlayer()) {
|
||||
return Call((Player*)actor.as_ptr(), params);
|
||||
std::unordered_map<std::string, std::string> paramMap;
|
||||
for (auto& [key, val] : params) {
|
||||
paramMap[key] = val;
|
||||
}
|
||||
return Call((Player*)actor.as_ptr(), paramMap);
|
||||
}
|
||||
return std::nullopt;
|
||||
},
|
||||
@@ -55,8 +59,13 @@ void registerServerPlaceholder(
|
||||
[Call = RemoteCall::importAs<std::string(std::unordered_map<std::string, std::string>)>(
|
||||
PluginName,
|
||||
FuncName
|
||||
)](auto, std::unordered_map<std::string, std::string> const& params, auto&&...
|
||||
) -> std::optional<std::string> { return Call(params); },
|
||||
)](auto, ll::StringMap<std::string> const& params, auto&&...) -> std::optional<std::string> {
|
||||
std::unordered_map<std::string, std::string> paramMap;
|
||||
for (auto& [key, val] : params) {
|
||||
paramMap[key] = val;
|
||||
}
|
||||
return Call(paramMap);
|
||||
},
|
||||
mod
|
||||
);
|
||||
};
|
||||
@@ -80,8 +89,8 @@ void registerStaticPlaceholder(
|
||||
if (mod.expired()) return;
|
||||
PlaceholderAPI::registerPlaceholder(
|
||||
PAPIName,
|
||||
[Call = RemoteCall::importAs<std::string()>(PluginName, FuncName)](auto&&...
|
||||
) -> std::optional<std::string> { return Call(); },
|
||||
[Call = RemoteCall::importAs<std::string()>(PluginName, FuncName)](auto&&...)
|
||||
-> std::optional<std::string> { return Call(); },
|
||||
mod
|
||||
);
|
||||
};
|
||||
@@ -128,10 +137,13 @@ void registerPlaceholder(std::string const& placeholder, std::string const& func
|
||||
std::string(Actor*, std::unordered_map<std::string, std::string>, std::string)>(
|
||||
pluginName,
|
||||
funcName
|
||||
)](optional_ref<GMActor> actor,
|
||||
std::unordered_map<std::string, std::string> const& params,
|
||||
std::string const& language) -> std::optional<std::string> {
|
||||
auto result = Call((Actor*)actor.as_ptr(), params, language);
|
||||
)](optional_ref<Actor> actor, ll::StringMap<std::string> const& params, std::string const& language
|
||||
) -> std::optional<std::string> {
|
||||
std::unordered_map<std::string, std::string> paramMap;
|
||||
for (auto& [key, val] : params) {
|
||||
paramMap[key] = val;
|
||||
}
|
||||
auto result = Call((Actor*)actor.as_ptr(), paramMap, language);
|
||||
return result == "<std::nullopt>" ? std::nullopt : std::optional(result);
|
||||
},
|
||||
mod
|
||||
@@ -157,7 +169,11 @@ std::string getValue(
|
||||
std::unordered_map<std::string, std::string> params,
|
||||
std::string const& language
|
||||
) {
|
||||
return PlaceholderAPI::getValue(placeholder, std::nullopt, params, language).value_or("<std::nullopt>");
|
||||
ll::StringMap<std::string> paramMap;
|
||||
for (auto& [key, val] : params) {
|
||||
paramMap[key] = val;
|
||||
}
|
||||
return PlaceholderAPI::getValue(placeholder, std::nullopt, paramMap, language).value_or("<std::nullopt>");
|
||||
}
|
||||
std::string getValueFromActor(
|
||||
std::string const& placeholder,
|
||||
@@ -165,7 +181,11 @@ std::string getValueFromActor(
|
||||
std::unordered_map<std::string, std::string> params,
|
||||
std::string const& language
|
||||
) {
|
||||
return PlaceholderAPI::getValue(placeholder, (GMActor*)actor, params, language).value_or("<std::nullopt>");
|
||||
ll::StringMap<std::string> paramMap;
|
||||
for (auto& [key, val] : params) {
|
||||
paramMap[key] = val;
|
||||
}
|
||||
return PlaceholderAPI::getValue(placeholder, (GMActor*)actor, paramMap, language).value_or("<std::nullopt>");
|
||||
}
|
||||
} // namespace NewPapiRemoteCall
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ if not has_config("vs_runtime") then
|
||||
set_runtimes("MD")
|
||||
end
|
||||
|
||||
add_requires("levilamina", {configs = {target_type = "server"}})
|
||||
add_requires("levilamina 1.1.1", {configs = {target_type = "server"}})
|
||||
add_requires("legacyremotecall")
|
||||
add_requires("levibuildscript")
|
||||
add_requires("ilistenattentively")
|
||||
|
||||
Reference in New Issue
Block a user