chore: use new template
This commit is contained in:
+8
-34
@@ -5,17 +5,12 @@ ll::Logger logger(PLUGIN_NAME);
|
||||
|
||||
namespace GMLIB_LegacyRemoteCallApi {
|
||||
|
||||
namespace {
|
||||
std::unique_ptr<LRCA>& LRCA::getInstance() {
|
||||
static std::unique_ptr<LRCA> instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
std::unique_ptr<std::reference_wrapper<ll::plugin::NativePlugin>>
|
||||
selfPluginInstance; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
|
||||
auto disable(ll::plugin::NativePlugin& /*self*/) -> bool { return true; }
|
||||
|
||||
auto enable(ll::plugin::NativePlugin& /*self*/) -> bool { return true; }
|
||||
|
||||
auto load(ll::plugin::NativePlugin& self) -> bool {
|
||||
selfPluginInstance = std::make_unique<std::reference_wrapper<ll::plugin::NativePlugin>>(self);
|
||||
bool LRCA::load() {
|
||||
Export_Legacy_GMLib_ModAPI();
|
||||
Export_Legacy_GMLib_ServerAPI();
|
||||
Export_Compatibility_API();
|
||||
@@ -28,31 +23,10 @@ auto load(ll::plugin::NativePlugin& self) -> bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto unload(ll::plugin::NativePlugin& self) -> bool { return false; }
|
||||
bool LRCA::enable() { return true; }
|
||||
|
||||
} // namespace
|
||||
|
||||
auto getSelfPluginInstance() -> ll::plugin::NativePlugin& {
|
||||
if (!selfPluginInstance) {
|
||||
throw std::runtime_error("selfPluginInstance is null");
|
||||
}
|
||||
|
||||
return *selfPluginInstance;
|
||||
}
|
||||
bool LRCA::disable() { return true; }
|
||||
|
||||
} // namespace GMLIB_LegacyRemoteCallApi
|
||||
|
||||
extern "C" {
|
||||
_declspec(dllexport) auto ll_plugin_disable(ll::plugin::NativePlugin& self) -> bool {
|
||||
return GMLIB_LegacyRemoteCallApi::disable(self);
|
||||
}
|
||||
_declspec(dllexport) auto ll_plugin_enable(ll::plugin::NativePlugin& self) -> bool {
|
||||
return GMLIB_LegacyRemoteCallApi::enable(self);
|
||||
}
|
||||
_declspec(dllexport) auto ll_plugin_load(ll::plugin::NativePlugin& self) -> bool {
|
||||
return GMLIB_LegacyRemoteCallApi::load(self);
|
||||
}
|
||||
_declspec(dllexport) auto ll_plugin_unload(ll::plugin::NativePlugin& self) -> bool {
|
||||
return GMLIB_LegacyRemoteCallApi::unload(self);
|
||||
}
|
||||
}
|
||||
LL_REGISTER_PLUGIN(GMLIB_LegacyRemoteCallApi::LRCA, GMLIB_LegacyRemoteCallApi::LRCA::getInstance());
|
||||
|
||||
+26
-2
@@ -1,9 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include <ll/api/plugin/NativePlugin.h>
|
||||
#include <ll/api/plugin/RegisterHelper.h>
|
||||
|
||||
namespace GMLIB_LegacyRemoteCallApi {
|
||||
|
||||
[[nodiscard]] auto getSelfPluginInstance() -> ll::plugin::NativePlugin&;
|
||||
class LRCA {
|
||||
|
||||
public:
|
||||
static std::unique_ptr<LRCA>& getInstance();
|
||||
|
||||
LRCA(ll::plugin::NativePlugin& self) : mSelf(self) {}
|
||||
|
||||
[[nodiscard]] ll::plugin::NativePlugin& getSelf() const { return mSelf; }
|
||||
|
||||
/// @return True if the plugin is loaded successfully.
|
||||
bool load();
|
||||
|
||||
/// @return True if the plugin is enabled successfully.
|
||||
bool enable();
|
||||
|
||||
/// @return True if the plugin is disabled successfully.
|
||||
bool disable();
|
||||
|
||||
// TODO: Implement this method if you need to unload the plugin.
|
||||
// /// @return True if the plugin is unloaded successfully.
|
||||
// bool unload();
|
||||
|
||||
private:
|
||||
ll::plugin::NativePlugin& mSelf;
|
||||
};
|
||||
|
||||
} // namespace GMLIB_LegacyRemoteCallApi
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
#include <RemoteCallAPI.h>
|
||||
|
||||
#define PLUGIN_NAME "GMLIB-LRCA"
|
||||
#define LIB_VERSION SemVersion(0, 9, 1, "", "")
|
||||
#define LIB_VERSION SemVersion(0, 9, 4, "", "")
|
||||
|
||||
extern ll::Logger logger;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user