adapt: adapt to GMLIB v0.12.4

This commit is contained in:
Tsubasa6848
2024-05-03 01:39:59 +08:00
Unverified
parent 105228aba6
commit 3918069ce4
4 changed files with 18 additions and 27 deletions
+8 -12
View File
@@ -53,25 +53,21 @@ void Export_Compatibility_API() {
}
return result;
});
RemoteCall::exportAs("GMLIB_API", "getPlayerNbt", [](std::string uuid) -> std::string {
RemoteCall::exportAs("GMLIB_API", "getPlayerNbt", [](std::string uuid) -> std::unique_ptr<CompoundTag> {
auto uid = mce::UUID::fromString(uuid);
auto nbt = GMLIB_Player::getPlayerNbt(uid);
if (nbt) {
return nbt->toSnbt();
}
return "null";
return std::move(GMLIB_Player::getPlayerNbt(uid));
});
RemoteCall::exportAs("GMLIB_API", "setPlayerNbt", [](std::string uuid, std::string snbt, bool forceCreate) -> bool {
RemoteCall::exportAs("GMLIB_API", "setPlayerNbt", [](std::string uuid, CompoundTag* nbt, bool forceCreate) -> bool {
auto uid = mce::UUID::fromString(uuid);
auto nbt = CompoundTag::fromSnbt(snbt);
logger.warn(nbt->toSnbt());
return GMLIB_Player::setPlayerNbt(uid, *nbt, forceCreate);
});
RemoteCall::exportAs(
"GMLIB_API",
"setPlayerNbtTags",
[](std::string uuid, std::string snbt, std::vector<std::string> tags) -> bool {
[](std::string uuid, CompoundTag* nbt, std::vector<std::string> tags) -> bool {
auto uid = mce::UUID::fromString(uuid);
auto nbt = CompoundTag::fromSnbt(snbt);
logger.warn(nbt->toSnbt());
return GMLIB_Player::setPlayerNbtTags(uid, *nbt, tags);
}
);
@@ -176,8 +172,8 @@ void Export_Compatibility_API() {
}
});
RemoteCall::exportAs("GMLIB_API", "getResourcePackI18nLanguage", []() -> std::string {
if (auto result = I18nAPI::getCurrentLanguageCode()) {
return result.value();
if (GMLIB_Level::getInstance()) {
return I18nAPI::getCurrentLanguageCode();
}
return "unknown";
});
+6 -4
View File
@@ -2,16 +2,18 @@
void Export_Legacy_GMLib_ServerAPI() {
RemoteCall::exportAs("GMLib_ServerAPI", "setEducationFeatureEnabled", []() -> void {
GMLIB_Level::addEducationEditionRequired();
GMLIB_Level::tryEnableEducationEdition();
});
RemoteCall::exportAs("GMLib_ServerAPI", "registerAbilityCommand", []() -> void {
GMLIB_Level::forceEnableAbilityCommand();
GMLIB_Level::tryRegisterAbilityCommand();
});
RemoteCall::exportAs("GMLib_ServerAPI", "setEnableAchievement", []() -> void {
GMLIB_Level::setForceAchievementsEnabled();
});
RemoteCall::exportAs("GMLib_ServerAPI", "setForceTrustSkins", []() -> void { GMLIB_Level::setForceTrustSkin(); });
RemoteCall::exportAs("GMLib_ServerAPI", "enableCoResourcePack", []() -> void { GMLIB_Level::setCoResourcePack(); });
RemoteCall::exportAs("GMLib_ServerAPI", "setForceTrustSkins", []() -> void { GMLIB_Level::trustAllSkins(); });
RemoteCall::exportAs("GMLib_ServerAPI", "enableCoResourcePack", []() -> void {
GMLIB_Level::requireServerResourcePackAndAllowClientResourcePack();
});
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string {
auto level = GMLIB_Level::getInstance();
if (!level) {