Compare commits
13 Commits
+22
-21
@@ -7,32 +7,33 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v4
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
|
|
||||||
- uses: actions/checkout@v4
|
- name: Setup XMake
|
||||||
|
uses: xmake-io/github-action-setup-xmake@v1
|
||||||
- uses: xmake-io/github-action-setup-xmake@v1
|
|
||||||
|
|
||||||
- run: |
|
- name: Cache
|
||||||
xmake repo -u
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/AppData/Local/.xmake
|
||||||
|
key: xmake-${{ hashFiles('xmake.lua') }}
|
||||||
|
restore-keys: |
|
||||||
|
xmake-
|
||||||
|
|
||||||
- run: |
|
- name: Update Repo
|
||||||
xmake f -a x64 -m release -p windows -v -y
|
run: xmake repo -u
|
||||||
|
|
||||||
- run: |
|
- name: Update Project
|
||||||
xmake -w -y
|
run: xmake f -a x64 -m release -p windows -v -y
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
- name: Build Project
|
||||||
|
run: xmake -v -y
|
||||||
|
|
||||||
|
- name: Upload Artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
|
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
|
||||||
path: |
|
path: |
|
||||||
bin/DLL/
|
bin/
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: PDB
|
|
||||||
path: |
|
|
||||||
bin/PDB/
|
|
||||||
@@ -7,35 +7,36 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v4
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
|
|
||||||
- uses: actions/checkout@v4
|
- name: Setup XMake
|
||||||
|
uses: xmake-io/github-action-setup-xmake@v1
|
||||||
- uses: xmake-io/github-action-setup-xmake@v1
|
|
||||||
|
|
||||||
- run: |
|
- name: Cache
|
||||||
xmake repo -u
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/AppData/Local/.xmake
|
||||||
|
key: xmake-${{ hashFiles('xmake.lua') }}
|
||||||
|
restore-keys: |
|
||||||
|
xmake-
|
||||||
|
|
||||||
- run: |
|
- name: Update Repo
|
||||||
xmake f -a x64 -m release -p windows -v -y
|
run: xmake repo -u
|
||||||
|
|
||||||
- run: |
|
- name: Update Project
|
||||||
xmake -w -y
|
run: xmake f -a x64 -m release -p windows -v -y
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
- name: Build Project
|
||||||
|
run: xmake -v -y
|
||||||
|
|
||||||
|
- name: Upload Artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
|
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
|
||||||
path: |
|
path: |
|
||||||
bin/DLL/
|
bin/
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: PDB
|
|
||||||
path: |
|
|
||||||
bin/PDB/
|
|
||||||
|
|
||||||
upload-to-release:
|
upload-to-release:
|
||||||
needs:
|
needs:
|
||||||
@@ -44,35 +45,26 @@ jobs:
|
|||||||
contents: write
|
contents: write
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Download Plugin
|
- name: Download Artifact
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
|
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
|
||||||
path: release/Plugin/
|
path: artifact
|
||||||
|
|
||||||
- name: Download PDB
|
- name: Copy Files
|
||||||
uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: PDB
|
|
||||||
path: release/PDB/
|
|
||||||
|
|
||||||
- name: Copy additional files
|
|
||||||
run: |
|
run: |
|
||||||
cp LICENSE README.md release/Plugin/
|
cp LICENSE README.md artifact/
|
||||||
|
|
||||||
- name: Archive release
|
- name: Compress Artifact
|
||||||
run: |
|
run: |
|
||||||
cd release/Plugin
|
|
||||||
zip -r ../${{ github.event.repository.name }}-windows-x64.zip *
|
zip -r ../${{ github.event.repository.name }}-windows-x64.zip *
|
||||||
cd ..
|
working-directory: artifact
|
||||||
|
|
||||||
- name: Create GitHub Release
|
- name: Create Release
|
||||||
id: create_release
|
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
files: |
|
files: |
|
||||||
release/${{ github.event.repository.name }}-windows-x64.zip
|
${{ github.event.repository.name }}-windows-x64.zip
|
||||||
release/PDB/${{ github.event.repository.name }}.pdb
|
|
||||||
|
|||||||
@@ -16,3 +16,4 @@ build/
|
|||||||
/CMakeLists.txt
|
/CMakeLists.txt
|
||||||
/bin
|
/bin
|
||||||
.cache/clangd/index
|
.cache/clangd/index
|
||||||
|
/.idea
|
||||||
|
|||||||
-1
Submodule SDK-GMLIB deleted from 710cc6e4c3
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "${pluginName}",
|
"name": "${modName}",
|
||||||
"entry": "${pluginFile}",
|
"entry": "${modFile}",
|
||||||
"version": "0.12.1",
|
"version": "0.16.1",
|
||||||
"author": "GroupMountain",
|
"author": "GroupMountain",
|
||||||
"description": "Check Player's Inventory",
|
"description": "Check Player's Inventory",
|
||||||
"type": "native",
|
"type": "native",
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-9
@@ -1,18 +1,26 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
|
#include "mc/server/commands/CommandRegistry.h"
|
||||||
|
#include "mc/server/commands/CommandOutput.h"
|
||||||
|
|
||||||
|
#include "ll/api/command/CommandHandle.h"
|
||||||
|
#include "ll/api/service/Bedrock.h"
|
||||||
|
|
||||||
|
#include "gmlib/mc/world/actor/Actor.h"
|
||||||
|
|
||||||
void RegisterCommand() {
|
void RegisterCommand() {
|
||||||
auto& cmd = ll::command::CommandRegistrar::getInstance().getOrCreateCommand(
|
auto& cmd = ll::command::CommandRegistrar::getInstance(false).getOrCreateCommand(
|
||||||
"inventorycheck",
|
"inventorycheck",
|
||||||
tr("command.inventorycheck.desc"),
|
tr("command.inventorycheck.desc"),
|
||||||
CommandPermissionLevel::GameDirectors
|
CommandPermissionLevel::GameDirectors
|
||||||
);
|
);
|
||||||
ll::service::getCommandRegistry()->registerAlias("inventorycheck", "ic");
|
ll::service::getCommandRegistry()->registerAlias("inventorycheck", "ic");
|
||||||
cmd.overload().execute<[&](CommandOrigin const& origin, CommandOutput& output) {
|
cmd.overload().execute([](CommandOrigin const& origin, CommandOutput& output) {
|
||||||
auto entity = (GMLIB_Actor*)origin.getEntity();
|
auto entity = (gmlib::GMActor*)origin.getEntity();
|
||||||
if (entity && entity->isPlayer()) {
|
if (entity && entity->isPlayer()) {
|
||||||
auto pl = (Player*)entity;
|
auto pl = (Player*)entity;
|
||||||
return mainForm(*pl);
|
return mainForm(*pl);
|
||||||
}
|
}
|
||||||
return output.error(tr("command.error.console"));
|
return output.error(tr("command.error.console"));
|
||||||
}>();
|
});
|
||||||
}
|
}
|
||||||
+23
-20
@@ -2,12 +2,21 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "Language.h"
|
#include "Language.h"
|
||||||
|
|
||||||
ll::Logger logger(PLUGIN_NAME);
|
#include "ll/api/Config.h"
|
||||||
|
#include "ll/api/Versions.h"
|
||||||
|
#include "ll/api/mod/RegisterHelper.h"
|
||||||
|
|
||||||
|
#include "gmlib/gm/i18n/LangI18n.h"
|
||||||
|
#include "gmlib/gm/i18n/JsonI18n.h"
|
||||||
|
|
||||||
|
#include "gmlib/gm/data/UserCache.h"
|
||||||
|
#include "ll/api/service/Bedrock.h"
|
||||||
|
#include "ll/api/service/PlayerInfo.h"
|
||||||
|
|
||||||
namespace InventoryCheck {
|
namespace InventoryCheck {
|
||||||
|
|
||||||
std::unique_ptr<Entry>& Entry::getInstance() {
|
Entry& Entry::getInstance() {
|
||||||
static std::unique_ptr<Entry> instance;
|
static Entry instance;
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,34 +29,28 @@ bool Entry::load() {
|
|||||||
mI18n->updateOrCreateLanguage("en_US", en_US);
|
mI18n->updateOrCreateLanguage("en_US", en_US);
|
||||||
mI18n->updateOrCreateLanguage("zh_CN", zh_CN);
|
mI18n->updateOrCreateLanguage("zh_CN", zh_CN);
|
||||||
mI18n->loadAllLanguages();
|
mI18n->loadAllLanguages();
|
||||||
if (GMLIB::Version::getProtocolVersion() != TARGET_PROTOCOL) {
|
|
||||||
logger.error(tr("error.protocolMismatch.info"));
|
if (ll::getNetworkProtocolVersion() != TARGET_PROTOCOL) {
|
||||||
logger.error(
|
getSelf().getLogger().error(tr("error.protocolMismatch.info"));
|
||||||
tr("error.protocolMismatch.version",
|
getSelf().getLogger().error(tr("error.protocolMismatch.version", {std::to_string(ll::getNetworkProtocolVersion()), std::to_string(TARGET_PROTOCOL)}));
|
||||||
{std::to_string(TARGET_PROTOCOL), std::to_string(GMLIB::Version::getProtocolVersion())})
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
bool Entry::enable() {
|
bool Entry::enable() {
|
||||||
RegisterCommand();
|
RegisterCommand();
|
||||||
logger.info("InventoryCheck Loaded!");
|
|
||||||
logger.info("Author: GroupMountain");
|
|
||||||
logger.info("Repository: https://github.com/GroupMountain/InventoryCheck");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Entry::disable() {
|
bool Entry::disable() {
|
||||||
// Code for disabling the plugin goes here.
|
// Code for disabling the mod goes here.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Entry::unload() {
|
|
||||||
getInstance().reset();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Config& Entry::getConfig() { return mConfig.value(); }
|
Config& Entry::getConfig() { return mConfig.value(); }
|
||||||
|
|
||||||
@@ -55,8 +58,8 @@ 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);
|
||||||
}
|
}
|
||||||
+18
-10
@@ -1,38 +1,46 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include <span>
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
#include "gmlib/gm/i18n/LangI18n.h"
|
||||||
|
|
||||||
|
#include "gmlib/gm/data/UserCache.h"
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace InventoryCheck {
|
namespace InventoryCheck {
|
||||||
|
|
||||||
using namespace GMLIB::Files::I18n;
|
using namespace gmlib::i18n;
|
||||||
|
|
||||||
class Entry {
|
class Entry {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static std::unique_ptr<Entry>& getInstance();
|
static Entry& getInstance();
|
||||||
|
|
||||||
Entry(ll::plugin::NativePlugin& self) : mSelf(self) {}
|
Entry() : mSelf((*ll::mod::NativeMod::current())) {}
|
||||||
|
|
||||||
[[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();
|
|
||||||
|
|
||||||
Config& getConfig();
|
Config& getConfig();
|
||||||
|
|
||||||
LangI18n& getI18n();
|
LangI18n& getI18n();
|
||||||
|
|
||||||
|
std::vector<gmlib::UserCache::UserCacheEntry> userCache;
|
||||||
|
|
||||||
|
|
||||||
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;
|
||||||
};
|
};
|
||||||
|
|||||||
+9
-4
@@ -1,10 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <include_all.h>
|
|
||||||
|
|
||||||
#define PLUGIN_NAME "InventoryCheck"
|
#include <span>
|
||||||
#define TARGET_PROTOCOL 671
|
|
||||||
|
#include "mc/world/actor/player/Player.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#define MOD_NAME "InventoryCheck"
|
||||||
|
#define TARGET_PROTOCOL 944
|
||||||
|
|
||||||
extern ll::Logger logger;
|
|
||||||
|
|
||||||
extern std::string tr(std::string const& key, std::vector<std::string> const& data = {});
|
extern std::string tr(std::string const& key, std::vector<std::string> const& data = {});
|
||||||
|
|
||||||
|
|||||||
+115
-33
@@ -1,42 +1,92 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
#include "Entry.h"
|
||||||
|
|
||||||
bool saveInventory(Player& player) {
|
#include <filesystem>
|
||||||
auto& pl = static_cast<GMLIB_Player&>(player);
|
#include <unordered_map>
|
||||||
|
|
||||||
|
#include "mc/world/level/Level.h"
|
||||||
|
#include "mc/world/level/storage/DBStorage.h"
|
||||||
|
#include "mc/world/actor/player/PlayerListEntry.h"
|
||||||
|
|
||||||
|
#include "ll/api/service/Bedrock.h"
|
||||||
|
#include "ll/api/io/FileUtils.h"
|
||||||
|
|
||||||
|
#include "ll/api/form/ModalForm.h"
|
||||||
|
#include "ll/api/form/SimpleForm.h"
|
||||||
|
#include "ll/api/form/CustomForm.h"
|
||||||
|
|
||||||
|
#include "gmlib/mc/world/actor/OfflinePlayer.h"
|
||||||
|
|
||||||
|
#include <ll/api/service/PlayerInfo.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief the keys of the playr nbt that would be copied or written
|
||||||
|
*/
|
||||||
|
static constexpr const char* InvKey[] = {
|
||||||
|
"Armor","Offhand","Inventory","EnderChestInventory"
|
||||||
|
};
|
||||||
|
void saveInventory(Player& player) {
|
||||||
|
auto& pl = static_cast<gmlib::GMPlayer&>(player);
|
||||||
auto uuid = pl.getUuid();
|
auto uuid = pl.getUuid();
|
||||||
ll::file_utils::writeFile(
|
ll::file_utils::writeFile(
|
||||||
"./plugins/InventoryCheck/save/" + uuid.asString() + ".dat",
|
"./plugins/InventoryCheck/save/" + uuid.asString() + ".dat",
|
||||||
pl.getNbt()->toBinaryNbt(),
|
pl.getNbt()->toBinaryNbt(),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
return false;
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief set the playerNBT easily and validly
|
||||||
|
*/
|
||||||
|
bool validSetNbt(mce::UUID uuid, const std::unique_ptr<CompoundTag>& nbt) {
|
||||||
|
if (!nbt) return false;
|
||||||
|
|
||||||
|
if (auto* p = ll::service::getLevel()->getPlayer(uuid)) {
|
||||||
|
auto& pl = static_cast<gmlib::GMPlayer&>(*p);
|
||||||
|
pl.setNbt(*nbt);
|
||||||
|
pl.refreshInventory();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto db = ll::service::getDBStorage();
|
||||||
|
if (!db) return false;
|
||||||
|
|
||||||
|
auto tag = db->getCompoundTag("player_" + uuid.asString(), DBHelpers::Category::Player);
|
||||||
|
|
||||||
|
if (!tag || !tag->contains("ServerId"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
gmlib::OfflinePlayer(uuid, tag->at("ServerId")).setNbt(*nbt);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool resumeInventory(Player& player) {
|
bool resumeInventory(Player& player) {
|
||||||
auto& pl = static_cast<GMLIB_Player&>(player);
|
auto& pl = static_cast<gmlib::GMPlayer&>(player);
|
||||||
auto uuid = pl.getUuid();
|
auto uuid = pl.getUuid();
|
||||||
std::string path = "./plugins/InventoryCheck/save/" + uuid.asString() + ".dat";
|
std::string path = "./plugins/InventoryCheck/save/" + uuid.asString() + ".dat";
|
||||||
if (auto binaryData = ll::file_utils::readFile(path, true)) {
|
if (auto binaryData = ll::file_utils::readFile(path, true)) {
|
||||||
std::filesystem::remove(path);
|
std::filesystem::remove(path);
|
||||||
if (auto nbt = CompoundTag::fromBinaryNbt(binaryData.value())) {
|
if (auto nbt = CompoundTag::fromBinaryNbt(binaryData.value())) {
|
||||||
GMLIB_Player::setPlayerNbtTags(uuid, *nbt, {"Offhand", "Inventory", "Armor", "EnderChestInventory"});
|
auto playerNbt=pl.getNbt();
|
||||||
|
for (auto key : InvKey)
|
||||||
|
playerNbt->mTags[key] = nbt->at(key);
|
||||||
|
pl.setNbt(*playerNbt);
|
||||||
|
pl.refreshInventory();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void mainForm(Player& pl) {
|
void mainForm(Player& pl) {
|
||||||
auto fm = ll::form::SimpleForm(tr("form.main.title"), tr("form.main.content"));
|
auto fm = ll::form::SimpleForm(tr("form.main.title"), tr("form.main.content"));
|
||||||
fm.appendButton(tr("form.main.checkOnline"), [](Player& pl) { return checkOnlineForm(pl); });
|
fm.appendButton(tr("form.main.checkOnline"), [](Player& pl) { return checkOnlineForm(pl); });
|
||||||
fm.appendButton(tr("form.main.checkAll"), [](Player& pl) { return checkAllForm(pl); });
|
fm.appendButton(tr("form.main.checkAll"), [](Player& pl) { return checkAllForm(pl); });
|
||||||
fm.appendButton(tr("form.main.searchPlayer"), [](Player& pl) { return searchPlayerForm(pl); });
|
fm.appendButton(tr("form.main.searchPlayer"), [](Player& pl) { return searchPlayerForm(pl); });
|
||||||
fm.appendButton(tr("form.main.resumeInventory"), [](Player& pl) {
|
fm.appendButton(tr("form.main.resumeInventory"), [](Player& pl) {
|
||||||
auto res = resumeInventory(pl);
|
pl.sendMessage(resumeInventory(pl)
|
||||||
if (res) {
|
? tr("resumeInventory.success")
|
||||||
return pl.sendMessage(tr("resumeInventory.success"));
|
: tr("resumeInventory.failed"));
|
||||||
}
|
|
||||||
return pl.sendMessage(tr("resumeInventory.failed"));
|
|
||||||
});
|
});
|
||||||
fm.sendTo(pl);
|
fm.sendTo(pl);
|
||||||
}
|
}
|
||||||
@@ -44,7 +94,7 @@ void mainForm(Player& pl) {
|
|||||||
void checkOnlineForm(Player& pl) {
|
void checkOnlineForm(Player& pl) {
|
||||||
auto fm = ll::form::SimpleForm(tr("form.checkList.title"), tr("form.checkList.content"));
|
auto fm = ll::form::SimpleForm(tr("form.checkList.title"), tr("form.checkList.content"));
|
||||||
std::unordered_map<mce::UUID, std::string> onlineList;
|
std::unordered_map<mce::UUID, std::string> onlineList;
|
||||||
GMLIB_Level::getLevel()->forEachPlayer([&onlineList](Player& pl) -> bool {
|
ll::service::getLevel()->forEachPlayer([&onlineList](Player& pl) -> bool {
|
||||||
if (!pl.isSimulated()) {
|
if (!pl.isSimulated()) {
|
||||||
onlineList[pl.getUuid()] = pl.getRealName();
|
onlineList[pl.getUuid()] = pl.getRealName();
|
||||||
}
|
}
|
||||||
@@ -66,25 +116,31 @@ void checkOnlineForm(Player& pl) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string getNameFormUuid(mce::UUID const& uuid) {
|
std::string getNameFormUuid(mce::UUID const& uuid) {
|
||||||
auto player = GMLIB_Level::getLevel()->getPlayer(uuid);
|
auto player = ll::service::getLevel()->getPlayer(uuid);
|
||||||
std::string name;
|
std::string name;
|
||||||
if (player) {
|
if (player) {
|
||||||
name = player->getRealName();
|
name = player->getRealName();
|
||||||
} else {
|
} else {
|
||||||
auto cache = GMLIB::UserCache::getNameByUuid(uuid);
|
auto cache = ll::service::PlayerInfo::getInstance().fromUuid(uuid);
|
||||||
name = cache ? cache.value() : uuid.asString();
|
name = cache ? cache->name : uuid.asString();
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unordered_map<mce::UUID, std::string> generateUuidMap() {
|
std::unordered_map<mce::UUID, std::string> generateUuidMap() {
|
||||||
auto allUuids = GMLIB_Player::getAllUuids();
|
std::vector<mce::UUID> allUuids;
|
||||||
std::unordered_map<mce::UUID, std::string> allList;
|
for (const auto& entry : ll::service::PlayerInfo::getInstance().entries()) {
|
||||||
for (auto& uuid : allUuids) {
|
allUuids.push_back(entry.uuid);
|
||||||
auto name = getNameFormUuid(uuid);
|
}
|
||||||
allList[uuid] = name;
|
for (const auto& player : ll::service::getLevel()->getPlayerList()) {
|
||||||
}
|
allUuids.push_back(player.first);
|
||||||
return std::move(allList);
|
}
|
||||||
|
std::unordered_map<mce::UUID, std::string> allList;
|
||||||
|
for (auto& uuid : allUuids) {
|
||||||
|
auto name = getNameFormUuid(uuid);
|
||||||
|
allList[uuid] = name;
|
||||||
|
}
|
||||||
|
return std::move(allList);
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkAllForm(Player& pl) {
|
void checkAllForm(Player& pl) {
|
||||||
@@ -175,19 +231,41 @@ void searchNotFoundForm(Player& pl, std::string const& name) {
|
|||||||
return mainForm(pl);
|
return mainForm(pl);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @brief get the playerNBT conveninetly
|
||||||
|
*/
|
||||||
|
std::unique_ptr<CompoundTag> getNBTptr(mce::UUID uuid) {
|
||||||
|
if (auto player = ll::service::getLevel()->getPlayer(uuid))
|
||||||
|
return static_cast<gmlib::GMPlayer&>(*player).getNbt();
|
||||||
|
auto db = ll::service::getDBStorage();
|
||||||
|
if (!db) return nullptr;
|
||||||
|
auto playerTag = db->getCompoundTag(
|
||||||
|
"player_" + uuid.asString(),
|
||||||
|
DBHelpers::Category::Player
|
||||||
|
);
|
||||||
|
if (!playerTag||!playerTag->contains("ServerId")) return nullptr;
|
||||||
|
auto nbt =gmlib::OfflinePlayer(uuid, playerTag->at("ServerId")).getNbt();
|
||||||
|
return nbt ? std::make_unique<CompoundTag>(*nbt) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void checkPlayerForm(Player& pl, mce::UUID const& uuid) {
|
void checkPlayerForm(Player& pl, mce::UUID const& uuid) {
|
||||||
std::string name = getNameFormUuid(uuid);
|
std::string name = getNameFormUuid(uuid);
|
||||||
auto fm = ll::form::SimpleForm(tr("form.checkPlayer.title"), tr("form.checkPlayer.content", {name}));
|
auto fm = ll::form::SimpleForm(tr("form.checkPlayer.title"), tr("form.checkPlayer.content", {name}));
|
||||||
fm.appendButton(tr("form.checkPlayer.copyInventory"), [uuid, name](Player& pl) {
|
fm.appendButton(tr("form.checkPlayer.copyInventory"), [uuid, name](Player& pl) {
|
||||||
saveInventory(pl);
|
saveInventory(pl);
|
||||||
auto nbt = GMLIB_Player::getPlayerNbt(uuid);
|
auto nbt =getNBTptr(uuid);
|
||||||
if (!nbt) {
|
auto playerNbt=getNBTptr(pl.getUuid());
|
||||||
|
if ((!nbt)||(!playerNbt)) {
|
||||||
|
|
||||||
return pl.sendMessage(tr("checkPlayer.copyInventory.failed", {name}));
|
return pl.sendMessage(tr("checkPlayer.copyInventory.failed", {name}));
|
||||||
}
|
}
|
||||||
auto& self = static_cast<GMLIB_Player&>(pl);
|
for (auto key : InvKey)
|
||||||
GMLIB_Player::setPlayerNbtTags(pl.getUuid(), *nbt, {"Offhand", "Inventory", "Armor", "EnderChestInventory"});
|
playerNbt->mTags[key] = nbt->at(key);
|
||||||
return pl.sendMessage(tr("checkPlayer.copyInventory.success", {name}));
|
bool success= validSetNbt(pl.getUuid(), std::move(playerNbt));
|
||||||
|
pl.refreshInventory();
|
||||||
|
return pl.sendMessage(tr(success ? "checkPlayer.copyInventory.success" :
|
||||||
|
"checkPlayer.copyInventory.setFailed",{name}));
|
||||||
|
|
||||||
});
|
});
|
||||||
fm.appendButton(tr("form.checkPlayer.writeInventory"), [uuid, name](Player& pl) {
|
fm.appendButton(tr("form.checkPlayer.writeInventory"), [uuid, name](Player& pl) {
|
||||||
return confirmWriteForm(pl, uuid, name);
|
return confirmWriteForm(pl, uuid, name);
|
||||||
@@ -226,14 +304,18 @@ void confirmWriteForm(Player& pl, mce::UUID const& uuid, std::string const& name
|
|||||||
);
|
);
|
||||||
fm.sendTo(pl, [uuid, name](Player& pl, ll::form::ModalFormResult result, ll::form::FormCancelReason) {
|
fm.sendTo(pl, [uuid, name](Player& pl, ll::form::ModalFormResult result, ll::form::FormCancelReason) {
|
||||||
if (result == ll::form::ModalFormSelectedButton::Upper) {
|
if (result == ll::form::ModalFormSelectedButton::Upper) {
|
||||||
auto& self = static_cast<GMLIB_Player&>(pl);
|
auto& self = static_cast<gmlib::GMPlayer&>(pl);
|
||||||
auto nbt = self.getNbt();
|
auto nbt = self.getNbt();
|
||||||
auto targetNbt = GMLIB_Player::getPlayerNbt(uuid);
|
auto targetNbt = getNBTptr(uuid);
|
||||||
if (!targetNbt) {
|
if (!targetNbt) {
|
||||||
return pl.sendMessage(tr("checkPlayer.writeInventory.failed", {name}));
|
return pl.sendMessage(tr("checkPlayer.writeInventory.failed", {name}));
|
||||||
}
|
}
|
||||||
GMLIB_Player::setPlayerNbtTags(uuid, *nbt, {"Offhand", "Inventory", "Armor", "EnderChestInventory"});
|
for (auto key : InvKey)
|
||||||
return pl.sendMessage(tr("checkPlayer.writeInventory.success", {name}));
|
targetNbt->mTags[key] = nbt->at(key);
|
||||||
|
bool success= validSetNbt(uuid, std::move(targetNbt));
|
||||||
|
pl.refreshInventory();
|
||||||
|
return pl.sendMessage(tr(success ? "checkPlayer.writeInventory.success" :
|
||||||
|
"checkPlayer.writeInventory.setFailed",{name}));
|
||||||
}
|
}
|
||||||
return checkPlayerForm(pl, uuid);
|
return checkPlayerForm(pl, uuid);
|
||||||
});
|
});
|
||||||
@@ -248,10 +330,10 @@ void confirmDeleteForm(Player& pl, mce::UUID const& uuid, std::string const& nam
|
|||||||
);
|
);
|
||||||
fm.sendTo(pl, [uuid, name](Player& pl, ll::form::ModalFormResult result, ll::form::FormCancelReason) {
|
fm.sendTo(pl, [uuid, name](Player& pl, ll::form::ModalFormResult result, ll::form::FormCancelReason) {
|
||||||
if (result == ll::form::ModalFormSelectedButton::Upper) {
|
if (result == ll::form::ModalFormSelectedButton::Upper) {
|
||||||
if (auto player = GMLIB_Level::getLevel()->getPlayer(uuid)) {
|
if (auto player = ll::service::getLevel()->getPlayer(uuid)) {
|
||||||
return deleteFailedForm(pl, uuid, name);
|
return deleteFailedForm(pl, uuid, name);
|
||||||
}
|
}
|
||||||
GMLIB_Player::deletePlayer(uuid);
|
gmlib::OfflinePlayer::deletePlayerNbt(uuid);
|
||||||
return pl.sendMessage(tr("checkPlayer.deletePlayer.success", {name}));
|
return pl.sendMessage(tr("checkPlayer.deletePlayer.success", {name}));
|
||||||
}
|
}
|
||||||
return checkPlayerForm(pl, uuid);
|
return checkPlayerForm(pl, uuid);
|
||||||
|
|||||||
+5
-1
@@ -33,12 +33,14 @@ std::string en_US = R"(
|
|||||||
command.inventorycheck.desc=Check player inventory.
|
command.inventorycheck.desc=Check player inventory.
|
||||||
checkPlayer.copyInventory.success=Successfully copied player %s's inventory to yours!
|
checkPlayer.copyInventory.success=Successfully copied player %s's inventory to yours!
|
||||||
checkPlayer.copyInventory.failed=It is not possible to copy player %s's backpack to yours! \nPlayer %s doesn't have any data!
|
checkPlayer.copyInventory.failed=It is not possible to copy player %s's backpack to yours! \nPlayer %s doesn't have any data!
|
||||||
|
checkPlayer.copyInventory.setFailed=CANNOT to copy player %s's backpack to yours!
|
||||||
form.confirmWrite.title=Confirm Action
|
form.confirmWrite.title=Confirm Action
|
||||||
form.confirmWrite.content=Are you sure you want to cover player %s's backpack with your backpack? \n\nAttention! \nThis operation is irreversible!
|
form.confirmWrite.content=Are you sure you want to cover player %s's backpack with your backpack? \n\nAttention! \nThis operation is irreversible!
|
||||||
form.confirmAction=Confirm
|
form.confirmAction=Confirm
|
||||||
form.cancelAction=Cancel
|
form.cancelAction=Cancel
|
||||||
checkPlayer.writeInventory.success=Successfully overwrote player %s's backpack!
|
checkPlayer.writeInventory.success=Successfully overwrote player %s's backpack!
|
||||||
checkPlayer.writeInventory.failed=Cannot cover player %s's backpack! nPlayer %s doesn't have any data!
|
checkPlayer.writeInventory.failed=Cannot cover player %s's backpack! \nPlayer %s doesn't have any data!
|
||||||
|
checkPlayer.writeInventory.setFailed=Cannot cover player %s's backpack!
|
||||||
form.confirmDelete.title=Confirm Delete Data
|
form.confirmDelete.title=Confirm Delete Data
|
||||||
form.confirmDelete.content=Are you sure you want to delete all of player %s's data? \nThis contains all the player's data in the save! \nIt's not just a backpack! \n\nAttention! nThis operation is irreversible! \nPlease proceed with caution
|
form.confirmDelete.content=Are you sure you want to delete all of player %s's data? \nThis contains all the player's data in the save! \nIt's not just a backpack! \n\nAttention! nThis operation is irreversible! \nPlease proceed with caution
|
||||||
checkPlayer.deletePlayer.success=Successfully deleted player from storage!
|
checkPlayer.deletePlayer.success=Successfully deleted player from storage!
|
||||||
@@ -85,12 +87,14 @@ std::string zh_CN = R"(
|
|||||||
command.inventorycheck.desc=查询玩家背包
|
command.inventorycheck.desc=查询玩家背包
|
||||||
checkPlayer.copyInventory.success=已成功将玩家 %s 的背包复制到你的背包!
|
checkPlayer.copyInventory.success=已成功将玩家 %s 的背包复制到你的背包!
|
||||||
checkPlayer.copyInventory.failed=无法将玩家 %s 的背包复制到你的背包!\n玩家 %s 没有任何数据!
|
checkPlayer.copyInventory.failed=无法将玩家 %s 的背包复制到你的背包!\n玩家 %s 没有任何数据!
|
||||||
|
checkPlayer.copyInventory.setFailed=无法将玩家 %s 的背包复制到你的背包!
|
||||||
form.confirmWrite.title=确认覆盖背包
|
form.confirmWrite.title=确认覆盖背包
|
||||||
form.confirmWrite.content=你确定要用你的背包覆盖玩家 %s 的背包吗?\n\n注意!\n此操作不可逆!
|
form.confirmWrite.content=你确定要用你的背包覆盖玩家 %s 的背包吗?\n\n注意!\n此操作不可逆!
|
||||||
form.confirmAction=确认操作
|
form.confirmAction=确认操作
|
||||||
form.cancelAction=我再想想
|
form.cancelAction=我再想想
|
||||||
checkPlayer.writeInventory.success=已成功覆盖玩家 %s 的背包!
|
checkPlayer.writeInventory.success=已成功覆盖玩家 %s 的背包!
|
||||||
checkPlayer.writeInventory.failed=无法覆盖玩家 %s 的背包!\n玩家 %s 没有任何数据!
|
checkPlayer.writeInventory.failed=无法覆盖玩家 %s 的背包!\n玩家 %s 没有任何数据!
|
||||||
|
checkPlayer.writeInventory.setFailed=无法覆盖玩家 %s 的背包!
|
||||||
form.confirmDelete.title=确认删除数据
|
form.confirmDelete.title=确认删除数据
|
||||||
form.confirmDelete.content=你确定要删除玩家 %s 的全部数据吗?\n这包含玩家在存档的全部数据!\n不仅仅是背包!\n\n注意!\n此操作不可逆!\n请谨慎操作
|
form.confirmDelete.content=你确定要删除玩家 %s 的全部数据吗?\n这包含玩家在存档的全部数据!\n不仅仅是背包!\n\n注意!\n此操作不可逆!\n请谨慎操作
|
||||||
checkPlayer.deletePlayer.success=已成功将玩家 %s 从存档删除!
|
checkPlayer.deletePlayer.success=已成功将玩家 %s 从存档删除!
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
+30
-16
@@ -1,29 +1,43 @@
|
|||||||
{
|
{
|
||||||
"format_version": 2,
|
"format_version": 3,
|
||||||
|
"format_uuid": "289f771f-2c9a-4d73-9f3f-8492495a924d",
|
||||||
"tooth": "github.com/GroupMountain/InventoryCheck",
|
"tooth": "github.com/GroupMountain/InventoryCheck",
|
||||||
"version": "0.12.1",
|
"version": "0.16.0",
|
||||||
"info": {
|
"info": {
|
||||||
"name": "InventoryCheck",
|
"name": "InventoryCheck",
|
||||||
"description": "Check Player's Inventory",
|
"description": "Check Player's Inventory",
|
||||||
"author": "GroupMountain",
|
"author": "GroupMountain",
|
||||||
"source": "github.com/GroupMountain/InventoryCheck",
|
"source": "github.com/GroupMountain/InventoryCheck",
|
||||||
"tags": [
|
"tags": [
|
||||||
"levilamina",
|
"platform:levilamina",
|
||||||
"inventory",
|
"type:mod",
|
||||||
"checkbag",
|
"checkbag",
|
||||||
"gmlib"
|
"gmlib"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"asset_url": "https://github.com/GroupMountain/InventoryCheck/releases/download/v0.12.1/InventoryCheck-windows-x64.zip",
|
|
||||||
"dependencies": {
|
"variants": [
|
||||||
"github.com/GroupMountain/GMLIB": ">=0.12.6"
|
{
|
||||||
},
|
"platform": "win-x64",
|
||||||
"files": {
|
"dependencies": {
|
||||||
"place": [
|
"github.com/GroupMountain/GMLIB-Release": ">=26.10.0"
|
||||||
{
|
},
|
||||||
"src": "InventoryCheck/*",
|
"assets": [
|
||||||
"dest": "plugins/InventoryCheck"
|
{
|
||||||
}
|
"type": "self",
|
||||||
]
|
"urls": [],
|
||||||
}
|
"placements": [
|
||||||
|
{
|
||||||
|
"type": "dir",
|
||||||
|
"src": "InventoryCheck/*",
|
||||||
|
"dest": "plugins/InventoryCheck"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"remove_files": [
|
||||||
|
"plugins/InventoryCheck"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
@@ -1,82 +1,26 @@
|
|||||||
add_rules("mode.debug", "mode.release")
|
add_rules("mode.debug", "mode.release")
|
||||||
|
|
||||||
add_repositories("liteldev-repo https://github.com/LiteLDev/xmake-repo.git")
|
add_repositories("liteldev-repo https://github.com/LiteLDev/xmake-repo.git")
|
||||||
|
add_repositories("groupmountain-repo https://github.com/GroupMountain/xmake-repo.git")
|
||||||
|
add_requires("levilamina 26.10.5", {configs = {target_type = "server"}})
|
||||||
|
add_requires("levibuildscript")
|
||||||
|
|
||||||
|
add_requires("gmlib 26.10.0")
|
||||||
|
|
||||||
if not has_config("vs_runtime") then
|
if not has_config("vs_runtime") then
|
||||||
set_runtimes("MD")
|
set_runtimes("MD")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Option 1: Use the latest version of LeviLamina released on GitHub.
|
target("InventoryCheck")
|
||||||
add_requires("levilamina")
|
add_rules("@levibuildscript/linkrule")
|
||||||
|
add_rules("@levibuildscript/modpacker")
|
||||||
-- Option 2: Use a specific version of LeviLamina released on GitHub.
|
add_cxflags( "/EHa", "/utf-8", "/W4", "/w44265", "/w44289", "/w44296", "/w45263", "/w44738", "/w45204")
|
||||||
-- add_requires("levilamina x.x.x")
|
add_defines("NOMINMAX", "UNICODE")
|
||||||
|
add_packages("levilamina","gmlib")
|
||||||
-- Option 3: Use the latest commit of LeviLamina on GitHub.
|
set_exceptions("none") -- To avoid conflicts with /EHa.
|
||||||
-- -- Here, "develop" is the branch name. You can change it to any branch name you want.
|
|
||||||
-- add_requires("levilamina develop")
|
|
||||||
-- -- You can also use debug build of LeviLamina.
|
|
||||||
-- -- add_requires("levilamina develop", {debug = true})
|
|
||||||
-- package("levilamina")
|
|
||||||
-- add_urls("https://github.com/LiteLDev/LeviLamina.git")
|
|
||||||
|
|
||||||
-- add_deps("ctre 3.8.1")
|
|
||||||
-- add_deps("entt 3.12.2")
|
|
||||||
-- add_deps("fmt 10.1.1")
|
|
||||||
-- add_deps("gsl 4.0.0")
|
|
||||||
-- add_deps("leveldb 1.23")
|
|
||||||
-- add_deps("magic_enum 0.9.0")
|
|
||||||
-- add_deps("nlohmann_json 3.11.2")
|
|
||||||
-- add_deps("rapidjson 1.1.0")
|
|
||||||
-- add_deps("pcg_cpp 1.0.0")
|
|
||||||
-- add_deps("pfr 2.1.1")
|
|
||||||
-- add_deps("preloader 1.4.0")
|
|
||||||
-- add_deps("symbolprovider 1.1.0")
|
|
||||||
|
|
||||||
-- -- You may need to change this to the target BDS version of your choice.
|
|
||||||
-- add_deps("bdslibrary 1.20.50.03")
|
|
||||||
|
|
||||||
-- on_install(function (package)
|
|
||||||
-- import("package.tools.xmake").install(package)
|
|
||||||
-- end)
|
|
||||||
|
|
||||||
target("InventoryCheck") -- Change this to your plugin name.
|
|
||||||
add_cxflags(
|
|
||||||
"/EHa",
|
|
||||||
"/utf-8"
|
|
||||||
)
|
|
||||||
add_defines(
|
|
||||||
"NOMINMAX",
|
|
||||||
"UNICODE"
|
|
||||||
)
|
|
||||||
add_files(
|
|
||||||
"src/**.cpp"
|
|
||||||
)
|
|
||||||
add_links(
|
|
||||||
"SDK-GMLIB/Lib/GMLIB"
|
|
||||||
)
|
|
||||||
add_includedirs(
|
|
||||||
"SDK-GMLIB",
|
|
||||||
"src"
|
|
||||||
)
|
|
||||||
add_packages(
|
|
||||||
"levilamina"
|
|
||||||
)
|
|
||||||
add_shflags(
|
|
||||||
"/DELAYLOAD:bedrock_server.dll" -- Magic to import symbols from BDS
|
|
||||||
)
|
|
||||||
set_exceptions("none") -- To avoid conflicts with /EHa
|
|
||||||
set_kind("shared")
|
set_kind("shared")
|
||||||
set_languages("c++23")
|
set_languages("c++23")
|
||||||
set_symbols("debug")
|
set_symbols("debug")
|
||||||
|
add_headerfiles("src/**.h")
|
||||||
after_build(function (target)
|
add_files("src/**.cpp")
|
||||||
local plugin_packer = import("scripts.after_build")
|
add_includedirs("src")
|
||||||
|
|
||||||
local plugin_define = {
|
|
||||||
pluginName = target:name(),
|
|
||||||
pluginFile = path.filename(target:targetfile()),
|
|
||||||
}
|
|
||||||
|
|
||||||
plugin_packer.pack_plugin(target,plugin_define)
|
|
||||||
end)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user