From a4d568620d4381c4c87440f78f94b4c2349f5c7c Mon Sep 17 00:00:00 2001 From: Tsubasa6848 <116721335+Tsubasa6848@users.noreply.github.com> Date: Thu, 8 Feb 2024 21:43:05 +0800 Subject: [PATCH] feat: add more api --- src/CompatibilityApi.cpp | 16 ++++++++++++++++ src/Global.h | 6 +++++- src/LegacyModApi.cpp | 2 +- src/LegacyServerApi.cpp | 2 +- src/Plugin.cpp | 4 +++- 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/CompatibilityApi.cpp b/src/CompatibilityApi.cpp index e69de29..a572e22 100644 --- a/src/CompatibilityApi.cpp +++ b/src/CompatibilityApi.cpp @@ -0,0 +1,16 @@ +#include "Global.h" + +void Export_Compatibility_API() { + RemoteCall::exportAs("GMLIB_API", "getServerMspt", []() -> float { + return GMLIB_Level::getLevel()->getServerMspt(); + }); + RemoteCall::exportAs("GMLIB_API", "getServerCurrentTps", []() -> float { + return GMLIB_Level::getLevel()->getServerCurrentTps(); + }); + RemoteCall::exportAs("GMLIB_API", "getServerAverageTps", []() -> float { + return GMLIB_Level::getLevel()->getServerAverageTps(); + }); + RemoteCall::exportAs("GMLIB_API", "getAllPlayerUuids", []() -> std::vector { + return GMLIB_Player::getAllUuids(); + }); +} \ No newline at end of file diff --git a/src/Global.h b/src/Global.h index 774383a..c445e32 100644 --- a/src/Global.h +++ b/src/Global.h @@ -4,4 +4,8 @@ #define PLUGIN_NAME "GMLIB-LRCA" -extern ll::Logger logger; \ No newline at end of file +extern ll::Logger logger; + +extern void Export_Legacy_GMLib_ModAPI(); +extern void Export_Legacy_GMLib_ServerAPI(); +extern void Export_Compatibility_API(); \ No newline at end of file diff --git a/src/LegacyModApi.cpp b/src/LegacyModApi.cpp index 609195c..fd8bc1b 100644 --- a/src/LegacyModApi.cpp +++ b/src/LegacyModApi.cpp @@ -13,7 +13,7 @@ std::variant> makeRecipeUnlockingKey( return result; } -void ExportGMLib_ModAPI() { +void Export_Legacy_GMLib_ModAPI() { // 合成表部分 RemoteCall::exportAs( "GMLib_ModAPI", diff --git a/src/LegacyServerApi.cpp b/src/LegacyServerApi.cpp index 07647b7..0a7a385 100644 --- a/src/LegacyServerApi.cpp +++ b/src/LegacyServerApi.cpp @@ -1,6 +1,6 @@ #include "Global.h" -void ExportGMLib_ServerAPI() { +void Export_Legacy_GMLib_ServerAPI() { RemoteCall::exportAs("GMLib_ServerAPI", "setEducationFeatureEnabled", []() -> void { GMLIB_Level::addEducationEditionRequired(); }); diff --git a/src/Plugin.cpp b/src/Plugin.cpp index f6cdb5e..a9b0f8e 100644 --- a/src/Plugin.cpp +++ b/src/Plugin.cpp @@ -7,7 +7,9 @@ namespace plugin { Plugin::Plugin(ll::plugin::NativePlugin& self) : mSelf(self) { // Code for loading the plugin goes here. - + Export_Legacy_GMLib_ModAPI(); + Export_Legacy_GMLib_ServerAPI(); + Export_Compatibility_API(); logger.info("GMLIB-LegacyRemoteCallApi Loaded!"); logger.info("Author: GroupMountain"); logger.info("Repository: https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi");