Was using deprecated ChatCommand, changing to ChatCommandTable
This commit is contained in:
parent
56a76bf9c2
commit
340ec5221e
@ -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 "CommandScript.h"
|
||||
#include "Chat.h"
|
||||
#include "ChatCommand.h"
|
||||
#include "Player.h"
|
||||
#include "GameObject.h"
|
||||
|
||||
#include <vector>
|
||||
#include <limits>
|
||||
|
||||
using namespace Acore::ChatCommands;
|
||||
|
||||
namespace
|
||||
{
|
||||
// === CONFIG ===
|
||||
@ -62,10 +65,10 @@ namespace
|
||||
{
|
||||
player->TeleportTo(
|
||||
node->GetMapId(),
|
||||
node->GetPositionX(),
|
||||
node->GetPositionY(),
|
||||
node->GetPositionZ() + Z_BUMP,
|
||||
node->GetOrientation()
|
||||
node->GetPositionX(),
|
||||
node->GetPositionY(),
|
||||
node->GetPositionZ() + Z_BUMP,
|
||||
node->GetOrientation()
|
||||
);
|
||||
}
|
||||
else
|
||||
@ -81,26 +84,24 @@ class telenode_commandscript : public CommandScript
|
||||
public:
|
||||
telenode_commandscript() : CommandScript("telenode_commandscript") { }
|
||||
|
||||
// EXACTLY like the AzerothCore boilerplate: std::vector<ChatCommand>
|
||||
std::vector<ChatCommand> GetCommands() const override
|
||||
// Match your si_commandscript style: ChatCommandTable and { name, handler, SEC, Console }
|
||||
ChatCommandTable GetCommands() const override
|
||||
{
|
||||
static std::vector<ChatCommand> commandTable =
|
||||
static ChatCommandTable commandTable =
|
||||
{
|
||||
// { name, security, allowConsole, handler, help }
|
||||
{ "telenode", SEC_PLAYER, false, &HandleTeleNode, "" },
|
||||
{ "telenode", HandleTeleNode, SEC_PLAYER, Console::No },
|
||||
};
|
||||
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)
|
||||
return false;
|
||||
|
||||
Player* player = nullptr;
|
||||
if (auto* session = handler->GetSession())
|
||||
player = session->GetPlayer();
|
||||
|
||||
Player* player = handler->GetSession() ? handler->GetSession()->GetPlayer() : nullptr;
|
||||
if (!player)
|
||||
{
|
||||
handler->SendSysMessage("Player only.");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user