From e117d37824c4e39a12985c8ddfe56e78c1c43701 Mon Sep 17 00:00:00 2001 From: Tsubasa6848 Date: Mon, 25 Mar 2024 21:38:58 +0800 Subject: [PATCH] adapt: adapt GMLIB v0.9.8 --- SDK-GMLIB | 2 +- manifest.json | 3 +++ src/Features/Clean.cpp | 9 ++------- src/Features/CleanTask.cpp | 7 ++++--- src/Features/Cleaner.cpp | 1 + src/Features/Events.cpp | 10 +++------- src/Global.h | 1 + tooth.json | 4 ++-- 8 files changed, 17 insertions(+), 20 deletions(-) diff --git a/SDK-GMLIB b/SDK-GMLIB index b1e7ebd..cda5bfb 160000 --- a/SDK-GMLIB +++ b/SDK-GMLIB @@ -1 +1 @@ -Subproject commit b1e7ebd770e667604016f93dc43359dc8212c043 +Subproject commit cda5bfbf85a291a85a78529f760883d1ca7216da diff --git a/manifest.json b/manifest.json index 6827888..ae7709a 100644 --- a/manifest.json +++ b/manifest.json @@ -2,6 +2,9 @@ "name": "${pluginName}", "entry": "${pluginFile}", "type": "native", + "version": "0.9.2", + "author": "GroupMountain", + "description": "Clean Entities", "dependencies": [ { "name": "GMLIB" diff --git a/src/Features/Clean.cpp b/src/Features/Clean.cpp index d524ae0..106d864 100644 --- a/src/Features/Clean.cpp +++ b/src/Features/Clean.cpp @@ -17,11 +17,7 @@ bool isMatch(std::string& A, std::string& B) { bool shouldIgnore(GMLIB_Actor* ac) { if (ac->isMob() || ac->isItemActor()) { - if (ac->isTame() || ac->isTrusting() || ac->getNameTag() != "") { - return true; - } - auto nbt = ac->getNbt(); - if (nbt->getByte("ShowBottom") == 1) { // End Crystal Used Only, if has this tag 1b, it is modified by cleaner. + if (ac->isTame() || ac->isTrusting() || ac->getNameTag() != "" || ac->hasTag("cleaner:ignore")) { return true; } } @@ -35,8 +31,7 @@ bool ShouldClean(Actor* actor) { return false; } auto type = en->getTypeName(); - auto tags = Config->getValue>({"IgnoreTags"}, {}); - for (auto& tag : tags) { + for (auto& tag : ConfigFile::mIgnoreTags) { if (en->hasTag(tag)) { return false; } diff --git a/src/Features/CleanTask.cpp b/src/Features/CleanTask.cpp index f775fcb..02e705d 100644 --- a/src/Features/CleanTask.cpp +++ b/src/Features/CleanTask.cpp @@ -2,9 +2,10 @@ namespace ConfigFile { -bool mConsoleLog = true; -bool mAnnounce = true; -bool mSendToast = true; +bool mConsoleLog = true; +bool mAnnounce = true; +bool mSendToast = true; +std::vector mIgnoreTags = {}; } // namespace ConfigFile diff --git a/src/Features/Cleaner.cpp b/src/Features/Cleaner.cpp index 8dfb0c6..0220c3a 100644 --- a/src/Features/Cleaner.cpp +++ b/src/Features/Cleaner.cpp @@ -16,6 +16,7 @@ void loadCleaner() { ConfigFile::mAnnounce = Config->getValue({"Basic", "SendBroadcast"}, true); ConfigFile::mConsoleLog = Config->getValue({"Basic", "ConsoleLog"}, true); ConfigFile::mSendToast = Config->getValue({"Basic", "SendToast"}, true); + ConfigFile::mIgnoreTags = Config->getValue>({"IgnoreTags"}, {}); } void unloadCleaner() { stopAllTasks(); } diff --git a/src/Features/Events.cpp b/src/Features/Events.cpp index 967f1a6..fc7f982 100644 --- a/src/Features/Events.cpp +++ b/src/Features/Events.cpp @@ -9,11 +9,7 @@ int mItemDespawnTicks = 3000; namespace Cleaner { -void setShouldIgnore(GMLIB_Actor* ac) { - auto nbt = ac->getNbt(); - nbt->put("ShowBottom", ByteTag(1)); - ac->setNbt(*nbt); -} +void setShouldIgnore(GMLIB_Actor* ac) { ac->addTag("cleaner:ignore"); } void ListenEvents() { auto& eventBus = ll::event::EventBus::getInstance(); @@ -21,8 +17,8 @@ void ListenEvents() { eventBus.emplaceListener( [](GMLIB::Event::EntityEvent::ItemActorSpawnAfterEvent& event) { auto& item = event.getItemActor(); - auto pl = (GMLIB_Player*)event.getSpawner(); - if (pl) { + if (event.getSpawner().has_value()) { + auto pl = (GMLIB_Player*)event.getSpawner().as_ptr(); if (pl->isPlayer() && !pl->isAlive()) { // Death Drop auto ac = (GMLIB_Actor*)&item; setShouldIgnore(ac); diff --git a/src/Global.h b/src/Global.h index 39ac3f9..96cb0a2 100644 --- a/src/Global.h +++ b/src/Global.h @@ -18,6 +18,7 @@ extern int mItemDespawnTicks; extern bool mConsoleLog; extern bool mAnnounce; extern bool mSendToast; +extern std::vector mIgnoreTags; } // namespace ConfigFile namespace Helper { diff --git a/tooth.json b/tooth.json index 2ba4335..9416166 100644 --- a/tooth.json +++ b/tooth.json @@ -1,7 +1,7 @@ { "format_version": 2, "tooth": "github.com/GroupMountain/Cleaner", - "version": "0.9.1", + "version": "0.9.2", "info": { "name": "Cleaner", "description": "A Powerful Entities Cleaning up Plugin for BDS", @@ -13,7 +13,7 @@ "gmlib" ] }, - "asset_url": "https://github.com/GroupMountain/Cleaner/releases/download/v0.9.1/Cleaner-windows-x64.zip", + "asset_url": "https://github.com/GroupMountain/Cleaner/releases/download/v0.9.2/Cleaner-windows-x64.zip", "dependencies": { "github.com/GroupMountain/GMLIB": ">=0.9.6" },