Compare commits
11 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
|
||||||
|
|
||||||
|
|||||||
@@ -15,3 +15,4 @@ build/
|
|||||||
/.xmake
|
/.xmake
|
||||||
/CMakeLists.txt
|
/CMakeLists.txt
|
||||||
/bin
|
/bin
|
||||||
|
.cache/clangd/index
|
||||||
|
|||||||
-1
Submodule SDK-GMLIB deleted from 2bb91343e1
@@ -1,6 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "${pluginName}",
|
"name": "${pluginName}",
|
||||||
"entry": "${pluginFile}",
|
"entry": "${pluginFile}",
|
||||||
|
"version": "0.13.0",
|
||||||
|
"author": "GroupMountain",
|
||||||
|
"description": "Check Player's Inventory",
|
||||||
"type": "native",
|
"type": "native",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
{
|
{
|
||||||
|
|||||||
+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
-31
@@ -1,58 +1,62 @@
|
|||||||
#include "Entry.h"
|
#include "Entry.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
#include "Language.h"
|
||||||
|
|
||||||
ll::Logger logger(PLUGIN_NAME);
|
ll::Logger logger(PLUGIN_NAME);
|
||||||
|
|
||||||
namespace InventoryCheck {
|
namespace InventoryCheck {
|
||||||
|
|
||||||
namespace {
|
std::unique_ptr<Entry>& Entry::getInstance() {
|
||||||
|
static std::unique_ptr<Entry> instance;
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<std::reference_wrapper<ll::plugin::NativePlugin>>
|
bool Entry::load() {
|
||||||
selfPluginInstance; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
mConfig.emplace();
|
||||||
|
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) {
|
||||||
|
logger.error(tr("error.protocolMismatch.info"));
|
||||||
|
logger.error(
|
||||||
|
tr("error.protocolMismatch.version",
|
||||||
|
{std::to_string(TARGET_PROTOCOL), std::to_string(GMLIB::Version::getProtocolVersion())})
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
auto disable(ll::plugin::NativePlugin& /*self*/) -> bool { return true; }
|
bool Entry::enable() {
|
||||||
|
|
||||||
auto enable(ll::plugin::NativePlugin& /*self*/) -> bool {
|
|
||||||
RegisterCommand();
|
RegisterCommand();
|
||||||
listenEvent();
|
|
||||||
logger.info("InventoryCheck Loaded!");
|
logger.info("InventoryCheck Loaded!");
|
||||||
logger.info("Author: GroupMountain");
|
logger.info("Author: GroupMountain");
|
||||||
logger.info("Repository: https://github.com/GroupMountain/InventoryCheck");
|
logger.info("Repository: https://github.com/GroupMountain/InventoryCheck");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto load(ll::plugin::NativePlugin& self) -> bool {
|
bool Entry::disable() {
|
||||||
selfPluginInstance = std::make_unique<std::reference_wrapper<ll::plugin::NativePlugin>>(self);
|
// Code for disabling the plugin goes here.
|
||||||
initPlugin();
|
|
||||||
initPlayerDataCache();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto unload(ll::plugin::NativePlugin& self) -> bool {
|
bool Entry::unload() {
|
||||||
selfPluginInstance.reset();
|
getInstance().reset();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
Config& Entry::getConfig() { return mConfig.value(); }
|
||||||
|
|
||||||
auto getSelfPluginInstance() -> ll::plugin::NativePlugin& {
|
LangI18n& Entry::getI18n() { return mI18n.value(); }
|
||||||
if (!selfPluginInstance) {
|
|
||||||
throw std::runtime_error("selfPluginInstance is null");
|
|
||||||
}
|
|
||||||
return *selfPluginInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace InventoryCheck
|
} // namespace InventoryCheck
|
||||||
|
|
||||||
extern "C" {
|
LL_REGISTER_PLUGIN(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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+34
-3
@@ -1,9 +1,40 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include "Config.h"
|
||||||
#include <ll/api/plugin/NativePlugin.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::plugin::NativePlugin& self) : mSelf(self) {}
|
||||||
|
|
||||||
|
[[nodiscard]] ll::plugin::NativePlugin& getSelf() const { return mSelf; }
|
||||||
|
|
||||||
|
/// @return True if the plugin is loaded successfully.
|
||||||
|
bool load();
|
||||||
|
|
||||||
|
/// @return True if the plugin is enabled successfully.
|
||||||
|
bool enable();
|
||||||
|
|
||||||
|
/// @return True if the plugin is disabled successfully.
|
||||||
|
bool disable();
|
||||||
|
|
||||||
|
/// @return True if the plugin is unloaded successfully.
|
||||||
|
bool unload();
|
||||||
|
|
||||||
|
Config& getConfig();
|
||||||
|
|
||||||
|
LangI18n& getI18n();
|
||||||
|
|
||||||
|
private:
|
||||||
|
ll::plugin::NativePlugin& mSelf;
|
||||||
|
std::optional<Config> mConfig;
|
||||||
|
std::optional<LangI18n> mI18n;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace InventoryCheck
|
} // namespace InventoryCheck
|
||||||
|
|||||||
+9
-14
@@ -1,28 +1,23 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <include_all.h>
|
#include <include_all.h>
|
||||||
|
|
||||||
#define PLUGIN_NAME "InventoryCheck"
|
#define PLUGIN_NAME "InventoryCheck"
|
||||||
|
#define TARGET_PROTOCOL 685
|
||||||
|
|
||||||
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 {};
|
|
||||||
}
|
|
||||||
+45
-68
@@ -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;
|
||||||
@@ -74,26 +58,21 @@ void checkOnlineForm(Player& pl) {
|
|||||||
if (onlineList.size() == 1) {
|
if (onlineList.size() == 1) {
|
||||||
return pl.sendMessage(tr("checkOnline.empty"));
|
return pl.sendMessage(tr("checkOnline.empty"));
|
||||||
}
|
}
|
||||||
fm.sendTo(pl, [](Player& pl, int index) {
|
fm.sendTo(pl, [](Player& pl, int index, ll::form::FormCancelReason) {
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
return mainForm(pl);
|
return mainForm(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;
|
||||||
}
|
}
|
||||||
@@ -101,8 +80,7 @@ std::string getNameFormUuid(mce::UUID& uuid) {
|
|||||||
std::unordered_map<mce::UUID, std::string> generateUuidMap() {
|
std::unordered_map<mce::UUID, std::string> generateUuidMap() {
|
||||||
auto allUuids = GMLIB_Player::getAllUuids();
|
auto allUuids = GMLIB_Player::getAllUuids();
|
||||||
std::unordered_map<mce::UUID, std::string> allList;
|
std::unordered_map<mce::UUID, std::string> allList;
|
||||||
for (auto& strUuid : allUuids) {
|
for (auto& uuid : allUuids) {
|
||||||
auto uuid = mce::UUID::fromString(strUuid);
|
|
||||||
auto name = getNameFormUuid(uuid);
|
auto name = getNameFormUuid(uuid);
|
||||||
allList[uuid] = name;
|
allList[uuid] = name;
|
||||||
}
|
}
|
||||||
@@ -120,7 +98,7 @@ void checkAllForm(Player& pl) {
|
|||||||
if (allList.size() == 1) {
|
if (allList.size() == 1) {
|
||||||
return pl.sendMessage(tr("checkAll.empty"));
|
return pl.sendMessage(tr("checkAll.empty"));
|
||||||
}
|
}
|
||||||
fm.sendTo(pl, [](Player& pl, int index) {
|
fm.sendTo(pl, [](Player& pl, int index, ll::form::FormCancelReason) {
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
return mainForm(pl);
|
return mainForm(pl);
|
||||||
}
|
}
|
||||||
@@ -137,15 +115,15 @@ void searchPlayerForm(Player& pl) {
|
|||||||
{tr("form.searchPlayer.fuzzySearch"), tr("form.searchPlayer.preciseSearch")},
|
{tr("form.searchPlayer.fuzzySearch"), tr("form.searchPlayer.preciseSearch")},
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
fm.sendTo(pl, [](Player& pl, const ll::form::CustomFormResult& result) {
|
fm.sendTo(pl, [](Player& pl, ll::form::CustomFormResult const& result, ll::form::FormCancelReason) {
|
||||||
if (result.empty()) {
|
if (!result.has_value()) {
|
||||||
return mainForm(pl);
|
return mainForm(pl);
|
||||||
}
|
}
|
||||||
std::string inputName;
|
std::string inputName;
|
||||||
if (std::holds_alternative<std::string>(result.at("name"))) {
|
if (std::holds_alternative<std::string>(result->at("name"))) {
|
||||||
inputName = std::get<std::string>(result.at("name"));
|
inputName = std::get<std::string>(result->at("name"));
|
||||||
}
|
}
|
||||||
auto searchMode = std::get<std::string>(result.at("mode"));
|
auto searchMode = std::get<std::string>(result->at("mode"));
|
||||||
if (inputName.empty()) {
|
if (inputName.empty()) {
|
||||||
return invalidInputForm(pl);
|
return invalidInputForm(pl);
|
||||||
}
|
}
|
||||||
@@ -171,34 +149,34 @@ 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); });
|
||||||
}
|
}
|
||||||
fm.sendTo(pl, [](Player& pl, int index) {
|
fm.sendTo(pl, [](Player& pl, int index, ll::form::FormCancelReason) {
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
return searchPlayerForm(pl);
|
return searchPlayerForm(pl);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
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}),
|
||||||
tr("form.notFound.returnSearch"),
|
tr("form.notFound.returnSearch"),
|
||||||
tr("form.returnMainForm")
|
tr("form.returnMainForm")
|
||||||
);
|
);
|
||||||
fm.sendTo(pl, [](Player& pl, ll::form::ModalForm::SelectedButton result) {
|
fm.sendTo(pl, [](Player& pl, ll::form::ModalFormResult result, ll::form::FormCancelReason) {
|
||||||
if (result == ll::form::ModalForm::SelectedButton::Upper) {
|
if (result == ll::form::ModalFormSelectedButton::Upper) {
|
||||||
return searchPlayerForm(pl);
|
return searchPlayerForm(pl);
|
||||||
}
|
}
|
||||||
return mainForm(pl);
|
return mainForm(pl);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
@@ -217,7 +195,7 @@ void checkPlayerForm(Player& pl, mce::UUID uuid) {
|
|||||||
fm.appendButton(tr("form.checkPlayer.deleteData"), [uuid, name](Player& pl) {
|
fm.appendButton(tr("form.checkPlayer.deleteData"), [uuid, name](Player& pl) {
|
||||||
return confirmDeleteForm(pl, uuid, name);
|
return confirmDeleteForm(pl, uuid, name);
|
||||||
});
|
});
|
||||||
fm.sendTo(pl, [](Player& pl, int index) {
|
fm.sendTo(pl, [](Player& pl, int index, ll::form::FormCancelReason) {
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
return mainForm(pl);
|
return mainForm(pl);
|
||||||
}
|
}
|
||||||
@@ -231,23 +209,23 @@ void invalidInputForm(Player& pl) {
|
|||||||
tr("form.invalidInput.returnSearch"),
|
tr("form.invalidInput.returnSearch"),
|
||||||
tr("form.returnMainForm")
|
tr("form.returnMainForm")
|
||||||
);
|
);
|
||||||
fm.sendTo(pl, [](Player& pl, ll::form::ModalForm::SelectedButton result) {
|
fm.sendTo(pl, [](Player& pl, ll::form::ModalFormResult result, ll::form::FormCancelReason) {
|
||||||
if (result == ll::form::ModalForm::SelectedButton::Upper) {
|
if (result == ll::form::ModalFormSelectedButton::Upper) {
|
||||||
return searchPlayerForm(pl);
|
return searchPlayerForm(pl);
|
||||||
}
|
}
|
||||||
return mainForm(pl);
|
return mainForm(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}),
|
||||||
tr("form.confirmAction"),
|
tr("form.confirmAction"),
|
||||||
tr("form.cancelAction")
|
tr("form.cancelAction")
|
||||||
);
|
);
|
||||||
fm.sendTo(pl, [uuid, name](Player& pl, ll::form::ModalForm::SelectedButton result) {
|
fm.sendTo(pl, [uuid, name](Player& pl, ll::form::ModalFormResult result, ll::form::FormCancelReason) {
|
||||||
if (result == ll::form::ModalForm::SelectedButton::Upper) {
|
if (result == ll::form::ModalFormSelectedButton::Upper) {
|
||||||
auto& self = static_cast<GMLIB_Player&>(pl);
|
auto& self = static_cast<GMLIB_Player&>(pl);
|
||||||
auto nbt = self.getNbt();
|
auto nbt = self.getNbt();
|
||||||
auto targetNbt = GMLIB_Player::getPlayerNbt(uuid);
|
auto targetNbt = GMLIB_Player::getPlayerNbt(uuid);
|
||||||
@@ -261,35 +239,34 @@ 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}),
|
||||||
tr("form.confirmAction"),
|
tr("form.confirmAction"),
|
||||||
tr("form.cancelAction")
|
tr("form.cancelAction")
|
||||||
);
|
);
|
||||||
fm.sendTo(pl, [uuid, name](Player& pl, ll::form::ModalForm::SelectedButton result) {
|
fm.sendTo(pl, [uuid, name](Player& pl, ll::form::ModalFormResult result, ll::form::FormCancelReason) {
|
||||||
if (result == ll::form::ModalForm::SelectedButton::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}),
|
||||||
tr("form.deleteFailed.returnCheck"),
|
tr("form.deleteFailed.returnCheck"),
|
||||||
tr("form.returnMainForm")
|
tr("form.returnMainForm")
|
||||||
);
|
);
|
||||||
fm.sendTo(pl, [uuid](Player& pl, ll::form::ModalForm::SelectedButton result) {
|
fm.sendTo(pl, [uuid](Player& pl, ll::form::ModalFormResult result, ll::form::FormCancelReason) {
|
||||||
if (result == ll::form::ModalForm::SelectedButton::Upper) {
|
if (result == ll::form::ModalFormSelectedButton::Upper) {
|
||||||
return checkPlayerForm(pl, uuid);
|
return checkPlayerForm(pl, uuid);
|
||||||
}
|
}
|
||||||
return mainForm(pl);
|
return mainForm(pl);
|
||||||
|
|||||||
+9
-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
|
||||||
@@ -49,9 +49,11 @@ std::string defaultLanguage_en_US = R"(
|
|||||||
checkAll.empty=You've played the entire archive alone, and you're still playing here to check the bag? \nWhy don't you go and recruit people?
|
checkAll.empty=You've played the entire archive alone, and you're still playing here to check the bag? \nWhy don't you go and recruit people?
|
||||||
resumeInventory.success=Your backpack has been resumed!
|
resumeInventory.success=Your backpack has been resumed!
|
||||||
resumeInventory.failed=Unable to resume your backpack, no data was found on your backpack!
|
resumeInventory.failed=Unable to resume your backpack, no data was found on your backpack!
|
||||||
|
error.protocolMismatch.info=You are running on an unsupport protocol version! This may result in crash!
|
||||||
|
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=查询在线玩家
|
||||||
@@ -91,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=返回操作界面
|
||||||
@@ -99,4 +101,6 @@ std::string defaultLanguage_zh_CN = R"(
|
|||||||
checkAll.empty=整个存档就你一个人玩过,还在这玩查包呢?\n还不快去招人?
|
checkAll.empty=整个存档就你一个人玩过,还在这玩查包呢?\n还不快去招人?
|
||||||
resumeInventory.success=已成功复原你的背包!
|
resumeInventory.success=已成功复原你的背包!
|
||||||
resumeInventory.failed=无法复原你的背包,没有找到你的背包数据!
|
resumeInventory.failed=无法复原你的背包,没有找到你的背包数据!
|
||||||
|
error.protocolMismatch.info=此插件正在不兼容的版本协议上运行!这可能造成服务器崩溃!
|
||||||
|
error.protocolMismatch.version=此插件支持版本协议 %1$s,服务器版本协议 %2$s。
|
||||||
)";
|
)";
|
||||||
|
|||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"format_version": 2,
|
"format_version": 2,
|
||||||
"tooth": "github.com/GroupMountain/InventoryCheck",
|
"tooth": "github.com/GroupMountain/InventoryCheck",
|
||||||
"version": "0.9.1",
|
"version": "0.13.0",
|
||||||
"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.9.1/InventoryCheck-windows-x64.zip",
|
"asset_url": "https://github.com/GroupMountain/InventoryCheck/releases/download/v0.13.0/InventoryCheck-windows-x64.zip",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"github.com/GroupMountain/GMLIB": ">=0.9.2"
|
"github.com/GroupMountain/GMLIB": ">=0.13.0"
|
||||||
},
|
},
|
||||||
"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")
|
||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user