Skip to content

Commit

Permalink
refactor: update to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
OEOTYAN committed Dec 30, 2023
1 parent 262f718 commit 18646f1
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 105 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ compile_commands.json
CTestTestfile.cmake
_deps

.vscode

## XMake
/.xmake/
Expand Down
3 changes: 2 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "${pluginName}",
"entry": "${pluginFile}"
"entry": "${pluginFile}",
"type": "native"
}
26 changes: 26 additions & 0 deletions src/DllMain.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "Plugin.h"

namespace plugin_template {

// The global plugin instance.
std::unique_ptr<Plugin> plugin = nullptr;

extern "C" {
_declspec(dllexport) bool ll_plugin_load(ll::plugin::NativePlugin& self) {
plugin = std::make_unique<plugin_template::Plugin>(self);
return true;
}

/// @brief Unloads the plugin.Uninstalling a dll plugin is a very dangerous
/// thing. You must ensure that all resources are released before proceeding.
// _declspec(dllexport) bool ll_plugin_unload(ll::plugin::Plugin&) {
// plugin.reset();
// return true;
// }

_declspec(dllexport) bool ll_plugin_enable(ll::plugin::NativePlugin&) { return plugin->enable(); }

_declspec(dllexport) bool ll_plugin_disable(ll::plugin::NativePlugin&) { return plugin->disable(); }
}

} // namespace plugin_template
22 changes: 22 additions & 0 deletions src/Plugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "Plugin.h"

namespace plugin_template {

Plugin::Plugin(ll::plugin::NativePlugin& self) : mSelf(self) {
// Code for loading the plugin goes here.
mSelf.getLogger().warn("plugin_template loading");
}

bool Plugin::enable() {
// Code for enabling the plugin goes here.
mSelf.getLogger().warn("plugin_template enable");
return true;
}

bool Plugin::disable() {
// Code for disabling the plugin goes here.
mSelf.getLogger().warn("plugin_template disable");
return true;
}

} // namespace plugin_template
28 changes: 28 additions & 0 deletions src/Plugin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once

#include <ll/api/plugin/NativePlugin.h>

namespace plugin_template {

class Plugin {
public:
Plugin(ll::plugin::NativePlugin& self);

Plugin(Plugin&&) = delete;
Plugin(const Plugin&) = delete;
Plugin& operator=(Plugin&&) = delete;
Plugin& operator=(const Plugin&) = delete;

~Plugin() = default;

/// @return True if the plugin is enabled successfully.
bool enable();

/// @return True if the plugin is disabled successfully.
bool disable();

private:
ll::plugin::NativePlugin& mSelf;
};

} // namespace plugin_template
43 changes: 0 additions & 43 deletions src/better_suicide/DllMain.cpp

This file was deleted.

23 changes: 0 additions & 23 deletions src/better_suicide/Plugin.cpp

This file was deleted.

31 changes: 0 additions & 31 deletions src/better_suicide/Plugin.h

This file was deleted.

11 changes: 4 additions & 7 deletions xmake.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
add_repositories("liteldev-repo https://github.com/LiteLDev/xmake-repo.git")
add_requires("levilamina 0.2.1") -- Change this to your expected version.
add_requires("levilamina")

if not has_config("vs_runtime") then
set_runtimes("MD")
Expand Down Expand Up @@ -31,8 +31,7 @@ target("levilamina-plugin-template") -- Change this to your plugin name.
"NOMINMAX",
"UNICODE",
"WIN32_LEAN_AND_MEAN",
"ENTT_PACKED_PAGE=128",
"_HAS_CXX23=1"
"ENTT_PACKED_PAGE=128"
)
add_files(
"src/**.cpp"
Expand All @@ -44,9 +43,7 @@ target("levilamina-plugin-template") -- Change this to your plugin name.
"levilamina"
)
add_rules(
"mode.debug",
"mode.release",
"mode.releasedbg"
"mode.release"
)
add_shflags(
"/DELAYLOAD:bedrock_server.dll"
Expand All @@ -56,7 +53,7 @@ target("levilamina-plugin-template") -- Change this to your plugin name.
)
set_exceptions("none")
set_kind("shared")
set_languages("cxx20")
set_languages("c++23")
set_strip("all")

after_build(function (target)
Expand Down

0 comments on commit 18646f1

Please sign in to comment.