Initial commit

This commit is contained in:
Caixukun1919810
2024-02-27 14:07:17 +08:00
committed by GitHub
Unverified
commit b4609b0912
17 changed files with 652 additions and 0 deletions
+83
View File
@@ -0,0 +1,83 @@
#include "Entry.h"
#include "Global.h"
#include <fmt/format.h>
#include <functional>
#include <ll/api/Config.h>
#include <ll/api/io/FileUtils.h>
#include <ll/api/plugin/NativePlugin.h>
#include <ll/api/plugin/PluginManagerRegistry.h>
#include <memory>
#include <stdexcept>
ll::Logger logger(PLUGIN_NAME);
namespace change_this {
namespace {
std::unique_ptr<std::reference_wrapper<ll::plugin::NativePlugin>>
selfPluginInstance; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
auto disable(ll::plugin::NativePlugin& /*self*/) -> bool {
logger.info("disabling...");
// Your code here.
logger.info("disabled");
return true;
}
auto enable(ll::plugin::NativePlugin& /*self*/) -> bool {
logger.info("enabling...");
logger.info("enabled");
return true;
}
auto load(ll::plugin::NativePlugin& self) -> bool {
logger.info("loading...");
selfPluginInstance = std::make_unique<std::reference_wrapper<ll::plugin::NativePlugin>>(self);
// Your code here.
logger.info("loaded");
return true;
}
auto unload(ll::plugin::NativePlugin& self) -> bool {
auto& logger = self.getLogger();
logger.info("unloading...");
selfPluginInstance.reset();
// Your code here.
logger.info("unloaded");
return true;
}
} // namespace
auto getSelfPluginInstance() -> ll::plugin::NativePlugin& {
if (!selfPluginInstance) {
throw std::runtime_error("selfPluginInstance is null");
}
return *selfPluginInstance;
}
} // namespace change_this
extern "C" {
_declspec(dllexport) auto ll_plugin_disable(ll::plugin::NativePlugin& self) -> bool {
return change_this::disable(self);
}
_declspec(dllexport) auto ll_plugin_enable(ll::plugin::NativePlugin& self) -> bool { return change_this::enable(self); }
_declspec(dllexport) auto ll_plugin_load(ll::plugin::NativePlugin& self) -> bool { return change_this::load(self); }
_declspec(dllexport) auto ll_plugin_unload(ll::plugin::NativePlugin& self) -> bool { return change_this::unload(self); }
}
+9
View File
@@ -0,0 +1,9 @@
#pragma once
#include <ll/api/plugin/NativePlugin.h>
namespace change_this {
[[nodiscard]] auto getSelfPluginInstance() -> ll::plugin::NativePlugin&;
} // namespace change_this
+7
View File
@@ -0,0 +1,7 @@
#pragma once
#include <ll/api/Logger.h>
// #include <include_all.h>
#define PLUGIN_NAME "plugin"
extern ll::Logger logger;
+6
View File
@@ -0,0 +1,6 @@
// This file will make your plugin use LeviLamina's memory operators by default.
// This improves the memory management of your plugin and is recommended to use.
#define LL_MEMORY_OPERATORS
#include <ll/api/memory/MemoryOperators.h>