adapt: adapt GMLIB v0.13.7 and LeviLamina v0.13.5

This commit is contained in:
子沐呀
2024-12-07 19:01:04 +08:00
Unverified
parent 02ef60b69c
commit d8ca1764c1
9 changed files with 42 additions and 38 deletions
+4 -4
View File
@@ -48,11 +48,11 @@ jobs:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Download Plugin - name: Download Mod
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }} name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
path: release/Plugin/ path: release/Mod/
- name: Download PDB - name: Download PDB
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
@@ -62,11 +62,11 @@ jobs:
- name: Copy additional files - name: Copy additional files
run: | run: |
cp LICENSE README.md release/Plugin/ cp LICENSE README.md release/Mod/
- name: Archive release - name: Archive release
run: | run: |
cd release/Plugin cd release/Mod
zip -r ../${{ github.event.repository.name }}-windows-x64.zip * zip -r ../${{ github.event.repository.name }}-windows-x64.zip *
cd .. cd ..
+3 -3
View File
@@ -1,7 +1,7 @@
{ {
"name": "${pluginName}", "name": "${modName}",
"entry": "${pluginFile}", "entry": "${modFile}",
"version": "0.13.0", "version": "0.13.1",
"author": "GroupMountain", "author": "GroupMountain",
"description": "Check Player's Inventory", "description": "Check Player's Inventory",
"type": "native", "type": "native",
+7 -7
View File
@@ -82,7 +82,7 @@ function string_formatter(str, variables)
end) end)
end end
function pack_plugin(target,plugin_define) function pack_mod(target,mod_define)
import("lib.detect.find_file") import("lib.detect.find_file")
local manifest_path = find_file("manifest.json", os.projectdir()) local manifest_path = find_file("manifest.json", os.projectdir())
@@ -90,9 +90,9 @@ function pack_plugin(target,plugin_define)
local manifest = io.readfile(manifest_path) local manifest = io.readfile(manifest_path)
local bindir = path.join(os.projectdir(), "bin/DLL") local bindir = path.join(os.projectdir(), "bin/DLL")
local pdbdir = path.join(os.projectdir(), "bin/PDB") local pdbdir = path.join(os.projectdir(), "bin/PDB")
local outputdir = path.join(bindir, plugin_define.pluginName) local outputdir = path.join(bindir, mod_define.modName)
local targetfile = path.join(outputdir, plugin_define.pluginFile) local targetfile = path.join(outputdir, mod_define.modFile)
local pdbfile = path.join(pdbdir, path.basename(plugin_define.pluginFile) .. ".pdb") local pdbfile = path.join(pdbdir, path.basename(mod_define.modFile) .. ".pdb")
local manifestfile = path.join(outputdir, "manifest.json") local manifestfile = path.join(outputdir, "manifest.json")
local oritargetfile = target:targetfile() local oritargetfile = target:targetfile()
local oripdbfile = path.join(path.directory(oritargetfile), path.basename(oritargetfile) .. ".pdb") local oripdbfile = path.join(path.directory(oritargetfile), path.basename(oritargetfile) .. ".pdb")
@@ -103,9 +103,9 @@ function pack_plugin(target,plugin_define)
os.cp(oripdbfile, pdbfile) os.cp(oripdbfile, pdbfile)
end end
formattedmanifest = string_formatter(manifest, plugin_define) formattedmanifest = string_formatter(manifest, mod_define)
io.writefile(manifestfile,formattedmanifest) io.writefile(manifestfile,formattedmanifest)
cprint("${bright green}[Plugin Packer]: ${reset}plugin already generated to " .. outputdir) cprint("${bright green}[Mod Packer]: ${reset}mod already generated to " .. outputdir)
else else
cprint("${bright yellow}warn: ${reset}not found manifest.json in root dir!") cprint("${bright yellow}warn: ${reset}not found manifest.json in root dir!")
end end
@@ -113,7 +113,7 @@ end
return { return {
pack_plugin = pack_plugin, pack_mod = pack_mod,
beautify_json = beautify_json, beautify_json = beautify_json,
string_formatter = string_formatter string_formatter = string_formatter
} }
+3 -4
View File
@@ -2,7 +2,7 @@
#include "Global.h" #include "Global.h"
#include "Language.h" #include "Language.h"
ll::Logger logger(PLUGIN_NAME); ll::Logger logger(MOD_NAME);
namespace InventoryCheck { namespace InventoryCheck {
@@ -26,7 +26,6 @@ bool Entry::load() {
tr("error.protocolMismatch.version", tr("error.protocolMismatch.version",
{std::to_string(TARGET_PROTOCOL), std::to_string(GMLIB::Version::getProtocolVersion())}) {std::to_string(TARGET_PROTOCOL), std::to_string(GMLIB::Version::getProtocolVersion())})
); );
return false;
} }
return true; return true;
} }
@@ -40,7 +39,7 @@ bool Entry::enable() {
} }
bool Entry::disable() { bool Entry::disable() {
// Code for disabling the plugin goes here. // Code for disabling the mod goes here.
return true; return true;
} }
@@ -55,7 +54,7 @@ LangI18n& Entry::getI18n() { return mI18n.value(); }
} // namespace InventoryCheck } // namespace InventoryCheck
LL_REGISTER_PLUGIN(InventoryCheck::Entry, InventoryCheck::Entry::getInstance()); LL_REGISTER_MOD(InventoryCheck::Entry, InventoryCheck::Entry::getInstance());
std::string tr(std::string const& key, std::vector<std::string> const& data) { std::string tr(std::string const& key, std::vector<std::string> const& data) {
return InventoryCheck::Entry::getInstance()->getI18n().get(key, data); return InventoryCheck::Entry::getInstance()->getI18n().get(key, data);
+9 -7
View File
@@ -1,4 +1,6 @@
#pragma once #pragma once
#include <span>
#include "Config.h" #include "Config.h"
#include "Global.h" #include "Global.h"
@@ -11,20 +13,20 @@ class Entry {
public: public:
static std::unique_ptr<Entry>& getInstance(); static std::unique_ptr<Entry>& getInstance();
Entry(ll::plugin::NativePlugin& self) : mSelf(self) {} Entry(ll::mod::NativeMod& self) : mSelf(self) {}
[[nodiscard]] ll::plugin::NativePlugin& getSelf() const { return mSelf; } [[nodiscard]] ll::mod::NativeMod& getSelf() const { return mSelf; }
/// @return True if the plugin is loaded successfully. /// @return True if the mod is loaded successfully.
bool load(); bool load();
/// @return True if the plugin is enabled successfully. /// @return True if the mod is enabled successfully.
bool enable(); bool enable();
/// @return True if the plugin is disabled successfully. /// @return True if the mod is disabled successfully.
bool disable(); bool disable();
/// @return True if the plugin is unloaded successfully. /// @return True if the mod is unloaded successfully.
bool unload(); bool unload();
Config& getConfig(); Config& getConfig();
@@ -32,7 +34,7 @@ public:
LangI18n& getI18n(); LangI18n& getI18n();
private: private:
ll::plugin::NativePlugin& mSelf; ll::mod::NativeMod& mSelf;
std::optional<Config> mConfig; std::optional<Config> mConfig;
std::optional<LangI18n> mI18n; std::optional<LangI18n> mI18n;
}; };
+5 -2
View File
@@ -1,8 +1,11 @@
#pragma once #pragma once
#include <span>
#include <include_all.h> #include <include_all.h>
#define PLUGIN_NAME "InventoryCheck" #define MOD_NAME "InventoryCheck"
#define TARGET_PROTOCOL 685 #define TARGET_PROTOCOL 686
extern ll::Logger logger; extern ll::Logger logger;
+2 -2
View File
@@ -1,5 +1,5 @@
// This file will make your plugin use LeviLamina's memory operators by default. // This file will make your mod use LeviLamina's memory operators by default.
// This improves the memory management of your plugin and is recommended to use. // This improves the memory management of your mod and is recommended to use.
#define LL_MEMORY_OPERATORS #define LL_MEMORY_OPERATORS
+3 -3
View File
@@ -1,7 +1,7 @@
{ {
"format_version": 2, "format_version": 2,
"tooth": "github.com/GroupMountain/InventoryCheck", "tooth": "github.com/GroupMountain/InventoryCheck",
"version": "0.13.0", "version": "0.13.1",
"info": { "info": {
"name": "InventoryCheck", "name": "InventoryCheck",
"description": "Check Player's Inventory", "description": "Check Player's Inventory",
@@ -14,9 +14,9 @@
"gmlib" "gmlib"
] ]
}, },
"asset_url": "https://github.com/GroupMountain/InventoryCheck/releases/download/v0.13.0/InventoryCheck-windows-x64.zip", "asset_url": "https://github.com/GroupMountain/InventoryCheck/releases/download/v0.13.1/InventoryCheck-windows-x64.zip",
"dependencies": { "dependencies": {
"github.com/GroupMountain/GMLIB": ">=0.13.0" "github.com/GroupMountain/GMLIB": ">=0.13.7"
}, },
"files": { "files": {
"place": [ "place": [
+6 -6
View File
@@ -42,7 +42,7 @@ add_requires("gmlib")
-- import("package.tools.xmake").install(package) -- import("package.tools.xmake").install(package)
-- end) -- end)
target("InventoryCheck") -- Change this to your plugin name. target("InventoryCheck") -- Change this to your mod name.
add_cxflags( add_cxflags(
"/EHa", "/EHa",
"/utf-8" "/utf-8"
@@ -70,12 +70,12 @@ target("InventoryCheck") -- Change this to your plugin name.
set_symbols("debug") set_symbols("debug")
after_build(function (target) after_build(function (target)
local plugin_packer = import("scripts.after_build") local mod_packer = import("scripts.after_build")
local plugin_define = { local mod_define = {
pluginName = target:name(), modName = target:name(),
pluginFile = path.filename(target:targetfile()), modFile = path.filename(target:targetfile()),
} }
plugin_packer.pack_plugin(target,plugin_define) mod_packer.pack_mod(target,mod_define)
end) end)