Was using deprecated ChatCommand, changing to ChatCommandTable

This commit is contained in:
Flerp 2025-10-31 06:08:35 -07:00
parent 56a76bf9c2
commit 340ec5221e

View File

@ -1,16 +1,19 @@
/* /*
* MIT-style module command following AzerothCore boilerplate (std::vector<ChatCommand>) * Teleport to nearest mining node (.telenode) AzerothCore ChatCommandTable style
*/ */
#include "ScriptMgr.h" #include "ScriptMgr.h"
#include "CommandScript.h" #include "CommandScript.h"
#include "Chat.h" #include "Chat.h"
#include "ChatCommand.h"
#include "Player.h" #include "Player.h"
#include "GameObject.h" #include "GameObject.h"
#include <vector> #include <vector>
#include <limits> #include <limits>
using namespace Acore::ChatCommands;
namespace namespace
{ {
// === CONFIG === // === CONFIG ===
@ -62,10 +65,10 @@ namespace
{ {
player->TeleportTo( player->TeleportTo(
node->GetMapId(), node->GetMapId(),
node->GetPositionX(), node->GetPositionX(),
node->GetPositionY(), node->GetPositionY(),
node->GetPositionZ() + Z_BUMP, node->GetPositionZ() + Z_BUMP,
node->GetOrientation() node->GetOrientation()
); );
} }
else else
@ -81,26 +84,24 @@ class telenode_commandscript : public CommandScript
public: public:
telenode_commandscript() : CommandScript("telenode_commandscript") { } telenode_commandscript() : CommandScript("telenode_commandscript") { }
// EXACTLY like the AzerothCore boilerplate: std::vector<ChatCommand> // Match your si_commandscript style: ChatCommandTable and { name, handler, SEC, Console }
std::vector<ChatCommand> GetCommands() const override ChatCommandTable GetCommands() const override
{ {
static std::vector<ChatCommand> commandTable = static ChatCommandTable commandTable =
{ {
// { name, security, allowConsole, handler, help } { "telenode", HandleTeleNode, SEC_PLAYER, Console::No },
{ "telenode", SEC_PLAYER, false, &HandleTeleNode, "" },
}; };
return commandTable; return commandTable;
} }
static bool HandleTeleNode(ChatHandler* handler, char const* /*args*/) private:
// No-arg handler (Acore parser will pass only ChatHandler*)
static bool HandleTeleNode(ChatHandler* handler)
{ {
if (!handler) if (!handler)
return false; return false;
Player* player = nullptr; Player* player = handler->GetSession() ? handler->GetSession()->GetPlayer() : nullptr;
if (auto* session = handler->GetSession())
player = session->GetPlayer();
if (!player) if (!player)
{ {
handler->SendSysMessage("Player only."); handler->SendSysMessage("Player only.");