Compare commits
7 Commits
@@ -15,7 +15,8 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: xmake-io/github-action-setup-xmake@v1
|
||||
|
||||
with:
|
||||
xmake-version: branch@master
|
||||
- run: |
|
||||
xmake repo -u
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: xmake-io/github-action-setup-xmake@v1
|
||||
|
||||
with:
|
||||
xmake-version: branch@master
|
||||
- run: |
|
||||
xmake repo -u
|
||||
|
||||
|
||||
@@ -15,3 +15,4 @@ build/
|
||||
/.xmake
|
||||
/CMakeLists.txt
|
||||
/bin
|
||||
.cache/clangd/index
|
||||
|
||||
-1
Submodule SDK-GMLIB deleted from 37d92200bd
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "${pluginName}",
|
||||
"entry": "${pluginFile}",
|
||||
"version": "0.10.0",
|
||||
"version": "0.13.0",
|
||||
"author": "GroupMountain",
|
||||
"description": "Check Player's Inventory",
|
||||
"type": "native",
|
||||
|
||||
+5
-3
@@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
#include "Global.h"
|
||||
|
||||
std::string defaultConfig = R"({
|
||||
"language": "en_US"
|
||||
})";
|
||||
struct Config {
|
||||
int version = 1;
|
||||
|
||||
std::string language = "en_US";
|
||||
};
|
||||
+33
-37
@@ -1,29 +1,25 @@
|
||||
#include "Entry.h"
|
||||
#include "Global.h"
|
||||
#include "Language.h"
|
||||
|
||||
ll::Logger logger(PLUGIN_NAME);
|
||||
|
||||
namespace InventoryCheck {
|
||||
|
||||
namespace {
|
||||
|
||||
std::unique_ptr<std::reference_wrapper<ll::plugin::NativePlugin>>
|
||||
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;
|
||||
std::unique_ptr<Entry>& Entry::getInstance() {
|
||||
static std::unique_ptr<Entry> instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
auto load(ll::plugin::NativePlugin& self) -> bool {
|
||||
selfPluginInstance = std::make_unique<std::reference_wrapper<ll::plugin::NativePlugin>>(self);
|
||||
initPlugin();
|
||||
bool Entry::load() {
|
||||
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(
|
||||
@@ -32,35 +28,35 @@ auto load(ll::plugin::NativePlugin& self) -> bool {
|
||||
);
|
||||
return false;
|
||||
}
|
||||
initPlayerDataCache();
|
||||
return true;
|
||||
}
|
||||
|
||||
auto unload(ll::plugin::NativePlugin& self) -> bool {
|
||||
selfPluginInstance.reset();
|
||||
bool Entry::enable() {
|
||||
RegisterCommand();
|
||||
logger.info("InventoryCheck Loaded!");
|
||||
logger.info("Author: GroupMountain");
|
||||
logger.info("Repository: https://github.com/GroupMountain/InventoryCheck");
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
bool Entry::disable() {
|
||||
// Code for disabling the plugin goes here.
|
||||
return true;
|
||||
}
|
||||
|
||||
auto getSelfPluginInstance() -> ll::plugin::NativePlugin& {
|
||||
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
|
||||
|
||||
extern "C" {
|
||||
_declspec(dllexport) auto ll_plugin_disable(ll::plugin::NativePlugin& self) -> bool {
|
||||
return InventoryCheck::disable(self);
|
||||
}
|
||||
_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);
|
||||
}
|
||||
LL_REGISTER_PLUGIN(InventoryCheck::Entry, InventoryCheck::Entry::getInstance());
|
||||
|
||||
std::string tr(std::string const& key, std::vector<std::string> const& data) {
|
||||
return InventoryCheck::Entry::getInstance()->getI18n().get(key, data);
|
||||
}
|
||||
+34
-3
@@ -1,9 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include <ll/api/plugin/NativePlugin.h>
|
||||
#include "Config.h"
|
||||
#include "Global.h"
|
||||
|
||||
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
|
||||
|
||||
+8
-14
@@ -2,28 +2,22 @@
|
||||
#include <include_all.h>
|
||||
|
||||
#define PLUGIN_NAME "InventoryCheck"
|
||||
#define TARGET_PROTOCOL 662
|
||||
#define TARGET_PROTOCOL 685
|
||||
|
||||
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 mainForm(Player& pl);
|
||||
extern void checkOnlineForm(Player& pl);
|
||||
extern void checkAllForm(Player& pl);
|
||||
extern void searchPlayerForm(Player& pl);
|
||||
extern void searchResultForm(Player& pl, std::unordered_map<mce::UUID, std::string> resultList);
|
||||
extern void searchNotFoundForm(Player& pl, std::string& name);
|
||||
extern void checkPlayerForm(Player& pl, mce::UUID uuid);
|
||||
extern void searchResultForm(Player& pl, std::unordered_map<mce::UUID, std::string> const& resultList);
|
||||
extern void searchNotFoundForm(Player& pl, std::string const& name);
|
||||
extern void checkPlayerForm(Player& pl, mce::UUID const& uuid);
|
||||
extern void invalidInputForm(Player& pl);
|
||||
extern void confirmWriteForm(Player& pl, mce::UUID uuid, std::string name);
|
||||
extern void confirmDeleteForm(Player& pl, mce::UUID uuid, std::string name);
|
||||
extern void deleteFailedForm(Player& pl, mce::UUID uuid, std::string name);
|
||||
|
||||
extern void listenEvent();
|
||||
extern void initPlayerDataCache();
|
||||
|
||||
extern std::optional<std::string> getNameFromUuid(std::string uuid);
|
||||
extern void confirmWriteForm(Player& pl, mce::UUID const& uuid, std::string const& name);
|
||||
extern void confirmDeleteForm(Player& pl, mce::UUID const& uuid, std::string const& name);
|
||||
extern void deleteFailedForm(Player& pl, mce::UUID const& uuid, std::string const& name);
|
||||
@@ -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 {};
|
||||
}
|
||||
+39
-61
@@ -3,16 +3,11 @@
|
||||
bool saveInventory(Player& player) {
|
||||
auto& pl = static_cast<GMLIB_Player&>(player);
|
||||
auto uuid = pl.getUuid();
|
||||
std::string path = "./plugins/InventoryCheck/save/" + uuid.asString() + ".dat";
|
||||
if (!std::filesystem::exists(path)) {
|
||||
auto nbt = pl.getNbt()->toBinaryNbt();
|
||||
std::ofstream newFile(path, std::ios::out | std::ios::binary);
|
||||
if (newFile.is_open()) {
|
||||
newFile.write(nbt.c_str(), nbt.size());
|
||||
newFile.close();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
ll::file_utils::writeFile(
|
||||
"./plugins/InventoryCheck/save/" + uuid.asString() + ".dat",
|
||||
pl.getNbt()->toBinaryNbt(),
|
||||
true
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -20,24 +15,13 @@ bool resumeInventory(Player& player) {
|
||||
auto& pl = static_cast<GMLIB_Player&>(player);
|
||||
auto uuid = pl.getUuid();
|
||||
std::string path = "./plugins/InventoryCheck/save/" + uuid.asString() + ".dat";
|
||||
if (std::filesystem::exists(path)) {
|
||||
std::ifstream dataFile(path, std::ios::binary);
|
||||
if (dataFile.is_open()) {
|
||||
dataFile.seekg(0, std::ios::end);
|
||||
std::streampos fileSize = dataFile.tellg();
|
||||
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();
|
||||
if (auto binaryData = ll::file_utils::readFile(path, true)) {
|
||||
std::filesystem::remove(path);
|
||||
auto nbt = CompoundTag::fromBinaryNbt(binaryData);
|
||||
if (nbt) {
|
||||
if (auto nbt = CompoundTag::fromBinaryNbt(binaryData.value())) {
|
||||
GMLIB_Player::setPlayerNbtTags(uuid, *nbt, {"Offhand", "Inventory", "Armor", "EnderChestInventory"});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -74,26 +58,21 @@ void checkOnlineForm(Player& pl) {
|
||||
if (onlineList.size() == 1) {
|
||||
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) {
|
||||
return mainForm(pl);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
std::string getNameFormUuid(mce::UUID& uuid) {
|
||||
std::string getNameFormUuid(mce::UUID const& uuid) {
|
||||
auto player = GMLIB_Level::getLevel()->getPlayer(uuid);
|
||||
std::string name;
|
||||
if (player) {
|
||||
name = player->getRealName();
|
||||
} else {
|
||||
auto strUuid = uuid.asString();
|
||||
auto cachename = getNameFromUuid(strUuid);
|
||||
if (cachename.has_value()) {
|
||||
name = cachename.value();
|
||||
} else {
|
||||
name = strUuid;
|
||||
}
|
||||
auto cache = GMLIB::UserCache::getNameByUuid(uuid);
|
||||
name = cache ? cache.value() : uuid.asString();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
@@ -119,7 +98,7 @@ void checkAllForm(Player& pl) {
|
||||
if (allList.size() == 1) {
|
||||
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) {
|
||||
return mainForm(pl);
|
||||
}
|
||||
@@ -136,15 +115,15 @@ void searchPlayerForm(Player& pl) {
|
||||
{tr("form.searchPlayer.fuzzySearch"), tr("form.searchPlayer.preciseSearch")},
|
||||
0
|
||||
);
|
||||
fm.sendTo(pl, [](Player& pl, const ll::form::CustomFormResult& result) {
|
||||
if (result.empty()) {
|
||||
fm.sendTo(pl, [](Player& pl, ll::form::CustomFormResult const& result, ll::form::FormCancelReason) {
|
||||
if (!result.has_value()) {
|
||||
return mainForm(pl);
|
||||
}
|
||||
std::string inputName;
|
||||
if (std::holds_alternative<std::string>(result.at("name"))) {
|
||||
inputName = std::get<std::string>(result.at("name"));
|
||||
if (std::holds_alternative<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()) {
|
||||
return invalidInputForm(pl);
|
||||
}
|
||||
@@ -170,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"));
|
||||
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) {
|
||||
return searchPlayerForm(pl);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void searchNotFoundForm(Player& pl, std::string& name) {
|
||||
void searchNotFoundForm(Player& pl, std::string const& name) {
|
||||
auto fm = ll::form::ModalForm(
|
||||
tr("form.notFound.title"),
|
||||
tr("form.notFound.content", {name}),
|
||||
tr("form.notFound.returnSearch"),
|
||||
tr("form.returnMainForm")
|
||||
);
|
||||
fm.sendTo(pl, [](Player& pl, ll::form::ModalForm::SelectedButton result) {
|
||||
if (result == ll::form::ModalForm::SelectedButton::Upper) {
|
||||
fm.sendTo(pl, [](Player& pl, ll::form::ModalFormResult result, ll::form::FormCancelReason) {
|
||||
if (result == ll::form::ModalFormSelectedButton::Upper) {
|
||||
return searchPlayerForm(pl);
|
||||
}
|
||||
return mainForm(pl);
|
||||
});
|
||||
}
|
||||
|
||||
void checkPlayerForm(Player& pl, mce::UUID uuid) {
|
||||
void checkPlayerForm(Player& pl, mce::UUID const& uuid) {
|
||||
std::string name = getNameFormUuid(uuid);
|
||||
auto fm = ll::form::SimpleForm(tr("form.checkPlayer.title"), tr("form.checkPlayer.content", {name}));
|
||||
fm.appendButton(tr("form.checkPlayer.copyInventory"), [uuid, name](Player& pl) {
|
||||
@@ -216,7 +195,7 @@ void checkPlayerForm(Player& pl, mce::UUID uuid) {
|
||||
fm.appendButton(tr("form.checkPlayer.deleteData"), [uuid, name](Player& pl) {
|
||||
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) {
|
||||
return mainForm(pl);
|
||||
}
|
||||
@@ -230,23 +209,23 @@ void invalidInputForm(Player& pl) {
|
||||
tr("form.invalidInput.returnSearch"),
|
||||
tr("form.returnMainForm")
|
||||
);
|
||||
fm.sendTo(pl, [](Player& pl, ll::form::ModalForm::SelectedButton result) {
|
||||
if (result == ll::form::ModalForm::SelectedButton::Upper) {
|
||||
fm.sendTo(pl, [](Player& pl, ll::form::ModalFormResult result, ll::form::FormCancelReason) {
|
||||
if (result == ll::form::ModalFormSelectedButton::Upper) {
|
||||
return searchPlayerForm(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(
|
||||
tr("form.confirmWrite.title"),
|
||||
tr("form.confirmWrite.content", {name}),
|
||||
tr("form.confirmAction"),
|
||||
tr("form.cancelAction")
|
||||
);
|
||||
fm.sendTo(pl, [uuid, name](Player& pl, ll::form::ModalForm::SelectedButton result) {
|
||||
if (result == ll::form::ModalForm::SelectedButton::Upper) {
|
||||
fm.sendTo(pl, [uuid, name](Player& pl, ll::form::ModalFormResult result, ll::form::FormCancelReason) {
|
||||
if (result == ll::form::ModalFormSelectedButton::Upper) {
|
||||
auto& self = static_cast<GMLIB_Player&>(pl);
|
||||
auto nbt = self.getNbt();
|
||||
auto targetNbt = GMLIB_Player::getPlayerNbt(uuid);
|
||||
@@ -260,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(
|
||||
tr("form.confirmDelete.title"),
|
||||
tr("form.confirmDelete.content", {name}),
|
||||
tr("form.confirmAction"),
|
||||
tr("form.cancelAction")
|
||||
);
|
||||
fm.sendTo(pl, [uuid, name](Player& pl, ll::form::ModalForm::SelectedButton result) {
|
||||
if (result == ll::form::ModalForm::SelectedButton::Upper) {
|
||||
auto player = GMLIB_Level::getLevel()->getPlayer(uuid);
|
||||
if (player) {
|
||||
fm.sendTo(pl, [uuid, name](Player& pl, ll::form::ModalFormResult result, ll::form::FormCancelReason) {
|
||||
if (result == ll::form::ModalFormSelectedButton::Upper) {
|
||||
if (auto player = GMLIB_Level::getLevel()->getPlayer(uuid)) {
|
||||
return deleteFailedForm(pl, uuid, name);
|
||||
}
|
||||
GMLIB_Player::deletePlayerNbt(uuid);
|
||||
return pl.sendMessage(tr("checkPlayer.deleteNbt.success", {name}));
|
||||
GMLIB_Player::deletePlayer(uuid);
|
||||
return pl.sendMessage(tr("checkPlayer.deletePlayer.success", {name}));
|
||||
}
|
||||
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(
|
||||
tr("form.deleteFailed.title"),
|
||||
tr("form.deleteFailed.content", {name}),
|
||||
tr("form.deleteFailed.returnCheck"),
|
||||
tr("form.returnMainForm")
|
||||
);
|
||||
fm.sendTo(pl, [uuid](Player& pl, ll::form::ModalForm::SelectedButton result) {
|
||||
if (result == ll::form::ModalForm::SelectedButton::Upper) {
|
||||
fm.sendTo(pl, [uuid](Player& pl, ll::form::ModalFormResult result, ll::form::FormCancelReason) {
|
||||
if (result == ll::form::ModalFormSelectedButton::Upper) {
|
||||
return checkPlayerForm(pl, uuid);
|
||||
}
|
||||
return mainForm(pl);
|
||||
|
||||
+5
-5
@@ -1,7 +1,7 @@
|
||||
#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.content=Please select a query mode.
|
||||
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!
|
||||
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
|
||||
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.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
|
||||
@@ -53,7 +53,7 @@ std::string defaultLanguage_en_US = R"(
|
||||
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.content=请选择查询模式
|
||||
form.main.checkOnline=查询在线玩家
|
||||
@@ -93,7 +93,7 @@ std::string defaultLanguage_zh_CN = R"(
|
||||
checkPlayer.writeInventory.failed=无法覆盖玩家 %s 的背包!\n玩家 %s 没有任何数据!
|
||||
form.confirmDelete.title=确认删除数据
|
||||
form.confirmDelete.content=你确定要删除玩家 %s 的全部数据吗?\n这包含玩家在存档的全部数据!\n不仅仅是背包!\n\n注意!\n此操作不可逆!\n请谨慎操作
|
||||
checkPlayer.deleteNbt.success=已成功删除玩家 %s 的全部数据!
|
||||
checkPlayer.deletePlayer.success=已成功将玩家 %s 从存档删除!
|
||||
form.deleteFailed.title=删除失败
|
||||
form.deleteFailed.content=玩家 %s 在线!无法删除玩家全部数据!\n\n如需删除全部玩家数据,请先将该玩家踢出游戏再操作!
|
||||
form.deleteFailed.returnCheck=返回操作界面
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"format_version": 2,
|
||||
"tooth": "github.com/GroupMountain/InventoryCheck",
|
||||
"version": "0.10.0",
|
||||
"version": "0.13.0",
|
||||
"info": {
|
||||
"name": "InventoryCheck",
|
||||
"description": "Check Player's Inventory",
|
||||
@@ -14,9 +14,9 @@
|
||||
"gmlib"
|
||||
]
|
||||
},
|
||||
"asset_url": "https://github.com/GroupMountain/InventoryCheck/releases/download/v0.10.0/InventoryCheck-windows-x64.zip",
|
||||
"asset_url": "https://github.com/GroupMountain/InventoryCheck/releases/download/v0.13.0/InventoryCheck-windows-x64.zip",
|
||||
"dependencies": {
|
||||
"github.com/GroupMountain/GMLIB": ">=0.10.x"
|
||||
"github.com/GroupMountain/GMLIB": ">=0.13.0"
|
||||
},
|
||||
"files": {
|
||||
"place": [
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
add_rules("mode.debug", "mode.release")
|
||||
|
||||
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
|
||||
set_runtimes("MD")
|
||||
@@ -8,6 +9,7 @@ end
|
||||
|
||||
-- Option 1: Use the latest version of LeviLamina released on GitHub.
|
||||
add_requires("levilamina")
|
||||
add_requires("gmlib")
|
||||
|
||||
-- Option 2: Use a specific version of LeviLamina released on GitHub.
|
||||
-- add_requires("levilamina x.x.x")
|
||||
@@ -52,15 +54,12 @@ target("InventoryCheck") -- Change this to your plugin name.
|
||||
add_files(
|
||||
"src/**.cpp"
|
||||
)
|
||||
add_links(
|
||||
"SDK-GMLIB/Lib/GMLIB"
|
||||
)
|
||||
add_includedirs(
|
||||
"SDK-GMLIB",
|
||||
"src"
|
||||
)
|
||||
add_packages(
|
||||
"levilamina"
|
||||
"levilamina",
|
||||
"gmlib"
|
||||
)
|
||||
add_shflags(
|
||||
"/DELAYLOAD:bedrock_server.dll" -- Magic to import symbols from BDS
|
||||
|
||||
Reference in New Issue
Block a user