feat: adapt to gmlib 1.2.0-rc.1
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "${pluginName}",
|
"name": "${pluginName}",
|
||||||
"entry": "${pluginFile}",
|
"entry": "${pluginFile}",
|
||||||
"version": "1.0.1",
|
"version": "1.1.1",
|
||||||
"author": "GroupMountain",
|
"author": "GroupMountain",
|
||||||
"type": "native",
|
"type": "native",
|
||||||
"passive": true,
|
"passive": true,
|
||||||
|
|||||||
+17
-20
@@ -1,4 +1,5 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
#include "mc/platform/UUID.h"
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
|
||||||
ActorUniqueID parseScriptUniqueID(std::string const& uniqueId) {
|
ActorUniqueID parseScriptUniqueID(std::string const& uniqueId) {
|
||||||
@@ -35,7 +36,7 @@ void Export_Compatibility_API() {
|
|||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerNbt", [](std::string const& uuid) -> std::unique_ptr<CompoundTag> {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerNbt", [](std::string const& uuid) -> std::unique_ptr<CompoundTag> {
|
||||||
if (auto player = OfflinePlayer::getOfflinePlayer(mce::UUID::fromString(uuid))) {
|
if (auto player = OfflinePlayer::fromUuid(mce::UUID::fromString(uuid))) {
|
||||||
return std::make_unique<CompoundTag>(*player->getNbt());
|
return std::make_unique<CompoundTag>(*player->getNbt());
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -44,7 +45,7 @@ void Export_Compatibility_API() {
|
|||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"setPlayerNbt",
|
"setPlayerNbt",
|
||||||
[](std::string const& uuid, CompoundTag* nbt, bool forceCreate) -> bool {
|
[](std::string const& uuid, CompoundTag* nbt, bool forceCreate) -> bool {
|
||||||
if (auto player = OfflinePlayer::getOfflinePlayer(mce::UUID::fromString(uuid))) return player->setNbt(*nbt);
|
if (auto player = OfflinePlayer::fromUuid(mce::UUID::fromString(uuid))) return player->setNbt(*nbt);
|
||||||
return forceCreate ? OfflinePlayer::createNewPlayerNbt(mce::UUID::fromString(uuid), *nbt).has_value()
|
return forceCreate ? OfflinePlayer::createNewPlayerNbt(mce::UUID::fromString(uuid), *nbt).has_value()
|
||||||
: false;
|
: false;
|
||||||
}
|
}
|
||||||
@@ -53,7 +54,7 @@ void Export_Compatibility_API() {
|
|||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"setPlayerNbtTags",
|
"setPlayerNbtTags",
|
||||||
[](std::string const& uuid, CompoundTag* nbt, std::vector<std::string> tags) -> bool {
|
[](std::string const& uuid, CompoundTag* nbt, std::vector<std::string> tags) -> bool {
|
||||||
if (auto player = OfflinePlayer::getOfflinePlayer(mce::UUID::fromString(uuid))) {
|
if (auto player = OfflinePlayer::fromUuid(mce::UUID::fromString(uuid))) {
|
||||||
auto nbt2 = *player->getNbt();
|
auto nbt2 = *player->getNbt();
|
||||||
GMCompoundTag::writeNbtTags(nbt2, *nbt, tags);
|
GMCompoundTag::writeNbtTags(nbt2, *nbt, tags);
|
||||||
return player->setNbt(nbt2);
|
return player->setNbt(nbt2);
|
||||||
@@ -200,7 +201,7 @@ void Export_Compatibility_API() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerPosition", [](std::string const& uuid) -> std::pair<BlockPos, int> {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerPosition", [](std::string const& uuid) -> std::pair<BlockPos, int> {
|
||||||
if (auto player = OfflinePlayer::getOfflinePlayer(mce::UUID::fromString(uuid))) {
|
if (auto player = OfflinePlayer::fromUuid(mce::UUID::fromString(uuid))) {
|
||||||
if (auto pos = player->getPlayerPosition()) {
|
if (auto pos = player->getPlayerPosition()) {
|
||||||
return *pos;
|
return *pos;
|
||||||
}
|
}
|
||||||
@@ -214,7 +215,7 @@ void Export_Compatibility_API() {
|
|||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"setPlayerPosition",
|
"setPlayerPosition",
|
||||||
[](std::string const& uuid, std::pair<BlockPos, int> pos) -> bool {
|
[](std::string const& uuid, std::pair<BlockPos, int> pos) -> bool {
|
||||||
if (auto player = OfflinePlayer::getOfflinePlayer(mce::UUID::fromString(uuid))) {
|
if (auto player = OfflinePlayer::fromUuid(mce::UUID::fromString(uuid))) {
|
||||||
return player->setPosition(pos.first, pos.second);
|
return player->setPosition(pos.first, pos.second);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -475,33 +476,29 @@ void Export_Compatibility_API() {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "getXuidByUuid", [](std::string const& uuid) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getXuidByUuid", [](std::string const& uuid) -> std::string {
|
||||||
return UserCache::getXuidByUuid(mce::UUID::fromString(uuid)).value_or("");
|
return UserCache::getInstance()->from(mce::UUID::fromString(uuid))->mXuid;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getXuidByName", [](std::string const& name) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getXuidByName", [](std::string const& name) -> std::string {
|
||||||
return UserCache::getXuidByName(name).value_or("");
|
return UserCache::getInstance()->from(name)->mXuid;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getNameByUuid", [](std::string const& uuid) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getNameByUuid", [](std::string const& uuid) -> std::string {
|
||||||
return UserCache::getNameByUuid(mce::UUID::fromString(uuid)).value_or("");
|
return UserCache::getInstance()->from(mce::UUID::fromString(uuid))->mName;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getNameByXuid", [](std::string const& xuid) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getNameByXuid", [](std::string const& xuid) -> std::string {
|
||||||
return UserCache::getNameByXuid(xuid).value_or("");
|
return UserCache::getInstance()->from(xuid, UserCache::QueryType::Xuid)->mName;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getUuidByXuid", [](std::string const& xuid) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getUuidByXuid", [](std::string const& xuid) -> std::string {
|
||||||
return UserCache::getUuidByXuid(xuid).transform(
|
return UserCache::getInstance()->from(xuid, UserCache::QueryType::Xuid)->mUuid.asString();
|
||||||
[](mce::UUID&& uuid) -> std::string { return uuid.asString(); }
|
|
||||||
).value_or("");
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getUuidByName", [](std::string const& name) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getUuidByName", [](std::string const& name) -> std::string {
|
||||||
return UserCache::getUuidByName(name).transform(
|
return UserCache::getInstance()->from(name)->mUuid.asString();
|
||||||
[](mce::UUID&& uuid) -> std::string { return uuid.asString(); }
|
|
||||||
).value_or("");
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"getAllPlayerInfo",
|
"getAllPlayerInfo",
|
||||||
[]() -> std::vector<std::unordered_map<std::string, std::string>> {
|
[]() -> std::vector<std::unordered_map<std::string, std::string>> {
|
||||||
std::vector<std::unordered_map<std::string, std::string>> result;
|
std::vector<std::unordered_map<std::string, std::string>> result;
|
||||||
for (auto entry : UserCache::entries()) {
|
for (auto entry : UserCache::getInstance()->entries()) {
|
||||||
result.push_back({
|
result.push_back({
|
||||||
{"Name", entry.mName },
|
{"Name", entry.mName },
|
||||||
{"Xuid", entry.mXuid },
|
{"Xuid", entry.mXuid },
|
||||||
@@ -612,21 +609,21 @@ void Export_Compatibility_API() {
|
|||||||
result.push_back({
|
result.push_back({
|
||||||
{"Name", gameRule.mName },
|
{"Name", gameRule.mName },
|
||||||
{"Type", "Bool" },
|
{"Type", "Bool" },
|
||||||
{"Value", std::to_string(gameRule.mValue->mUnk29fff1.as<bool>())}
|
{"Value", std::to_string(gameRule.mValue->boolVal)}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case GameRule::Type::Float:
|
case GameRule::Type::Float:
|
||||||
result.push_back({
|
result.push_back({
|
||||||
{"Name", gameRule.mName },
|
{"Name", gameRule.mName },
|
||||||
{"Type", "Float" },
|
{"Type", "Float" },
|
||||||
{"Value", std::to_string(gameRule.mValue->mUnk768db5.as<float>())}
|
{"Value", std::to_string(gameRule.mValue->floatVal)}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case GameRule::Type::Int:
|
case GameRule::Type::Int:
|
||||||
result.push_back({
|
result.push_back({
|
||||||
{"Name", gameRule.mName },
|
{"Name", gameRule.mName },
|
||||||
{"Type", "Int" },
|
{"Type", "Int" },
|
||||||
{"Value", std::to_string(gameRule.mValue->mUnk2ab4f3.as<int>())}
|
{"Value", std::to_string(gameRule.mValue->intVal)}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case GameRule::Type::Invalid:
|
case GameRule::Type::Invalid:
|
||||||
@@ -804,7 +801,7 @@ void Export_Compatibility_API() {
|
|||||||
return magic_enum::enum_name(container->mContainerType).data();
|
return magic_enum::enum_name(container->mContainerType).data();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "hasPlayerNbt", [](std::string const& uuid) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "hasPlayerNbt", [](std::string const& uuid) -> bool {
|
||||||
return OfflinePlayer::getOfflinePlayer(mce::UUID::fromString(uuid))
|
return OfflinePlayer::fromUuid(mce::UUID::fromString(uuid))
|
||||||
.transform([&](auto&& player) -> bool { return player.hasNbt(); })
|
.transform([&](auto&& player) -> bool { return player.hasNbt(); })
|
||||||
.value_or(false);
|
.value_or(false);
|
||||||
});
|
});
|
||||||
|
|||||||
+3
-3
@@ -2,7 +2,7 @@
|
|||||||
"format_version": 3,
|
"format_version": 3,
|
||||||
"format_uuid": "289f771f-2c9a-4d73-9f3f-8492495a924d",
|
"format_uuid": "289f771f-2c9a-4d73-9f3f-8492495a924d",
|
||||||
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
||||||
"version": "1.0.1",
|
"version": "1.1.1",
|
||||||
"info": {
|
"info": {
|
||||||
"name": "GMLIB-LegacyRemoteCallApi",
|
"name": "GMLIB-LegacyRemoteCallApi",
|
||||||
"description": "Legacy RemoteCall API for GMLIB",
|
"description": "Legacy RemoteCall API for GMLIB",
|
||||||
@@ -20,8 +20,8 @@
|
|||||||
"platform": "win-x64",
|
"platform": "win-x64",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"github.com/LiteLDev/LeviLamina": ">=1.1.1",
|
"github.com/LiteLDev/LeviLamina": ">=1.1.1",
|
||||||
"github.com/GroupMountain/GMLIB-Release": ">=1.0.0",
|
"github.com/GroupMountain/GMLIB-Release": ">=1.2.0-rc.1",
|
||||||
"github.com/MiracleForest/iListenAttentively-Release": ">=0.4.1"
|
"github.com/MiracleForest/iListenAttentively-Release": ">=0.5.0-rc.1"
|
||||||
},
|
},
|
||||||
"assets": [
|
"assets": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ if not has_config("vs_runtime") then
|
|||||||
set_runtimes("MD")
|
set_runtimes("MD")
|
||||||
end
|
end
|
||||||
|
|
||||||
add_requires("levilamina 1.1.1", {configs = {target_type = "server"}})
|
add_requires("levilamina 1.2.0", {configs = {target_type = "server"}})
|
||||||
add_requires("legacyremotecall")
|
add_requires("legacyremotecall")
|
||||||
add_requires("levibuildscript")
|
add_requires("levibuildscript")
|
||||||
add_requires("ilistenattentively")
|
add_requires("ilistenattentively 0.5.0-rc.1")
|
||||||
add_requires("gmlib")
|
add_requires("gmlib 1.2.0-rc.1")
|
||||||
|
|
||||||
target("GMLIB-LegacyRemoteCallApi")
|
target("GMLIB-LegacyRemoteCallApi")
|
||||||
add_cxflags(
|
add_cxflags(
|
||||||
|
|||||||
Reference in New Issue
Block a user