Compare commits
6 Commits
@@ -15,7 +15,8 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- uses: xmake-io/github-action-setup-xmake@v1
|
- uses: xmake-io/github-action-setup-xmake@v1
|
||||||
|
with:
|
||||||
|
xmake-version: branch@master
|
||||||
- run: |
|
- run: |
|
||||||
xmake repo -u
|
xmake repo -u
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- uses: xmake-io/github-action-setup-xmake@v1
|
- uses: xmake-io/github-action-setup-xmake@v1
|
||||||
|
with:
|
||||||
|
xmake-version: branch@master
|
||||||
- run: |
|
- run: |
|
||||||
xmake repo -u
|
xmake repo -u
|
||||||
|
|
||||||
@@ -47,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
|
||||||
@@ -61,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 ..
|
||||||
|
|
||||||
|
|||||||
@@ -15,3 +15,4 @@ build/
|
|||||||
/.xmake
|
/.xmake
|
||||||
/CMakeLists.txt
|
/CMakeLists.txt
|
||||||
/bin
|
/bin
|
||||||
|
.cache/clangd/index
|
||||||
|
|||||||
-1
Submodule SDK-GMLIB deleted from cecc827900
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "${pluginName}",
|
"name": "${modName}",
|
||||||
"entry": "${pluginFile}",
|
"entry": "${modFile}",
|
||||||
"version": "0.11.0",
|
"version": "0.13.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
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-3
@@ -1,6 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
std::string defaultConfig = R"({
|
struct Config {
|
||||||
"language": "en_US"
|
int version = 1;
|
||||||
})";
|
|
||||||
|
std::string language = "en_US";
|
||||||
|
};
|
||||||
+35
-40
@@ -1,66 +1,61 @@
|
|||||||
#include "Entry.h"
|
#include "Entry.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
#include "Language.h"
|
||||||
|
|
||||||
ll::Logger logger(PLUGIN_NAME);
|
ll::Logger logger(MOD_NAME);
|
||||||
|
|
||||||
namespace InventoryCheck {
|
namespace InventoryCheck {
|
||||||
|
|
||||||
namespace {
|
std::unique_ptr<Entry>& Entry::getInstance() {
|
||||||
|
static std::unique_ptr<Entry> instance;
|
||||||
std::unique_ptr<std::reference_wrapper<ll::plugin::NativePlugin>>
|
return instance;
|
||||||
selfPluginInstance; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
|
||||||
|
|
||||||
auto disable(ll::plugin::NativePlugin& /*self*/) -> bool { return true; }
|
|
||||||
|
|
||||||
auto enable(ll::plugin::NativePlugin& /*self*/) -> bool {
|
|
||||||
RegisterCommand();
|
|
||||||
listenEvent();
|
|
||||||
logger.info("InventoryCheck Loaded!");
|
|
||||||
logger.info("Author: GroupMountain");
|
|
||||||
logger.info("Repository: https://github.com/GroupMountain/InventoryCheck");
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto load(ll::plugin::NativePlugin& self) -> bool {
|
bool Entry::load() {
|
||||||
selfPluginInstance = std::make_unique<std::reference_wrapper<ll::plugin::NativePlugin>>(self);
|
mConfig.emplace();
|
||||||
initPlugin();
|
if (!ll::config::loadConfig(*mConfig, getSelf().getConfigDir() / u8"config.json")) {
|
||||||
|
ll::config::saveConfig(*mConfig, getSelf().getConfigDir() / u8"config.json");
|
||||||
|
}
|
||||||
|
mI18n.emplace(getSelf().getLangDir(), mConfig->language);
|
||||||
|
mI18n->updateOrCreateLanguage("en_US", en_US);
|
||||||
|
mI18n->updateOrCreateLanguage("zh_CN", zh_CN);
|
||||||
|
mI18n->loadAllLanguages();
|
||||||
if (GMLIB::Version::getProtocolVersion() != TARGET_PROTOCOL) {
|
if (GMLIB::Version::getProtocolVersion() != TARGET_PROTOCOL) {
|
||||||
logger.error(tr("error.protocolMismatch.info"));
|
logger.error(tr("error.protocolMismatch.info"));
|
||||||
logger.error(
|
logger.error(
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
initPlayerDataCache();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto unload(ll::plugin::NativePlugin& self) -> bool {
|
bool Entry::enable() {
|
||||||
selfPluginInstance.reset();
|
RegisterCommand();
|
||||||
|
logger.info("InventoryCheck Loaded!");
|
||||||
|
logger.info("Author: GroupMountain");
|
||||||
|
logger.info("Repository: https://github.com/GroupMountain/InventoryCheck");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
bool Entry::disable() {
|
||||||
|
// Code for disabling the mod goes here.
|
||||||
auto getSelfPluginInstance() -> ll::plugin::NativePlugin& {
|
return true;
|
||||||
if (!selfPluginInstance) {
|
|
||||||
throw std::runtime_error("selfPluginInstance is null");
|
|
||||||
}
|
|
||||||
return *selfPluginInstance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Entry::unload() {
|
||||||
|
getInstance().reset();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Config& Entry::getConfig() { return mConfig.value(); }
|
||||||
|
|
||||||
|
LangI18n& Entry::getI18n() { return mI18n.value(); }
|
||||||
|
|
||||||
} // namespace InventoryCheck
|
} // namespace InventoryCheck
|
||||||
|
|
||||||
extern "C" {
|
LL_REGISTER_MOD(InventoryCheck::Entry, InventoryCheck::Entry::getInstance());
|
||||||
_declspec(dllexport) auto ll_plugin_disable(ll::plugin::NativePlugin& self) -> bool {
|
|
||||||
return InventoryCheck::disable(self);
|
std::string tr(std::string const& key, std::vector<std::string> const& data) {
|
||||||
}
|
return InventoryCheck::Entry::getInstance()->getI18n().get(key, data);
|
||||||
_declspec(dllexport) auto ll_plugin_enable(ll::plugin::NativePlugin& self) -> bool {
|
|
||||||
return InventoryCheck::enable(self);
|
|
||||||
}
|
|
||||||
_declspec(dllexport) auto ll_plugin_load(ll::plugin::NativePlugin& self) -> bool { return InventoryCheck::load(self); }
|
|
||||||
_declspec(dllexport) auto ll_plugin_unload(ll::plugin::NativePlugin& self) -> bool {
|
|
||||||
return InventoryCheck::unload(self);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+35
-2
@@ -1,9 +1,42 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include <span>
|
||||||
|
|
||||||
#include <ll/api/plugin/NativePlugin.h>
|
#include "Config.h"
|
||||||
|
#include "Global.h"
|
||||||
|
|
||||||
namespace InventoryCheck {
|
namespace InventoryCheck {
|
||||||
|
|
||||||
[[nodiscard]] auto getSelfPluginInstance() -> ll::plugin::NativePlugin&;
|
using namespace GMLIB::Files::I18n;
|
||||||
|
|
||||||
|
class Entry {
|
||||||
|
|
||||||
|
public:
|
||||||
|
static std::unique_ptr<Entry>& getInstance();
|
||||||
|
|
||||||
|
Entry(ll::mod::NativeMod& self) : mSelf(self) {}
|
||||||
|
|
||||||
|
[[nodiscard]] ll::mod::NativeMod& getSelf() const { return mSelf; }
|
||||||
|
|
||||||
|
/// @return True if the mod is loaded successfully.
|
||||||
|
bool load();
|
||||||
|
|
||||||
|
/// @return True if the mod is enabled successfully.
|
||||||
|
bool enable();
|
||||||
|
|
||||||
|
/// @return True if the mod is disabled successfully.
|
||||||
|
bool disable();
|
||||||
|
|
||||||
|
/// @return True if the mod is unloaded successfully.
|
||||||
|
bool unload();
|
||||||
|
|
||||||
|
Config& getConfig();
|
||||||
|
|
||||||
|
LangI18n& getI18n();
|
||||||
|
|
||||||
|
private:
|
||||||
|
ll::mod::NativeMod& mSelf;
|
||||||
|
std::optional<Config> mConfig;
|
||||||
|
std::optional<LangI18n> mI18n;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace InventoryCheck
|
} // namespace InventoryCheck
|
||||||
|
|||||||
+12
-15
@@ -1,29 +1,26 @@
|
|||||||
#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 662
|
#define TARGET_PROTOCOL 686
|
||||||
|
|
||||||
extern ll::Logger logger;
|
extern ll::Logger logger;
|
||||||
|
|
||||||
extern std::string tr(std::string key, std::vector<std::string> data = {});
|
extern std::string tr(std::string const& key, std::vector<std::string> const& data = {});
|
||||||
|
|
||||||
extern void initPlugin();
|
|
||||||
extern void RegisterCommand();
|
extern void RegisterCommand();
|
||||||
|
|
||||||
extern void mainForm(Player& pl);
|
extern void mainForm(Player& pl);
|
||||||
extern void checkOnlineForm(Player& pl);
|
extern void checkOnlineForm(Player& pl);
|
||||||
extern void checkAllForm(Player& pl);
|
extern void checkAllForm(Player& pl);
|
||||||
extern void searchPlayerForm(Player& pl);
|
extern void searchPlayerForm(Player& pl);
|
||||||
extern void searchResultForm(Player& pl, std::unordered_map<mce::UUID, std::string> resultList);
|
extern void searchResultForm(Player& pl, std::unordered_map<mce::UUID, std::string> const& resultList);
|
||||||
extern void searchNotFoundForm(Player& pl, std::string& name);
|
extern void searchNotFoundForm(Player& pl, std::string const& name);
|
||||||
extern void checkPlayerForm(Player& pl, mce::UUID uuid);
|
extern void checkPlayerForm(Player& pl, mce::UUID const& uuid);
|
||||||
extern void invalidInputForm(Player& pl);
|
extern void invalidInputForm(Player& pl);
|
||||||
extern void confirmWriteForm(Player& pl, mce::UUID uuid, std::string name);
|
extern void confirmWriteForm(Player& pl, mce::UUID const& uuid, std::string const& name);
|
||||||
extern void confirmDeleteForm(Player& pl, mce::UUID uuid, std::string name);
|
extern void confirmDeleteForm(Player& pl, mce::UUID const& uuid, std::string const& name);
|
||||||
extern void deleteFailedForm(Player& pl, mce::UUID uuid, std::string name);
|
extern void deleteFailedForm(Player& pl, mce::UUID const& uuid, std::string const& name);
|
||||||
|
|
||||||
extern void listenEvent();
|
|
||||||
extern void initPlayerDataCache();
|
|
||||||
|
|
||||||
extern std::optional<std::string> getNameFromUuid(std::string uuid);
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
#include "Config.h"
|
|
||||||
#include "Global.h"
|
|
||||||
#include "Language.h"
|
|
||||||
|
|
||||||
GMLIB::Files::JsonConfig* Config = nullptr;
|
|
||||||
GMLIB::Files::I18n::LangI18n* Language = nullptr;
|
|
||||||
nlohmann::json mPlayerDataCache;
|
|
||||||
|
|
||||||
std::optional<nlohmann::json> readFile(std::string path) {
|
|
||||||
if (std::filesystem::exists(path)) {
|
|
||||||
return GMLIB::Files::JsonFile::readFromFile(path);
|
|
||||||
}
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
void initPlayerDataCache() {
|
|
||||||
mPlayerDataCache = nlohmann::json::object();
|
|
||||||
auto data = readFile("./plugins/InventoryCheck/data/PlayerDataCache.json");
|
|
||||||
if (data.has_value()) {
|
|
||||||
try {
|
|
||||||
mPlayerDataCache = data.value();
|
|
||||||
} catch (...) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void saveCacheData() {
|
|
||||||
std::string path = "./plugins/InventoryCheck/data/PlayerDataCache.json";
|
|
||||||
GMLIB::Files::JsonFile::writeFile(path, mPlayerDataCache);
|
|
||||||
}
|
|
||||||
|
|
||||||
void initPlugin() {
|
|
||||||
Config = new GMLIB::Files::JsonConfig("./plugins/InventoryCheck/config/config.json", defaultConfig);
|
|
||||||
Config->init();
|
|
||||||
std::string langPath = "./plugins/InventoryCheck/language/";
|
|
||||||
std::string languageCode = Config->getValue<std::string>({"language"}, "en_US");
|
|
||||||
Language = new GMLIB::Files::I18n::LangI18n(langPath, languageCode);
|
|
||||||
Language->updateOrCreateLanguage("en_US", defaultLanguage_en_US);
|
|
||||||
Language->updateOrCreateLanguage("zh_CN", defaultLanguage_zh_CN);
|
|
||||||
Language->loadAllLanguages();
|
|
||||||
Language->chooseLanguage(languageCode);
|
|
||||||
if (!std::filesystem::exists("./plugins/InventoryCheck/data/")) {
|
|
||||||
std::filesystem::create_directories("./plugins/InventoryCheck/data/");
|
|
||||||
}
|
|
||||||
if (!std::filesystem::exists("./plugins/InventoryCheck/save/")) {
|
|
||||||
std::filesystem::create_directories("./plugins/InventoryCheck/save/");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string tr(std::string key, std::vector<std::string> data) { return Language->translate(key, data); }
|
|
||||||
|
|
||||||
void listenEvent() {
|
|
||||||
auto& eventBus = ll::event::EventBus::getInstance();
|
|
||||||
eventBus.emplaceListener<ll::event::player::PlayerConnectEvent>([](ll::event::player::PlayerConnectEvent& ev) {
|
|
||||||
auto& pl = ev.self();
|
|
||||||
mPlayerDataCache[pl.getUuid().asString()] = pl.getRealName();
|
|
||||||
saveCacheData();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
std::optional<std::string> getNameFromUuid(std::string uuid) {
|
|
||||||
if (mPlayerDataCache.contains(uuid)) {
|
|
||||||
return mPlayerDataCache[uuid].get<std::string>();
|
|
||||||
}
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
+24
-46
@@ -1,18 +1,13 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
bool saveInventory(Player& player) {
|
bool saveInventory(Player& player) {
|
||||||
auto& pl = static_cast<GMLIB_Player&>(player);
|
auto& pl = static_cast<GMLIB_Player&>(player);
|
||||||
auto uuid = pl.getUuid();
|
auto uuid = pl.getUuid();
|
||||||
std::string path = "./plugins/InventoryCheck/save/" + uuid.asString() + ".dat";
|
ll::file_utils::writeFile(
|
||||||
if (!std::filesystem::exists(path)) {
|
"./plugins/InventoryCheck/save/" + uuid.asString() + ".dat",
|
||||||
auto nbt = pl.getNbt()->toBinaryNbt();
|
pl.getNbt()->toBinaryNbt(),
|
||||||
std::ofstream newFile(path, std::ios::out | std::ios::binary);
|
true
|
||||||
if (newFile.is_open()) {
|
);
|
||||||
newFile.write(nbt.c_str(), nbt.size());
|
|
||||||
newFile.close();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,22 +15,11 @@ bool resumeInventory(Player& player) {
|
|||||||
auto& pl = static_cast<GMLIB_Player&>(player);
|
auto& pl = static_cast<GMLIB_Player&>(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 (std::filesystem::exists(path)) {
|
if (auto binaryData = ll::file_utils::readFile(path, true)) {
|
||||||
std::ifstream dataFile(path, std::ios::binary);
|
std::filesystem::remove(path);
|
||||||
if (dataFile.is_open()) {
|
if (auto nbt = CompoundTag::fromBinaryNbt(binaryData.value())) {
|
||||||
dataFile.seekg(0, std::ios::end);
|
GMLIB_Player::setPlayerNbtTags(uuid, *nbt, {"Offhand", "Inventory", "Armor", "EnderChestInventory"});
|
||||||
std::streampos fileSize = dataFile.tellg();
|
return true;
|
||||||
dataFile.seekg(0, std::ios::beg);
|
|
||||||
std::vector<char> buffer(fileSize);
|
|
||||||
dataFile.read(buffer.data(), fileSize);
|
|
||||||
std::string_view binaryData(buffer.data(), fileSize);
|
|
||||||
dataFile.close();
|
|
||||||
std::filesystem::remove(path);
|
|
||||||
auto nbt = CompoundTag::fromBinaryNbt(binaryData);
|
|
||||||
if (nbt) {
|
|
||||||
GMLIB_Player::setPlayerNbtTags(uuid, *nbt, {"Offhand", "Inventory", "Armor", "EnderChestInventory"});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -81,19 +65,14 @@ void checkOnlineForm(Player& pl) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getNameFormUuid(mce::UUID& uuid) {
|
std::string getNameFormUuid(mce::UUID const& uuid) {
|
||||||
auto player = GMLIB_Level::getLevel()->getPlayer(uuid);
|
auto player = GMLIB_Level::getLevel()->getPlayer(uuid);
|
||||||
std::string name;
|
std::string name;
|
||||||
if (player) {
|
if (player) {
|
||||||
name = player->getRealName();
|
name = player->getRealName();
|
||||||
} else {
|
} else {
|
||||||
auto strUuid = uuid.asString();
|
auto cache = GMLIB::UserCache::getNameByUuid(uuid);
|
||||||
auto cachename = getNameFromUuid(strUuid);
|
name = cache ? cache.value() : uuid.asString();
|
||||||
if (cachename.has_value()) {
|
|
||||||
name = cachename.value();
|
|
||||||
} else {
|
|
||||||
name = strUuid;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@@ -170,7 +149,7 @@ void searchPlayerForm(Player& pl) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void searchResultForm(Player& pl, std::unordered_map<mce::UUID, std::string> resultList) {
|
void searchResultForm(Player& pl, std::unordered_map<mce::UUID, std::string> const& resultList) {
|
||||||
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"));
|
||||||
for (auto& [uuid, name] : resultList) {
|
for (auto& [uuid, name] : resultList) {
|
||||||
fm.appendButton(name, [uuid](Player& pl) { checkPlayerForm(pl, uuid); });
|
fm.appendButton(name, [uuid](Player& pl) { checkPlayerForm(pl, uuid); });
|
||||||
@@ -182,7 +161,7 @@ void searchResultForm(Player& pl, std::unordered_map<mce::UUID, std::string> res
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void searchNotFoundForm(Player& pl, std::string& name) {
|
void searchNotFoundForm(Player& pl, std::string const& name) {
|
||||||
auto fm = ll::form::ModalForm(
|
auto fm = ll::form::ModalForm(
|
||||||
tr("form.notFound.title"),
|
tr("form.notFound.title"),
|
||||||
tr("form.notFound.content", {name}),
|
tr("form.notFound.content", {name}),
|
||||||
@@ -197,7 +176,7 @@ void searchNotFoundForm(Player& pl, std::string& name) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkPlayerForm(Player& pl, mce::UUID 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) {
|
||||||
@@ -238,7 +217,7 @@ void invalidInputForm(Player& pl) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void confirmWriteForm(Player& pl, mce::UUID uuid, std::string name) {
|
void confirmWriteForm(Player& pl, mce::UUID const& uuid, std::string const& name) {
|
||||||
auto fm = ll::form::ModalForm(
|
auto fm = ll::form::ModalForm(
|
||||||
tr("form.confirmWrite.title"),
|
tr("form.confirmWrite.title"),
|
||||||
tr("form.confirmWrite.content", {name}),
|
tr("form.confirmWrite.content", {name}),
|
||||||
@@ -260,7 +239,7 @@ void confirmWriteForm(Player& pl, mce::UUID uuid, std::string name) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void confirmDeleteForm(Player& pl, mce::UUID uuid, std::string name) {
|
void confirmDeleteForm(Player& pl, mce::UUID const& uuid, std::string const& name) {
|
||||||
auto fm = ll::form::ModalForm(
|
auto fm = ll::form::ModalForm(
|
||||||
tr("form.confirmDelete.title"),
|
tr("form.confirmDelete.title"),
|
||||||
tr("form.confirmDelete.content", {name}),
|
tr("form.confirmDelete.content", {name}),
|
||||||
@@ -269,18 +248,17 @@ void confirmDeleteForm(Player& pl, mce::UUID uuid, std::string 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 player = GMLIB_Level::getLevel()->getPlayer(uuid);
|
if (auto player = GMLIB_Level::getLevel()->getPlayer(uuid)) {
|
||||||
if (player) {
|
|
||||||
return deleteFailedForm(pl, uuid, name);
|
return deleteFailedForm(pl, uuid, name);
|
||||||
}
|
}
|
||||||
GMLIB_Player::deletePlayerNbt(uuid);
|
GMLIB_Player::deletePlayer(uuid);
|
||||||
return pl.sendMessage(tr("checkPlayer.deleteNbt.success", {name}));
|
return pl.sendMessage(tr("checkPlayer.deletePlayer.success", {name}));
|
||||||
}
|
}
|
||||||
return checkPlayerForm(pl, uuid);
|
return checkPlayerForm(pl, uuid);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void deleteFailedForm(Player& pl, mce::UUID uuid, std::string name) {
|
void deleteFailedForm(Player& pl, mce::UUID const& uuid, std::string const& name) {
|
||||||
auto fm = ll::form::ModalForm(
|
auto fm = ll::form::ModalForm(
|
||||||
tr("form.deleteFailed.title"),
|
tr("form.deleteFailed.title"),
|
||||||
tr("form.deleteFailed.content", {name}),
|
tr("form.deleteFailed.content", {name}),
|
||||||
|
|||||||
+5
-5
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Global.h"
|
#include <iostream>
|
||||||
|
|
||||||
std::string defaultLanguage_en_US = R"(
|
std::string en_US = R"(
|
||||||
form.main.title=Check Player Inventory
|
form.main.title=Check Player Inventory
|
||||||
form.main.content=Please select a query mode.
|
form.main.content=Please select a query mode.
|
||||||
form.main.checkOnline=Query online players
|
form.main.checkOnline=Query online players
|
||||||
@@ -41,7 +41,7 @@ std::string defaultLanguage_en_US = R"(
|
|||||||
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!
|
||||||
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.deleteNbt.success=Successfully deleted all of player %s's data!
|
checkPlayer.deletePlayer.success=Successfully deleted player from storage!
|
||||||
form.deleteFailed.title=Deletion failed
|
form.deleteFailed.title=Deletion failed
|
||||||
form.deleteFailed.content=Players %s online! You can't delete all of your players' data! \n\nIf you want to delete all player data, please kick the player out of the game before you do it!
|
form.deleteFailed.content=Players %s online! You can't delete all of your players' data! \n\nIf you want to delete all player data, please kick the player out of the game before you do it!
|
||||||
form.deleteFailed.returnCheck=Return to the check menu
|
form.deleteFailed.returnCheck=Return to the check menu
|
||||||
@@ -53,7 +53,7 @@ std::string defaultLanguage_en_US = R"(
|
|||||||
error.protocolMismatch.version=Support protocol %1$s, current protocol %2$s.
|
error.protocolMismatch.version=Support protocol %1$s, current protocol %2$s.
|
||||||
)";
|
)";
|
||||||
|
|
||||||
std::string defaultLanguage_zh_CN = R"(
|
std::string zh_CN = R"(
|
||||||
form.main.title=查询玩家背包
|
form.main.title=查询玩家背包
|
||||||
form.main.content=请选择查询模式
|
form.main.content=请选择查询模式
|
||||||
form.main.checkOnline=查询在线玩家
|
form.main.checkOnline=查询在线玩家
|
||||||
@@ -93,7 +93,7 @@ std::string defaultLanguage_zh_CN = R"(
|
|||||||
checkPlayer.writeInventory.failed=无法覆盖玩家 %s 的背包!\n玩家 %s 没有任何数据!
|
checkPlayer.writeInventory.failed=无法覆盖玩家 %s 的背包!\n玩家 %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.deleteNbt.success=已成功删除玩家 %s 的全部数据!
|
checkPlayer.deletePlayer.success=已成功将玩家 %s 从存档删除!
|
||||||
form.deleteFailed.title=删除失败
|
form.deleteFailed.title=删除失败
|
||||||
form.deleteFailed.content=玩家 %s 在线!无法删除玩家全部数据!\n\n如需删除全部玩家数据,请先将该玩家踢出游戏再操作!
|
form.deleteFailed.content=玩家 %s 在线!无法删除玩家全部数据!\n\n如需删除全部玩家数据,请先将该玩家踢出游戏再操作!
|
||||||
form.deleteFailed.returnCheck=返回操作界面
|
form.deleteFailed.returnCheck=返回操作界面
|
||||||
|
|||||||
@@ -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
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"format_version": 2,
|
"format_version": 2,
|
||||||
"tooth": "github.com/GroupMountain/InventoryCheck",
|
"tooth": "github.com/GroupMountain/InventoryCheck",
|
||||||
"version": "0.11.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.11.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.10.0"
|
"github.com/GroupMountain/GMLIB": ">=0.13.7"
|
||||||
},
|
},
|
||||||
"files": {
|
"files": {
|
||||||
"place": [
|
"place": [
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
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")
|
||||||
|
|
||||||
if not has_config("vs_runtime") then
|
if not has_config("vs_runtime") then
|
||||||
set_runtimes("MD")
|
set_runtimes("MD")
|
||||||
@@ -8,6 +9,7 @@ end
|
|||||||
|
|
||||||
-- Option 1: Use the latest version of LeviLamina released on GitHub.
|
-- Option 1: Use the latest version of LeviLamina released on GitHub.
|
||||||
add_requires("levilamina")
|
add_requires("levilamina")
|
||||||
|
add_requires("gmlib")
|
||||||
|
|
||||||
-- Option 2: Use a specific version of LeviLamina released on GitHub.
|
-- Option 2: Use a specific version of LeviLamina released on GitHub.
|
||||||
-- add_requires("levilamina x.x.x")
|
-- add_requires("levilamina x.x.x")
|
||||||
@@ -40,7 +42,7 @@ add_requires("levilamina")
|
|||||||
-- 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"
|
||||||
@@ -52,15 +54,12 @@ target("InventoryCheck") -- Change this to your plugin name.
|
|||||||
add_files(
|
add_files(
|
||||||
"src/**.cpp"
|
"src/**.cpp"
|
||||||
)
|
)
|
||||||
add_links(
|
|
||||||
"SDK-GMLIB/Lib/GMLIB"
|
|
||||||
)
|
|
||||||
add_includedirs(
|
add_includedirs(
|
||||||
"SDK-GMLIB",
|
|
||||||
"src"
|
"src"
|
||||||
)
|
)
|
||||||
add_packages(
|
add_packages(
|
||||||
"levilamina"
|
"levilamina",
|
||||||
|
"gmlib"
|
||||||
)
|
)
|
||||||
add_shflags(
|
add_shflags(
|
||||||
"/DELAYLOAD:bedrock_server.dll" -- Magic to import symbols from BDS
|
"/DELAYLOAD:bedrock_server.dll" -- Magic to import symbols from BDS
|
||||||
@@ -71,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)
|
||||||
|
|||||||
Reference in New Issue
Block a user