diff --git a/src/Command/Command.cpp b/src/Command/Command.cpp index 3e20c83..28a6e19 100644 --- a/src/Command/Command.cpp +++ b/src/Command/Command.cpp @@ -1,5 +1,6 @@ #include "Command.h" #include "Utils/Utils.h" +#include "mc/network/packet/RemoveActorPacket.h" namespace tls::command { @@ -88,9 +89,8 @@ void registerCommand() { auto item = param.player.results(origin).data; for (Player* target : *item) { if (target) { - string name = target->getRealName(); - LevelChunkPacket pkt = LevelChunkPacket(); - pkt.mCacheEnabled = true; + string name = target->getRealName(); + RemoveActorPacket pkt = RemoveActorPacket(target->getAgentID()); target->sendNetworkPacket(pkt); tls::utils::sendMsg(player, "try crash player: {}"_tr(name)); } diff --git a/src/Command/GamemodeCommand.cpp b/src/Command/GamemodeCommand.cpp index 6498730..8b0c4a5 100644 --- a/src/Command/GamemodeCommand.cpp +++ b/src/Command/GamemodeCommand.cpp @@ -8,7 +8,7 @@ using ll::command::CommandRegistrar; void registerGamemodeCommand() { #define Gm_String_Full_CallBack \ - [&](CommandOrigin const& origin, CommandOutput& output, GameMode_String_Full const& param) { \ + [](CommandOrigin const& origin, CommandOutput& output, GameMode_String_Full const& param) { \ CHECK_COMMAND_TYPE(output, origin.getOriginType(), CommandOriginType::Player); \ if (!checkPlayerPermission(origin, output, tls::perms::ChangeGameMode)) { \ output.error("You don't have permission to use this command!"_tr()); \ @@ -30,7 +30,7 @@ void registerGamemodeCommand() { } #define Gm_String_Brief_CallBack \ - [&](CommandOrigin const& origin, CommandOutput& output, GameMode_String_Brief const& param) { \ + [](CommandOrigin const& origin, CommandOutput& output, GameMode_String_Brief const& param) { \ CHECK_COMMAND_TYPE(output, origin.getOriginType(), CommandOriginType::Player); \ if (!checkPlayerPermission(origin, output, tls::perms::ChangeGameMode)) { \ output.error("You don't have permission to use this command!"_tr()); \ @@ -52,7 +52,7 @@ void registerGamemodeCommand() { } #define Gm_Int_CallBack \ - [&](CommandOrigin const& origin, CommandOutput& output, GameMode_Int const& param) { \ + [](CommandOrigin const& origin, CommandOutput& output, GameMode_Int const& param) { \ CHECK_COMMAND_TYPE(output, origin.getOriginType(), CommandOriginType::Player); \ if (!checkPlayerPermission(origin, output, tls::perms::ChangeGameMode)) { \ output.error("You don't have permission to use this command!"_tr()); \ diff --git a/src/Entry/Entry.cpp b/src/Entry/Entry.cpp index 91e04d0..3b2ee33 100644 --- a/src/Entry/Entry.cpp +++ b/src/Entry/Entry.cpp @@ -11,7 +11,6 @@ #include "Command/Command.h" #include "Entry.h" #include "File/Config.h" -#include "Form/Mapping.h" #include "Motd/Motd.h" #include "Permission/Permission.h" #include "PluginInfo.h" @@ -37,15 +36,6 @@ bool entry::load() { // print plugin info logger.info("Autor: {}"_tr(PLUGIN_AUTHOR)); - logger.info("Support Bedrock Dedicated Server Protocol {}"_tr(PLUGIN_TARGET_BDS_PROTOCOL_VERSION)); - // check server protocol version - if (ll::getServerProtocolVersion() != PLUGIN_TARGET_BDS_PROTOCOL_VERSION) { - logger.warn("The bedrock server protocol version does not match, which can lead to unexpected errors. "_tr()); - logger.warn("Current protocol version {} Adaptation protocol version {}"_tr( - ll::getServerProtocolVersion(), - PLUGIN_TARGET_BDS_PROTOCOL_VERSION - )); - } return true; } @@ -56,7 +46,6 @@ bool entry::enable() { tls::command::registerChunkCommand(); tls::command::registerGamemodeCommand(); tls::command::registerTeleportCommand(); - tls::form::initMapping(); tls::perms::initPermission(); tls::motd::initMotd(); @@ -66,9 +55,6 @@ bool entry::enable() { bool entry::disable() { getSelf().getLogger().info("Disabling..."); - // TODO: 销毁注册的权限 - // TODO: 销毁PermissionCore - return true; } diff --git a/src/Entry/PluginInfo.h b/src/Entry/PluginInfo.h index 1700dce..4b613a0 100644 --- a/src/Entry/PluginInfo.h +++ b/src/Entry/PluginInfo.h @@ -1,4 +1,2 @@ -#define PLUGIN_NAME "LeviOPTools" // 插件名 -#define PLUGIN_AUTHOR "engsr6982" // 作者 - -#define PLUGIN_TARGET_BDS_PROTOCOL_VERSION 662 // BDS协议版本 \ No newline at end of file +#define PLUGIN_NAME "LeviOPTools" +#define PLUGIN_AUTHOR "engsr6982" diff --git a/src/Form/Mapping.cpp b/src/Form/Mapping.cpp deleted file mode 100644 index bb6b28b..0000000 --- a/src/Form/Mapping.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once -#include "Mapping.h" -#include "function/include_all.h" -#include "mc/world/actor/player/Player.h" -#include -#include -#include - -namespace tls::form { - -std::unordered_map> mapping; - -bool initMapping() { - mapping["kickPlayer"] = kickPlayer; - mapping["killPlayer"] = killPlayer; - mapping["changeWeather"] = changeWeather; - mapping["changeTime"] = changeTime; - mapping["changeGameRule"] = changeGameRule; - mapping["terminal"] = terminal; - mapping["crashPlayerClient"] = crashPlayerClient; - mapping["broadCastMessage"] = broadCastMessage; - mapping["usePlayerIdentitySay"] = usePlayerIdentitySay; - mapping["usePlayerIdentityExecute"] = usePlayerIdentityExecute; - mapping["motdManagement"] = motdManagement; - mapping["getBlockOrItem"] = getBlockOrItem; - return true; -} - -} // namespace tls::form \ No newline at end of file diff --git a/src/Form/Mapping.h b/src/Form/Mapping.h index 562e9fb..8038c73 100644 --- a/src/Form/Mapping.h +++ b/src/Form/Mapping.h @@ -1,3 +1,4 @@ +#include "function/include_all.h" #include "mc/world/actor/player/Player.h" #include #include @@ -6,7 +7,19 @@ namespace tls::form { -extern std::unordered_map> mapping; -bool initMapping(); +inline static std::unordered_map> mapping = { + {"kickPlayer", kickPlayer }, + {"killPlayer", killPlayer }, + {"changeWeather", changeWeather }, + {"changeTime", changeTime }, + {"changeGameRule", changeGameRule }, + {"terminal", terminal }, + {"crashPlayerClient", crashPlayerClient }, + {"broadCastMessage", broadCastMessage }, + {"usePlayerIdentitySay", usePlayerIdentitySay }, + {"usePlayerIdentityExecute", usePlayerIdentityExecute}, + {"motdManagement", motdManagement }, + {"getBlockOrItem", getBlockOrItem } +}; } // namespace tls::form \ No newline at end of file diff --git a/src/Form/function/CrashClient.cpp b/src/Form/function/CrashClient.cpp index 4efa224..b5e10b0 100644 --- a/src/Form/function/CrashClient.cpp +++ b/src/Form/function/CrashClient.cpp @@ -1,4 +1,5 @@ #include "include_all.h" +#include "mc/network/packet/RemoveActorPacket.h" namespace tls::form { @@ -26,14 +27,12 @@ void crashPlayerClient(Player& player) { DebugFormCallBack(dt); for (auto const& [name, value] : *dt) { - if (std::holds_alternative(value)) { - auto isTrue = std::get(value); + if (std::holds_alternative(value)) { + auto isTrue = std::get(value); if (isTrue) { Player* playerPtr = ll::service::getLevel()->getPlayer(name); if (playerPtr) { - string name = playerPtr->getRealName(); - LevelChunkPacket pkt = LevelChunkPacket(); - pkt.mCacheEnabled = true; + RemoveActorPacket pkt = RemoveActorPacket(playerPtr->getAgentID()); playerPtr->sendNetworkPacket(pkt); } else { sendMsg(pl, "Failed to get player {} pointer"_tr(name)); diff --git a/src/Form/function/include_all.h b/src/Form/function/include_all.h index 2d831d9..7727659 100644 --- a/src/Form/function/include_all.h +++ b/src/Form/function/include_all.h @@ -29,6 +29,7 @@ #include "mc/network/packet/BossEventPacket.h" #include "mc/network/packet/LevelChunkPacket.h" #include "mc/network/packet/ModalFormRequestPacket.h" +#include "mc/network/packet/RemoveActorPacket.h" #include "mc/network/packet/RemoveObjectivePacket.h" #include "mc/network/packet/ScorePacketInfo.h" #include "mc/network/packet/SetDisplayObjectivePacket.h" @@ -122,7 +123,7 @@ void getBlockOrItem(Player& player); #define AutoCheckPermission(player, permission) \ { \ - if (pmc::PermissionManager::getInstance() \ + if (pmc::PermissionManager::getInstance() \ .getPermissionCore(PLUGIN_NAME) \ ->checkUserPermission(player.getUuid().asString().c_str(), permission) \ == false) \ diff --git a/src/Utils/Utils.h b/src/Utils/Utils.h index 0da25b0..b673011 100644 --- a/src/Utils/Utils.h +++ b/src/Utils/Utils.h @@ -1,3 +1,4 @@ +#pragma once #include "Entry/PluginInfo.h" #include "mc/world/actor/player/Player.h" #include diff --git a/xmake.lua b/xmake.lua index f4a102d..60dd8f1 100644 --- a/xmake.lua +++ b/xmake.lua @@ -6,7 +6,7 @@ add_repositories("liteldev-repo https://github.com/LiteLDev/xmake-repo.git") -- add_requires("levilamina develop") to use develop version -- please note that you should add bdslibrary yourself if using dev version add_requires( - "levilamina 0.12.1", + "levilamina 0.12.3", "PermissionCore" )