From 32e70d8318753016d286d70f1b9f2b482f4964ee Mon Sep 17 00:00:00 2001 From: Tsubasa6848 <116721335+Tsubasa6848@users.noreply.github.com> Date: Tue, 28 May 2024 08:39:32 +0800 Subject: [PATCH] refactor: optimize FloatingText --- lib/GMLIB_API-JS.js | 67 ++++++++++++++++------------------------ src/CompatibilityApi.cpp | 45 ++++++++++++++------------- src/Entry.cpp | 4 +-- src/EventAPI.cpp | 40 ++++++++++++------------ src/Global.h | 6 +++- src/LegacyModApi.cpp | 20 ++++++------ src/LegacyServerApi.cpp | 6 ++-- src/PlaceholderApi.cpp | 24 +++++++------- 8 files changed, 102 insertions(+), 110 deletions(-) diff --git a/lib/GMLIB_API-JS.js b/lib/GMLIB_API-JS.js index fc2c748..521fde8 100644 --- a/lib/GMLIB_API-JS.js +++ b/lib/GMLIB_API-JS.js @@ -120,7 +120,8 @@ const GMLIB_API = { getDestroyBlockSpeed: ll.import("GMLIB_API", "getDestroyBlockSpeed") } -const FloatingTextList = []; +const mStaticFloatingTextMap = new Map(); +const mDynamicFloatingTextMap = new Map(); class StaticFloatingText { constructor(pos, text, papi = true) { @@ -128,7 +129,7 @@ class StaticFloatingText { this.mText = text; this.mPlaceholderAPI = papi; this.mRuntimeId = GMLIB_API.createFloatingText(this.mPosition, this.mText, this.mPlaceholderAPI); - FloatingTextList.push(this); + mStaticFloatingTextMap.set(this.mRuntimeId, this); } sendToClient(player) { @@ -182,32 +183,21 @@ class StaticFloatingText { } destroy() { - let size_t = FloatingTextList.indexOf(this); - FloatingTextList.splice(size_t, 1); + mStaticFloatingTextMap.delete(this.mRuntimeId); return GMLIB_API.deleteFloatingText(this.mRuntimeId); } - isDynamic() { - return false; - } - static getFloatingText(runtimeId) { - for (const ft of FloatingTextList) { - if (ft.getRuntimeId() == runtimeId) { - if (!ft.isDynamic()) { - return ft; - } - } + if (mStaticFloatingTextMap.has(runtimeId)) { + return mStaticFloatingTextMap.get(runtimeId); } return null; } static getAllFloatingTexts() { let result = []; - FloatingTextList.forEach((ft) => { - if (!ft.isDynamic()) { - result.push(ft); - } + mStaticFloatingTextMap.forEach((ft) => { + result.push(ft); }); return result; } @@ -215,9 +205,13 @@ class StaticFloatingText { class DynamicFloatingText extends StaticFloatingText { constructor(pos, text, updateRate = 1, papi = true) { - super(pos, text, papi); + this.mPosition = pos; + this.mText = text; + this.mPlaceholderAPI = papi; + this.mRuntimeId = GMLIB_API.createFloatingText(this.mPosition, this.mText, this.mPlaceholderAPI); this.mUpdateRate = updateRate; this.mTaskId = null; + mDynamicFloatingTextMap.set(this.mRuntimeId, this); this.startUpdate(); } @@ -242,7 +236,7 @@ class DynamicFloatingText extends StaticFloatingText { } stopUpdate() { - if (this.mTaskId != null) { + if (this.mTaskId) { clearInterval(this.mTaskId); this.mTaskId = null; return true; @@ -251,32 +245,21 @@ class DynamicFloatingText extends StaticFloatingText { } destroy() { - let size_t = FloatingTextList.indexOf(this); - FloatingTextList.splice(size_t, 1); + mDynamicFloatingTextMap.delete(this.mRuntimeId); return GMLIB_API.deleteFloatingText(this.mRuntimeId); } - isDynamic() { - return true; - } - static getFloatingText(runtimeId) { - for (const ft of FloatingTextList) { - if (ft.getRuntimeId() == runtimeId) { - if (ft.isDynamic()) { - return ft; - } - } + if (mDynamicFloatingTextMap.has(runtimeId)) { + return mDynamicFloatingTextMap.get(runtimeId); } return null; } static getAllFloatingTexts() { let result = []; - FloatingTextList.forEach((ft) => { - if (ft.isDynamic()) { - result.push(ft); - } + mDynamicFloatingTextMap.forEach((ft) => { + result.push(ft); }); return result; } @@ -838,14 +821,18 @@ class I18nAPI { } static get(key, params = [], langCode = undefined) { + let data = []; + params.forEach((param) => { + data.push(param); + }); if (langCode) { - return GMLIB_API.resourcePackTranslate(key, params, langCode); + return GMLIB_API.resourcePackTranslate(key, data, langCode); } - return GMLIB_API.resourcePackDefaultTranslate(key, params); + return GMLIB_API.resourcePackDefaultTranslate(key, data); } - static translate(key, params = []) { - return I18nAPI.get(key, params); + static translate(key, params = [], langCode = undefined) { + return I18nAPI.get(key, params, langCode); } static getSupportedLanguages() { diff --git a/src/CompatibilityApi.cpp b/src/CompatibilityApi.cpp index b3e82e0..33306aa 100644 --- a/src/CompatibilityApi.cpp +++ b/src/CompatibilityApi.cpp @@ -19,10 +19,10 @@ void Export_Compatibility_API() { if (!level) { return false; } - return GMLIB::Mod::CustomRecipe::unregisterRecipe(id); + return CustomRecipe::unregisterRecipe(id); }); RemoteCall::exportAs("GMLIB_API", "setCustomPackPath", [](std::string const& path) -> void { - GMLIB::Mod::CustomPacks::addCustomPackPath(path); + CustomPacks::addCustomPackPath(path); }); RemoteCall::exportAs("GMLIB_API", "getServerMspt", []() -> float { auto level = GMLIB_Level::getInstance(); @@ -96,70 +96,71 @@ void Export_Compatibility_API() { "GMLIB_API", "createFloatingText", [](std::pair pos, std::string const& text, bool papi) -> int { - auto ft = std::make_shared(text, pos.first, pos.second, papi); - GMLIB::Server::FloatingTextManager::getInstance().add(ft); + auto& manager = FloatingTextManager::getInstance(); + auto ft = manager.createStatic(text, pos.first, pos.second, papi); + manager.add(ft); return ft->getRuntimeID(); } ); RemoteCall::exportAs("GMLIB_API", "setFloatingTextData", [](int id, std::string const& text) -> bool { - if (auto ft = GMLIB::Server::FloatingTextManager::getInstance().getFloatingText(id)) { + if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) { ft->setText(text); return true; } return false; }); RemoteCall::exportAs("GMLIB_API", "deleteFloatingText", [](int id) -> bool { - return GMLIB::Server::FloatingTextManager::getInstance().remove(id); + return FloatingTextManager::getInstance().remove(id); }); RemoteCall::exportAs("GMLIB_API", "sendFloatingTextToPlayer", [](int id, Player* pl) -> bool { - if (auto ft = GMLIB::Server::FloatingTextManager::getInstance().getFloatingText(id)) { + if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) { ft->sendTo(*pl); return true; } return false; }); RemoteCall::exportAs("GMLIB_API", "sendFloatingText", [](int id) -> bool { - if (auto ft = GMLIB::Server::FloatingTextManager::getInstance().getFloatingText(id)) { + if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) { ft->sendToClients(); return true; } return false; }); RemoteCall::exportAs("GMLIB_API", "removeFloatingTextFromPlayer", [](int id, Player* pl) -> bool { - if (auto ft = GMLIB::Server::FloatingTextManager::getInstance().getFloatingText(id)) { + if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) { ft->removeFrom(*pl); return true; } return false; }); RemoteCall::exportAs("GMLIB_API", "removeFloatingText", [](int id) -> bool { - if (auto ft = GMLIB::Server::FloatingTextManager::getInstance().getFloatingText(id)) { + if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) { ft->removeFromClients(); return true; } return false; }); RemoteCall::exportAs("GMLIB_API", "updateClientFloatingTextData", [](int id, Player* pl) -> bool { - if (auto ft = GMLIB::Server::FloatingTextManager::getInstance().getFloatingText(id)) { + if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) { ft->update(*pl); return true; } return false; }); RemoteCall::exportAs("GMLIB_API", "updateAllClientsFloatingTextData", [](int id) -> bool { - if (auto ft = GMLIB::Server::FloatingTextManager::getInstance().getFloatingText(id)) { + if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) { ft->updateClients(); return true; } return false; }); RemoteCall::exportAs("GMLIB_API", "isVersionMatched", [](int a, int b, int c) -> bool { - auto version = GMLIB::Version(a, b, c, "", ""); + auto version = Version(a, b, c, "", ""); return LIB_VERSION >= version; }); RemoteCall::exportAs("GMLIB_API", "getVersion_LRCA", []() -> std::string { return LIB_VERSION.asString(); }); RemoteCall::exportAs("GMLIB_API", "getVersion_GMLIB", []() -> std::string { - return GMLIB::Version::getLibVersionString(); + return Version::getLibVersionString(); }); RemoteCall::exportAs( "GMLIB_API", @@ -555,32 +556,32 @@ void Export_Compatibility_API() { ); RemoteCall::exportAs("GMLIB_API", "getXuidByUuid", [](std::string const& uuid) -> std::string { auto uid = mce::UUID::fromString(uuid); - auto result = GMLIB::UserCache::getXuidByUuid(uid); + auto result = UserCache::getXuidByUuid(uid); return result ? result.value() : ""; }); RemoteCall::exportAs("GMLIB_API", "getNameByUuid", [](std::string const& uuid) -> std::string { auto uid = mce::UUID::fromString(uuid); - auto result = GMLIB::UserCache::getNameByUuid(uid); + auto result = UserCache::getNameByUuid(uid); return result ? result.value() : ""; }); RemoteCall::exportAs("GMLIB_API", "getUuidByXuid", [](std::string const& xuid) -> std::string { - auto result = GMLIB::UserCache::getUuidByXuid(xuid); + auto result = UserCache::getUuidByXuid(xuid); return result ? result.value().asString() : ""; }); RemoteCall::exportAs("GMLIB_API", "getNameByXuid", [](std::string const& xuid) -> std::string { - auto result = GMLIB::UserCache::getNameByXuid(xuid); + auto result = UserCache::getNameByXuid(xuid); return result ? result.value() : ""; }); RemoteCall::exportAs("GMLIB_API", "getXuidByName", [](std::string const& name) -> std::string { - auto result = GMLIB::UserCache::getXuidByName(name); + auto result = UserCache::getXuidByName(name); return result ? result.value() : ""; }); RemoteCall::exportAs("GMLIB_API", "getUuidByName", [](std::string const& name) -> std::string { - auto result = GMLIB::UserCache::getUuidByName(name); + auto result = UserCache::getUuidByName(name); return result ? result.value().asString() : ""; }); RemoteCall::exportAs("GMLIB_API", "getUuidByName", [](std::string const& name) -> std::string { - auto result = GMLIB::UserCache::getUuidByName(name); + auto result = UserCache::getUuidByName(name); return result ? result.value().asString() : ""; }); RemoteCall::exportAs( @@ -588,7 +589,7 @@ void Export_Compatibility_API() { "getAllPlayerInfo", []() -> std::vector> { std::vector> result; - GMLIB::UserCache::forEach([&result](const GMLIB::UserCache::UserCacheEntry& entry) { + UserCache::forEach([&result](const UserCache::UserCacheEntry& entry) { std::unordered_map info; info["Name"] = entry.mName; info["Xuid"] = entry.mXuid; diff --git a/src/Entry.cpp b/src/Entry.cpp index aafca38..0abb2b9 100644 --- a/src/Entry.cpp +++ b/src/Entry.cpp @@ -19,7 +19,7 @@ bool LegacyRemoteCallApi::load() { logger.info("GMLIB-LegacyRemoteCallApi Loaded!"); logger.info( "Loaded Version: {} with {}", - fmt::format(fg(fmt::color::pink), "GMLIB-" + GMLIB::Version::getLibVersionString()), + fmt::format(fg(fmt::color::pink), "GMLIB-" + Version::getLibVersionString()), fmt::format(fg(fmt::color::light_green), "GMLIB-LegacyRemoteCallApi-" + LIB_VERSION.asString()) ); logger.info("Author: GroupMountain"); @@ -33,4 +33,4 @@ bool LegacyRemoteCallApi::disable() { return true; } } // namespace GMLIB -LL_REGISTER_PLUGIN(GMLIB::LegacyRemoteCallApi, GMLIB::LegacyRemoteCallApi::getInstance()); +LL_REGISTER_PLUGIN(LegacyRemoteCallApi, LegacyRemoteCallApi::getInstance()); diff --git a/src/EventAPI.cpp b/src/EventAPI.cpp index f675961..d0ea282 100644 --- a/src/EventAPI.cpp +++ b/src/EventAPI.cpp @@ -16,8 +16,8 @@ void Export_Event_API() { std::string const& serverXuid, std::string const& clientXuid )>(eventName, eventId); - eventBus->emplaceListener( - [Call](GMLIB::Event::PacketEvent::ClientLoginAfterEvent& ev) { + eventBus->emplaceListener( + [Call](Event::PacketEvent::ClientLoginAfterEvent& ev) { try { Call( ev.getRealName(), @@ -36,8 +36,8 @@ void Export_Event_API() { eventName, eventId ); - eventBus->emplaceListener( - [Call](GMLIB::Event::LevelEvent::WeatherUpdateBeforeEvent& ev) { + eventBus->emplaceListener( + [Call](Event::LevelEvent::WeatherUpdateBeforeEvent& ev) { bool result = true; try { result = Call( @@ -56,8 +56,8 @@ void Export_Event_API() { } case doHash("onMobPick"): { auto Call = RemoteCall::importAs(eventName, eventId); - eventBus->emplaceListener( - [Call](GMLIB::Event::EntityEvent::MobPickupItemBeforeEvent& ev) { + eventBus->emplaceListener( + [Call](Event::EntityEvent::MobPickupItemBeforeEvent& ev) { bool result = true; try { result = Call(&ev.self(), (Actor*)&ev.getItemActor()); @@ -72,8 +72,8 @@ void Export_Event_API() { case doHash("onItemTrySpawn"): { auto Call = RemoteCall::importAs< bool(const ItemStack* item, std::pair position, Actor* spawner)>(eventName, eventId); - eventBus->emplaceListener( - [Call](GMLIB::Event::EntityEvent::ItemActorSpawnBeforeEvent& ev) { + eventBus->emplaceListener( + [Call](Event::EntityEvent::ItemActorSpawnBeforeEvent& ev) { auto pos = ev.getPosition(); auto dimid = ev.getBlockSource().getDimensionId().id; std::pair lsePos = {pos, dimid}; @@ -94,8 +94,8 @@ void Export_Event_API() { eventName, eventId ); - eventBus->emplaceListener( - [Call](GMLIB::Event::EntityEvent::ItemActorSpawnAfterEvent& ev) { + eventBus->emplaceListener( + [Call](Event::EntityEvent::ItemActorSpawnAfterEvent& ev) { auto pos = ev.getPosition(); auto dimid = ev.getBlockSource().getDimensionId().id; std::pair lsePos = {pos, dimid}; @@ -108,8 +108,8 @@ void Export_Event_API() { } case doHash("onEntityChangeDim"): { auto Call = RemoteCall::importAs(eventName, eventId); - eventBus->emplaceListener( - [Call](GMLIB::Event::EntityEvent::ActorChangeDimensionBeforeEvent& ev) { + eventBus->emplaceListener( + [Call](Event::EntityEvent::ActorChangeDimensionBeforeEvent& ev) { bool result = true; try { result = Call(&ev.self(), ev.getToDimensionId()); @@ -123,8 +123,8 @@ void Export_Event_API() { } case doHash("onLeaveBed"): { auto Call = RemoteCall::importAs(eventName, eventId); - eventBus->emplaceListener( - [Call](GMLIB::Event::PlayerEvent::PlayerStopSleepBeforeEvent& ev) { + eventBus->emplaceListener( + [Call](Event::PlayerEvent::PlayerStopSleepBeforeEvent& ev) { bool result = true; try { result = Call(&ev.self()); @@ -142,8 +142,8 @@ void Export_Event_API() { eventName, eventId ); - eventBus->emplaceListener( - [Call](GMLIB::Event::EntityEvent::DeathMessageAfterEvent& ev) { + eventBus->emplaceListener( + [Call](Event::EntityEvent::DeathMessageAfterEvent& ev) { auto msg = ev.getDeathMessage(); auto source = ev.getDamageSource(); try { @@ -158,8 +158,8 @@ void Export_Event_API() { eventName, eventId ); - eventBus->emplaceListener( - [Call](GMLIB::Event::EntityEvent::MobHurtAfterEvent& ev) { + eventBus->emplaceListener( + [Call](Event::EntityEvent::MobHurtAfterEvent& ev) { auto& damageSource = ev.getSource(); Actor* source = nullptr; if (damageSource.isEntitySource()) { @@ -178,8 +178,8 @@ void Export_Event_API() { } case doHash("onEndermanTake"): { auto Call = RemoteCall::importAs(eventName, eventId); - eventBus->emplaceListener( - [Call](GMLIB::Event::EntityEvent::EndermanTakeBlockBeforeEvent& ev) { + eventBus->emplaceListener( + [Call](Event::EntityEvent::EndermanTakeBlockBeforeEvent& ev) { bool result = true; try { result = Call(&ev.self()); diff --git a/src/Global.h b/src/Global.h index 4add570..f768e81 100644 --- a/src/Global.h +++ b/src/Global.h @@ -3,13 +3,17 @@ #include +using namespace GMLIB; +using namespace Server; +using namespace Mod; + #define PLUGIN_NAME fmt::format(fg(fmt::color::light_green), "GMLIB-LRCA") #define LIB_VERSION_MAJOR 0 #define LIB_VERSION_MINOR 12 #define LIB_VERSION_PATCH 7 -#define LIB_VERSION GMLIB::Version(LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH) +#define LIB_VERSION Version(LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH) extern ll::Logger logger; diff --git a/src/LegacyModApi.cpp b/src/LegacyModApi.cpp index b9b41dd..3cab3db 100644 --- a/src/LegacyModApi.cpp +++ b/src/LegacyModApi.cpp @@ -33,7 +33,7 @@ void Export_Legacy_GMLib_ModAPI() { } auto res = RecipeIngredient(result, 0, count); auto unl = makeRecipeUnlockingKey(unlock); - GMLIB::Mod::JsonRecipe::registerShapelessCraftingTableRecipe(recipe_id, types, res, unl); + JsonRecipe::registerShapelessCraftingTableRecipe(recipe_id, types, res, unl); } ); RemoteCall::exportAs( @@ -56,7 +56,7 @@ void Export_Legacy_GMLib_ModAPI() { } auto res = RecipeIngredient(result, 0, count); auto unl = makeRecipeUnlockingKey(unlock); - GMLIB::Mod::JsonRecipe::registerShapedCraftingTableRecipe(recipe_id, shape, types, res, unl); + JsonRecipe::registerShapedCraftingTableRecipe(recipe_id, shape, types, res, unl); } ); RemoteCall::exportAs( @@ -72,7 +72,7 @@ void Export_Legacy_GMLib_ModAPI() { } auto inp = RecipeIngredient(input, 0, 1); auto outp = RecipeIngredient(output, 0, 1); - GMLIB::Mod::JsonRecipe::registerFurnaceRecipe(recipe_id, inp, outp, tags); + JsonRecipe::registerFurnaceRecipe(recipe_id, inp, outp, tags); } ); RemoteCall::exportAs( @@ -85,7 +85,7 @@ void Export_Legacy_GMLib_ModAPI() { return; } auto rea = RecipeIngredient(reagent, 0, 1); - GMLIB::Mod::JsonRecipe::registerBrewingMixRecipe(recipe_id, input, output, rea); + JsonRecipe::registerBrewingMixRecipe(recipe_id, input, output, rea); } ); RemoteCall::exportAs( @@ -100,7 +100,7 @@ void Export_Legacy_GMLib_ModAPI() { auto inp = RecipeIngredient(input, 0, 1); auto outp = RecipeIngredient(output, 0, 1); auto rea = RecipeIngredient(reagent, 0, 1); - GMLIB::Mod::JsonRecipe::registerBrewingContainerRecipe(recipe_id, inp, outp, rea); + JsonRecipe::registerBrewingContainerRecipe(recipe_id, inp, outp, rea); } ); RemoteCall::exportAs( @@ -115,7 +115,7 @@ void Export_Legacy_GMLib_ModAPI() { if (!level) { return; } - GMLIB::Mod::JsonRecipe::registerSmithingTransformRecipe( + JsonRecipe::registerSmithingTransformRecipe( recipe_id, smithing_template, base, @@ -135,7 +135,7 @@ void Export_Legacy_GMLib_ModAPI() { if (!level) { return; } - GMLIB::Mod::JsonRecipe::registerSmithingTrimRecipe(recipe_id, smithing_template, base, addition); + JsonRecipe::registerSmithingTrimRecipe(recipe_id, smithing_template, base, addition); } ); RemoteCall::exportAs( @@ -153,12 +153,12 @@ void Export_Legacy_GMLib_ModAPI() { } auto inp = RecipeIngredient(input, 0, 1); auto outp = RecipeIngredient(output, 0, 1); - GMLIB::Mod::JsonRecipe::registerStoneCutterRecipe(recipe_id, inp, outp); + JsonRecipe::registerStoneCutterRecipe(recipe_id, inp, outp); } ); // 错误方块清理 RemoteCall::exportAs("GMLib_ModAPI", "setUnknownBlockCleaner", []() -> void { - GMLIB::Mod::VanillaFix::setAutoCleanUnknownBlockEnabled(); + VanillaFix::setAutoCleanUnknownBlockEnabled(); }); // 实验性 RemoteCall::exportAs("GMLib_ModAPI", "registerExperimentsRequire", [](int experiment_id) -> void { @@ -193,6 +193,6 @@ void Export_Legacy_GMLib_ModAPI() { return false; }); RemoteCall::exportAs("GMLib_ModAPI", "setFixI18nEnabled", []() -> void { - GMLIB::Mod::VanillaFix::setFixI18nEnabled(); + VanillaFix::setFixI18nEnabled(); }); } \ No newline at end of file diff --git a/src/LegacyServerApi.cpp b/src/LegacyServerApi.cpp index d829004..d3fb494 100644 --- a/src/LegacyServerApi.cpp +++ b/src/LegacyServerApi.cpp @@ -64,13 +64,13 @@ void Export_Legacy_GMLib_ServerAPI() { "GMLib_ServerAPI", "addFakeList", [](const std::string& name, const std::string& xuid) -> bool { - return GMLIB::Server::FakeList::addFakeList(name, xuid, ActorUniqueID(-1)); + return FakeList::addFakeList(name, xuid, ActorUniqueID(-1)); } ); RemoteCall::exportAs("GMLib_ServerAPI", "removeFakeList", [](const std::string& nameOrXuid) -> bool { - return GMLIB::Server::FakeList::removeFakeList(nameOrXuid); + return FakeList::removeFakeList(nameOrXuid); }); RemoteCall::exportAs("GMLib_ServerAPI", "removeAllFakeList", []() -> void { - return GMLIB::Server::FakeList::removeAllFakeLists(); + return FakeList::removeAllFakeLists(); }); } diff --git a/src/PlaceholderApi.cpp b/src/PlaceholderApi.cpp index 52519e6..16341c4 100644 --- a/src/PlaceholderApi.cpp +++ b/src/PlaceholderApi.cpp @@ -13,10 +13,10 @@ bool isParameters(std::string const& str) { return std::regex_search(removeBrackets(str), reg); } -std::string GetValue(std::string const& from) { return GMLIB::Server::PlaceholderAPI::getValue(from); } +std::string GetValue(std::string const& from) { return PlaceholderAPI::getValue(from); } std::string GetValueWithPlayer(std::string const& a1, std::string const& a2) { - return GMLIB::Server::PlaceholderAPI::getValue(a1, ll::service::bedrock::getLevel()->getPlayer(a2)); + return PlaceholderAPI::getValue(a1, ll::service::bedrock::getLevel()->getPlayer(a2)); } bool registerPlayerPlaceholder( @@ -30,14 +30,14 @@ bool registerPlayerPlaceholder( PluginName, FuncName ); - GMLIB::Server::PlaceholderAPI::registerPlayerPlaceholder( + PlaceholderAPI::registerPlayerPlaceholder( PAPIName, [Call](Player* sp, std::unordered_map map) { return Call(sp, map); }, PluginName ); } else { auto Call = RemoteCall::importAs(PluginName, FuncName); - GMLIB::Server::PlaceholderAPI::registerPlayerPlaceholder( + PlaceholderAPI::registerPlayerPlaceholder( PAPIName, [Call](Player* sp) { return Call(sp); }, PluginName @@ -57,14 +57,14 @@ bool registerServerPlaceholder( if (isParameters(PAPIName)) { auto Call = RemoteCall::importAs)>(PluginName, FuncName); - GMLIB::Server::PlaceholderAPI::registerServerPlaceholder( + PlaceholderAPI::registerServerPlaceholder( PAPIName, [Call](std::unordered_map map) { return Call(map); }, PluginName ); } else { auto Call = RemoteCall::importAs(PluginName, FuncName); - GMLIB::Server::PlaceholderAPI::registerServerPlaceholder(PAPIName, [Call]() { return Call(); }, PluginName); + PlaceholderAPI::registerServerPlaceholder(PAPIName, [Call]() { return Call(); }, PluginName); } return true; } @@ -81,13 +81,13 @@ bool registerStaticPlaceholder( if (isParameters(PAPIName)) { auto Call = RemoteCall::importAs(PluginName, FuncName); if (num == -1) { - GMLIB::Server::PlaceholderAPI::registerStaticPlaceholder( + PlaceholderAPI::registerStaticPlaceholder( PAPIName, [Call] { return Call(); }, PluginName ); } else { - GMLIB::Server::PlaceholderAPI::registerStaticPlaceholder( + PlaceholderAPI::registerStaticPlaceholder( PAPIName, num, [Call] { return Call(); }, @@ -101,14 +101,14 @@ bool registerStaticPlaceholder( } std::string translateStringWithPlayer(std::string const& str, Player* pl) { - return GMLIB::Server::PlaceholderAPI::translateString(str, pl); + return PlaceholderAPI::translateString(str, pl); } -std::string translateString(std::string const& str) { return GMLIB::Server::PlaceholderAPI::translateString(str); } +std::string translateString(std::string const& str) { return PlaceholderAPI::translateString(str); } -bool unRegisterPlaceholder(std::string const& str) { return GMLIB::Server::PlaceholderAPI::unregisterPlaceholder(str); } +bool unRegisterPlaceholder(std::string const& str) { return PlaceholderAPI::unregisterPlaceholder(str); } -std::vector getAllPAPI() { return GMLIB::Server::PlaceholderAPI::getAllPAPI(); } +std::vector getAllPAPI() { return PlaceholderAPI::getAllPAPI(); } } // namespace PAPIRemoteCall