Compare commits
34 Commits
+42
-22
@@ -6,34 +6,54 @@ on:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-latest
|
||||
env:
|
||||
XMAKE_BINARY_REPO: https://gitee.com/xmake-mirror/build-artifacts.git
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
- name: Checkout
|
||||
uses: https://github.bibk.top/actions/checkout@v4
|
||||
|
||||
- name: Setup XMake
|
||||
uses: https://git.soulmc.cn/wed15/github-action-setup-xmake@v1
|
||||
|
||||
- name: Cache
|
||||
uses: https://github.bibk.top/actions/cache@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
path: |
|
||||
~/AppData/Local/.xmake
|
||||
key: xmake-${{ hashFiles('xmake.lua') }}
|
||||
restore-keys: |
|
||||
xmake-
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
- name: Configure Mirror
|
||||
run: |
|
||||
$fileName = "github_mirror.lua"
|
||||
$currentDir = Get-Location
|
||||
$absoluteFilePath = Join-Path $currentDir $fileName
|
||||
$luaContent = @'
|
||||
function mirror(url)
|
||||
url = url:gsub("github.com", "github.bibk.top")
|
||||
return url
|
||||
end
|
||||
function main(url, host)
|
||||
return true
|
||||
end
|
||||
'@
|
||||
$luaContent | Out-File -FilePath $absoluteFilePath -Encoding utf8
|
||||
Write-Host "Mirror config generated at: $absoluteFilePath"
|
||||
xmake g --proxy_pac=$absoluteFilePath
|
||||
shell: powershell
|
||||
|
||||
- uses: xmake-io/github-action-setup-xmake@v1
|
||||
with:
|
||||
xmake-version: branch@master
|
||||
- run: |
|
||||
xmake repo -u
|
||||
- name: Update Repo
|
||||
run: xmake repo -u
|
||||
|
||||
- run: |
|
||||
xmake f -a x64 -m release -p windows -v -y
|
||||
- name: Update Project
|
||||
run: xmake f -a x64 -m release -p windows -v -y
|
||||
|
||||
- run: |
|
||||
xmake -w -y
|
||||
- name: Build Project
|
||||
run: xmake -v -y
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
- name: Upload Artifact
|
||||
uses: https://github.bibk.top/actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
|
||||
path: |
|
||||
bin/DLL/
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: PDB
|
||||
path: |
|
||||
bin/PDB/
|
||||
path: bin/
|
||||
@@ -6,37 +6,58 @@ on:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-latest
|
||||
env:
|
||||
XMAKE_BINARY_REPO: https://gitee.com/xmake-mirror/build-artifacts.git
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
- name: Checkout
|
||||
uses: https://github.bibk.top/actions/checkout@v4
|
||||
|
||||
- name: Setup XMake
|
||||
uses: https://git.soulmc.cn/wed15/github-action-setup-xmake@v1
|
||||
|
||||
- name: Cache
|
||||
uses: https://github.bibk.top/actions/cache@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
path: |
|
||||
~/AppData/Local/.xmake
|
||||
key: xmake-${{ hashFiles('xmake.lua') }}
|
||||
restore-keys: |
|
||||
xmake-
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
- name: Configure Mirror
|
||||
run: |
|
||||
$fileName = "github_mirror.lua"
|
||||
$currentDir = Get-Location
|
||||
$absoluteFilePath = Join-Path $currentDir $fileName
|
||||
$luaContent = @'
|
||||
function mirror(url)
|
||||
url = url:gsub("github.com", "github.bibk.top")
|
||||
return url
|
||||
end
|
||||
function main(url, host)
|
||||
return true
|
||||
end
|
||||
'@
|
||||
$luaContent | Out-File -FilePath $absoluteFilePath -Encoding utf8
|
||||
Write-Host "Mirror config generated at: $absoluteFilePath"
|
||||
xmake g --proxy_pac=$absoluteFilePath
|
||||
shell: powershell
|
||||
|
||||
- uses: xmake-io/github-action-setup-xmake@v1
|
||||
with:
|
||||
xmake-version: branch@master
|
||||
- run: |
|
||||
xmake repo -u
|
||||
- name: Update Repo
|
||||
run: xmake repo -u
|
||||
|
||||
- run: |
|
||||
xmake f -a x64 -m release -p windows -v -y
|
||||
- name: Update Project
|
||||
run: xmake f -a x64 -m release -p windows -v -y
|
||||
|
||||
- run: |
|
||||
xmake -w -y
|
||||
- name: Build Project
|
||||
run: xmake -v -y
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
- name: Upload Artifact
|
||||
uses: https://github.bibk.top/actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
|
||||
path: |
|
||||
bin/DLL/
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: PDB
|
||||
path: |
|
||||
bin/PDB/
|
||||
bin/
|
||||
|
||||
upload-to-release:
|
||||
needs:
|
||||
@@ -45,35 +66,26 @@ jobs:
|
||||
contents: write
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- name: Checkout
|
||||
uses: https://github.bibk.top/actions/checkout@v4
|
||||
|
||||
- name: Download Mod
|
||||
uses: actions/download-artifact@v3
|
||||
- name: Download Artifact
|
||||
uses: https://github.bibk.top/actions/download-artifact@v3
|
||||
with:
|
||||
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
|
||||
path: release/Mod/
|
||||
path: artifact
|
||||
|
||||
- name: Download PDB
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: PDB
|
||||
path: release/PDB/
|
||||
|
||||
- name: Copy additional files
|
||||
- name: Copy Files
|
||||
run: |
|
||||
cp LICENSE README.md release/Mod/
|
||||
cp LICENSE README.md artifact/
|
||||
|
||||
- name: Archive release
|
||||
- name: Compress Artifact
|
||||
run: |
|
||||
cd release/Mod
|
||||
zip -r ../${{ github.event.repository.name }}-windows-x64.zip *
|
||||
cd ..
|
||||
working-directory: artifact
|
||||
|
||||
- name: Create GitHub Release
|
||||
id: create_release
|
||||
uses: softprops/action-gh-release@v1
|
||||
- name: Create Release
|
||||
uses: https://github.bibk.top/softprops/action-gh-release@v1
|
||||
with:
|
||||
files: |
|
||||
release/${{ github.event.repository.name }}-windows-x64.zip
|
||||
release/PDB/${{ github.event.repository.name }}.pdb
|
||||
${{ github.event.repository.name }}-windows-x64.zip
|
||||
|
||||
@@ -16,3 +16,4 @@ build/
|
||||
/CMakeLists.txt
|
||||
/bin
|
||||
.cache/clangd/index
|
||||
/.idea
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "${modName}",
|
||||
"entry": "${modFile}",
|
||||
"version": "0.13.1",
|
||||
"version": "0.16.1",
|
||||
"author": "GroupMountain",
|
||||
"description": "Check Player's Inventory",
|
||||
"type": "native",
|
||||
|
||||
+12
-4
@@ -1,18 +1,26 @@
|
||||
#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() {
|
||||
auto& cmd = ll::command::CommandRegistrar::getInstance().getOrCreateCommand(
|
||||
auto& cmd = ll::command::CommandRegistrar::getInstance(false).getOrCreateCommand(
|
||||
"inventorycheck",
|
||||
tr("command.inventorycheck.desc"),
|
||||
CommandPermissionLevel::GameDirectors
|
||||
);
|
||||
ll::service::getCommandRegistry()->registerAlias("inventorycheck", "ic");
|
||||
cmd.overload().execute<[&](CommandOrigin const& origin, CommandOutput& output) {
|
||||
auto entity = (GMLIB_Actor*)origin.getEntity();
|
||||
cmd.overload().execute([](CommandOrigin const& origin, CommandOutput& output) {
|
||||
auto entity = (gmlib::GMActor*)origin.getEntity();
|
||||
if (entity && entity->isPlayer()) {
|
||||
auto pl = (Player*)entity;
|
||||
return mainForm(*pl);
|
||||
}
|
||||
return output.error(tr("command.error.console"));
|
||||
}>();
|
||||
});
|
||||
}
|
||||
+21
-17
@@ -2,12 +2,21 @@
|
||||
#include "Global.h"
|
||||
#include "Language.h"
|
||||
|
||||
ll::Logger logger(MOD_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 {
|
||||
|
||||
std::unique_ptr<Entry>& Entry::getInstance() {
|
||||
static std::unique_ptr<Entry> instance;
|
||||
Entry& Entry::getInstance() {
|
||||
static Entry instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
@@ -20,21 +29,19 @@ bool Entry::load() {
|
||||
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())})
|
||||
);
|
||||
|
||||
if (ll::getNetworkProtocolVersion() != TARGET_PROTOCOL) {
|
||||
getSelf().getLogger().error(tr("error.protocolMismatch.info"));
|
||||
getSelf().getLogger().error(tr("error.protocolMismatch.version", {std::to_string(ll::getNetworkProtocolVersion()), std::to_string(TARGET_PROTOCOL)}));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
;
|
||||
|
||||
bool Entry::enable() {
|
||||
RegisterCommand();
|
||||
logger.info("InventoryCheck Loaded!");
|
||||
logger.info("Author: GroupMountain");
|
||||
logger.info("Repository: https://github.com/GroupMountain/InventoryCheck");
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -43,10 +50,7 @@ bool Entry::disable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Entry::unload() {
|
||||
getInstance().reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Config& Entry::getConfig() { return mConfig.value(); }
|
||||
|
||||
@@ -57,5 +61,5 @@ LangI18n& Entry::getI18n() { return mI18n.value(); }
|
||||
LL_REGISTER_MOD(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);
|
||||
return InventoryCheck::Entry::getInstance().getI18n().get(key, data);
|
||||
}
|
||||
+10
-4
@@ -3,17 +3,21 @@
|
||||
|
||||
#include "Config.h"
|
||||
#include "Global.h"
|
||||
#include "gmlib/gm/i18n/LangI18n.h"
|
||||
|
||||
#include "gmlib/gm/data/UserCache.h"
|
||||
#include <memory>
|
||||
|
||||
namespace InventoryCheck {
|
||||
|
||||
using namespace GMLIB::Files::I18n;
|
||||
using namespace gmlib::i18n;
|
||||
|
||||
class Entry {
|
||||
|
||||
public:
|
||||
static std::unique_ptr<Entry>& getInstance();
|
||||
static Entry& getInstance();
|
||||
|
||||
Entry(ll::mod::NativeMod& self) : mSelf(self) {}
|
||||
Entry() : mSelf((*ll::mod::NativeMod::current())) {}
|
||||
|
||||
[[nodiscard]] ll::mod::NativeMod& getSelf() const { return mSelf; }
|
||||
|
||||
@@ -27,12 +31,14 @@ public:
|
||||
bool disable();
|
||||
|
||||
/// @return True if the mod is unloaded successfully.
|
||||
bool unload();
|
||||
|
||||
Config& getConfig();
|
||||
|
||||
LangI18n& getI18n();
|
||||
|
||||
std::vector<gmlib::UserCache::UserCacheEntry> userCache;
|
||||
|
||||
|
||||
private:
|
||||
ll::mod::NativeMod& mSelf;
|
||||
std::optional<Config> mConfig;
|
||||
|
||||
+5
-3
@@ -2,12 +2,14 @@
|
||||
|
||||
#include <span>
|
||||
|
||||
#include <include_all.h>
|
||||
#include "mc/world/actor/player/Player.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#define MOD_NAME "InventoryCheck"
|
||||
#define TARGET_PROTOCOL 686
|
||||
#define TARGET_PROTOCOL 944
|
||||
|
||||
extern ll::Logger logger;
|
||||
|
||||
extern std::string tr(std::string const& key, std::vector<std::string> const& data = {});
|
||||
|
||||
|
||||
+108
-26
@@ -1,42 +1,92 @@
|
||||
#include "Global.h"
|
||||
#include "Entry.h"
|
||||
|
||||
bool saveInventory(Player& player) {
|
||||
auto& pl = static_cast<GMLIB_Player&>(player);
|
||||
#include <filesystem>
|
||||
#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();
|
||||
ll::file_utils::writeFile(
|
||||
"./plugins/InventoryCheck/save/" + uuid.asString() + ".dat",
|
||||
pl.getNbt()->toBinaryNbt(),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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) {
|
||||
auto& pl = static_cast<GMLIB_Player&>(player);
|
||||
auto& pl = static_cast<gmlib::GMPlayer&>(player);
|
||||
auto uuid = pl.getUuid();
|
||||
std::string path = "./plugins/InventoryCheck/save/" + uuid.asString() + ".dat";
|
||||
if (auto binaryData = ll::file_utils::readFile(path, true)) {
|
||||
std::filesystem::remove(path);
|
||||
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 false;
|
||||
}
|
||||
|
||||
|
||||
void mainForm(Player& pl) {
|
||||
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.checkAll"), [](Player& pl) { return checkAllForm(pl); });
|
||||
fm.appendButton(tr("form.main.searchPlayer"), [](Player& pl) { return searchPlayerForm(pl); });
|
||||
fm.appendButton(tr("form.main.resumeInventory"), [](Player& pl) {
|
||||
auto res = resumeInventory(pl);
|
||||
if (res) {
|
||||
return pl.sendMessage(tr("resumeInventory.success"));
|
||||
}
|
||||
return pl.sendMessage(tr("resumeInventory.failed"));
|
||||
pl.sendMessage(resumeInventory(pl)
|
||||
? tr("resumeInventory.success")
|
||||
: tr("resumeInventory.failed"));
|
||||
});
|
||||
fm.sendTo(pl);
|
||||
}
|
||||
@@ -44,7 +94,7 @@ void mainForm(Player& pl) {
|
||||
void checkOnlineForm(Player& pl) {
|
||||
auto fm = ll::form::SimpleForm(tr("form.checkList.title"), tr("form.checkList.content"));
|
||||
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()) {
|
||||
onlineList[pl.getUuid()] = pl.getRealName();
|
||||
}
|
||||
@@ -66,19 +116,25 @@ void checkOnlineForm(Player& pl) {
|
||||
}
|
||||
|
||||
std::string getNameFormUuid(mce::UUID const& uuid) {
|
||||
auto player = GMLIB_Level::getLevel()->getPlayer(uuid);
|
||||
auto player = ll::service::getLevel()->getPlayer(uuid);
|
||||
std::string name;
|
||||
if (player) {
|
||||
name = player->getRealName();
|
||||
} else {
|
||||
auto cache = GMLIB::UserCache::getNameByUuid(uuid);
|
||||
name = cache ? cache.value() : uuid.asString();
|
||||
auto cache = ll::service::PlayerInfo::getInstance().fromUuid(uuid);
|
||||
name = cache ? cache->name : uuid.asString();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
std::unordered_map<mce::UUID, std::string> generateUuidMap() {
|
||||
auto allUuids = GMLIB_Player::getAllUuids();
|
||||
std::vector<mce::UUID> allUuids;
|
||||
for (const auto& entry : ll::service::PlayerInfo::getInstance().entries()) {
|
||||
allUuids.push_back(entry.uuid);
|
||||
}
|
||||
for (const auto& player : ll::service::getLevel()->getPlayerList()) {
|
||||
allUuids.push_back(player.first);
|
||||
}
|
||||
std::unordered_map<mce::UUID, std::string> allList;
|
||||
for (auto& uuid : allUuids) {
|
||||
auto name = getNameFormUuid(uuid);
|
||||
@@ -175,19 +231,41 @@ void searchNotFoundForm(Player& pl, std::string const& name) {
|
||||
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) {
|
||||
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) {
|
||||
saveInventory(pl);
|
||||
auto nbt = GMLIB_Player::getPlayerNbt(uuid);
|
||||
if (!nbt) {
|
||||
auto nbt =getNBTptr(uuid);
|
||||
auto playerNbt=getNBTptr(pl.getUuid());
|
||||
if ((!nbt)||(!playerNbt)) {
|
||||
|
||||
return pl.sendMessage(tr("checkPlayer.copyInventory.failed", {name}));
|
||||
}
|
||||
auto& self = static_cast<GMLIB_Player&>(pl);
|
||||
GMLIB_Player::setPlayerNbtTags(pl.getUuid(), *nbt, {"Offhand", "Inventory", "Armor", "EnderChestInventory"});
|
||||
return pl.sendMessage(tr("checkPlayer.copyInventory.success", {name}));
|
||||
for (auto key : InvKey)
|
||||
playerNbt->mTags[key] = nbt->at(key);
|
||||
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) {
|
||||
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) {
|
||||
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 targetNbt = GMLIB_Player::getPlayerNbt(uuid);
|
||||
auto targetNbt = getNBTptr(uuid);
|
||||
if (!targetNbt) {
|
||||
return pl.sendMessage(tr("checkPlayer.writeInventory.failed", {name}));
|
||||
}
|
||||
GMLIB_Player::setPlayerNbtTags(uuid, *nbt, {"Offhand", "Inventory", "Armor", "EnderChestInventory"});
|
||||
return pl.sendMessage(tr("checkPlayer.writeInventory.success", {name}));
|
||||
for (auto key : InvKey)
|
||||
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);
|
||||
});
|
||||
@@ -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) {
|
||||
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);
|
||||
}
|
||||
GMLIB_Player::deletePlayer(uuid);
|
||||
gmlib::OfflinePlayer::deletePlayerNbt(uuid);
|
||||
return pl.sendMessage(tr("checkPlayer.deletePlayer.success", {name}));
|
||||
}
|
||||
return checkPlayerForm(pl, uuid);
|
||||
|
||||
+5
-1
@@ -33,12 +33,14 @@ std::string en_US = R"(
|
||||
command.inventorycheck.desc=Check player inventory.
|
||||
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.setFailed=CANNOT to copy player %s's backpack to yours!
|
||||
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.confirmAction=Confirm
|
||||
form.cancelAction=Cancel
|
||||
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.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!
|
||||
@@ -85,12 +87,14 @@ std::string zh_CN = R"(
|
||||
command.inventorycheck.desc=查询玩家背包
|
||||
checkPlayer.copyInventory.success=已成功将玩家 %s 的背包复制到你的背包!
|
||||
checkPlayer.copyInventory.failed=无法将玩家 %s 的背包复制到你的背包!\n玩家 %s 没有任何数据!
|
||||
checkPlayer.copyInventory.setFailed=无法将玩家 %s 的背包复制到你的背包!
|
||||
form.confirmWrite.title=确认覆盖背包
|
||||
form.confirmWrite.content=你确定要用你的背包覆盖玩家 %s 的背包吗?\n\n注意!\n此操作不可逆!
|
||||
form.confirmAction=确认操作
|
||||
form.cancelAction=我再想想
|
||||
checkPlayer.writeInventory.success=已成功覆盖玩家 %s 的背包!
|
||||
checkPlayer.writeInventory.failed=无法覆盖玩家 %s 的背包!\n玩家 %s 没有任何数据!
|
||||
checkPlayer.writeInventory.setFailed=无法覆盖玩家 %s 的背包!
|
||||
form.confirmDelete.title=确认删除数据
|
||||
form.confirmDelete.content=你确定要删除玩家 %s 的全部数据吗?\n这包含玩家在存档的全部数据!\n不仅仅是背包!\n\n注意!\n此操作不可逆!\n请谨慎操作
|
||||
checkPlayer.deletePlayer.success=已成功将玩家 %s 从存档删除!
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
# 1. 定义文件名
|
||||
$fileName = "github_mirror.lua"
|
||||
|
||||
# 2. 获取当前工作目录的绝对路径 (例如: D:\a\your-repo\your-repo)
|
||||
$currentDir = Get-Location
|
||||
|
||||
# 3. 拼接出绝对文件路径 (例如: D:\a\your-re_repo\your-repo\github_mirror.lua)
|
||||
$absoluteFilePath = Join-Path $currentDir $fileName
|
||||
|
||||
# 4. 定义 Lua 脚本内容
|
||||
$luaContent = @'
|
||||
function mirror(url)
|
||||
-- 强制将 github.com 替换为镜像域名
|
||||
url = url:gsub("github.com", "github.bibk.top")
|
||||
return url
|
||||
end
|
||||
|
||||
-- main 函数允许处理该 URL
|
||||
function main(url, host)
|
||||
return true
|
||||
end
|
||||
'@
|
||||
|
||||
# 5. 使用绝对路径写入文件
|
||||
$luaContent | Out-File -FilePath $absoluteFilePath -Encoding utf8
|
||||
|
||||
# 6. 输出调试信息 (可选,确认路径是否正确)
|
||||
Write-Host "Mirror config generated at: $absoluteFilePath"
|
||||
|
||||
# 7. 配置 Xmake 使用该绝对路径的配置文件
|
||||
xmake g --proxy_pac=$absoluteFilePath
|
||||
+24
-10
@@ -1,29 +1,43 @@
|
||||
{
|
||||
"format_version": 2,
|
||||
"format_version": 3,
|
||||
"format_uuid": "289f771f-2c9a-4d73-9f3f-8492495a924d",
|
||||
"tooth": "github.com/GroupMountain/InventoryCheck",
|
||||
"version": "0.13.1",
|
||||
"version": "0.16.0",
|
||||
"info": {
|
||||
"name": "InventoryCheck",
|
||||
"description": "Check Player's Inventory",
|
||||
"author": "GroupMountain",
|
||||
"source": "github.com/GroupMountain/InventoryCheck",
|
||||
"tags": [
|
||||
"levilamina",
|
||||
"inventory",
|
||||
"platform:levilamina",
|
||||
"type:mod",
|
||||
"checkbag",
|
||||
"gmlib"
|
||||
]
|
||||
},
|
||||
"asset_url": "https://github.com/GroupMountain/InventoryCheck/releases/download/v0.13.1/InventoryCheck-windows-x64.zip",
|
||||
"dependencies": {
|
||||
"github.com/GroupMountain/GMLIB": ">=0.13.7"
|
||||
},
|
||||
"files": {
|
||||
"place": [
|
||||
|
||||
"variants": [
|
||||
{
|
||||
"platform": "win-x64",
|
||||
"dependencies": {
|
||||
"github.com/GroupMountain/GMLIB-Release": ">=26.10.0"
|
||||
},
|
||||
"assets": [
|
||||
{
|
||||
"type": "self",
|
||||
"urls": [],
|
||||
"placements": [
|
||||
{
|
||||
"type": "dir",
|
||||
"src": "InventoryCheck/*",
|
||||
"dest": "plugins/InventoryCheck"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"remove_files": [
|
||||
"plugins/InventoryCheck"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -2,80 +2,25 @@ 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")
|
||||
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
|
||||
set_runtimes("MD")
|
||||
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")
|
||||
|
||||
-- Option 3: Use the latest commit of LeviLamina on GitHub.
|
||||
-- -- 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 mod name.
|
||||
add_cxflags(
|
||||
"/EHa",
|
||||
"/utf-8"
|
||||
)
|
||||
add_defines(
|
||||
"NOMINMAX",
|
||||
"UNICODE"
|
||||
)
|
||||
add_files(
|
||||
"src/**.cpp"
|
||||
)
|
||||
add_includedirs(
|
||||
"src"
|
||||
)
|
||||
add_packages(
|
||||
"levilamina",
|
||||
"gmlib"
|
||||
)
|
||||
add_shflags(
|
||||
"/DELAYLOAD:bedrock_server.dll" -- Magic to import symbols from BDS
|
||||
)
|
||||
set_exceptions("none") -- To avoid conflicts with /EHa
|
||||
target("InventoryCheck")
|
||||
add_rules("@levibuildscript/linkrule")
|
||||
add_rules("@levibuildscript/modpacker")
|
||||
add_cxflags( "/EHa", "/utf-8", "/W4", "/w44265", "/w44289", "/w44296", "/w45263", "/w44738", "/w45204")
|
||||
add_defines("NOMINMAX", "UNICODE")
|
||||
add_packages("levilamina","gmlib")
|
||||
set_exceptions("none") -- To avoid conflicts with /EHa.
|
||||
set_kind("shared")
|
||||
set_languages("c++23")
|
||||
set_symbols("debug")
|
||||
|
||||
after_build(function (target)
|
||||
local mod_packer = import("scripts.after_build")
|
||||
|
||||
local mod_define = {
|
||||
modName = target:name(),
|
||||
modFile = path.filename(target:targetfile()),
|
||||
}
|
||||
|
||||
mod_packer.pack_mod(target,mod_define)
|
||||
end)
|
||||
add_headerfiles("src/**.h")
|
||||
add_files("src/**.cpp")
|
||||
add_includedirs("src")
|
||||
|
||||
Reference in New Issue
Block a user