AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
spectator_commandscript Class Reference
Inheritance diagram for spectator_commandscript:
CommandScript ScriptObject

Public Member Functions

 spectator_commandscript ()
 
ChatCommandTable GetCommands () const override
 
virtual std::vector< Acore::ChatCommands::ChatCommandBuilderGetCommands () const =0
 
- Public Member Functions inherited from ScriptObject
virtual bool IsDatabaseBound () const
 
virtual bool isAfterLoadScript () const
 
virtual void checkValidity ()
 
const std::string & GetName () const
 
uint16 GetTotalAvailableHooks ()
 

Static Public Member Functions

static bool HandleSpectatorCommand (ChatHandler *handler)
 
static bool HandleSpectatorVersionCommand (ChatHandler *handler, uint16 version)
 
static bool HandleSpectatorResetCommand (ChatHandler *handler)
 
static bool HandleSpectatorLeaveCommand (ChatHandler *handler)
 
static bool HandleSpectatorSpectateCommand (ChatHandler *handler, std::string const &name)
 
static bool HandleSpectatorWatchCommand (ChatHandler *handler, std::string const &name)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name, uint16 totalAvailableHooks=0)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ spectator_commandscript()

spectator_commandscript::spectator_commandscript ( )
inline
29: CommandScript("spectator_commandscript") { }
Definition: CommandScript.h:25

Member Function Documentation

◆ GetCommands()

ChatCommandTable spectator_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

32 {
33 static ChatCommandTable spectatorCommandTable =
34 {
35 { "version", HandleSpectatorVersionCommand, SEC_PLAYER, Console::No },
36 { "reset", HandleSpectatorResetCommand, SEC_PLAYER, Console::No },
37 { "spectate", HandleSpectatorSpectateCommand, SEC_PLAYER, Console::No },
38 { "watch", HandleSpectatorWatchCommand, SEC_PLAYER, Console::No },
39 { "leave", HandleSpectatorLeaveCommand, SEC_PLAYER, Console::No },
40 { "", HandleSpectatorCommand, SEC_PLAYER, Console::No }
41 };
42 static ChatCommandTable commandTable =
43 {
44 { "spect", spectatorCommandTable }
45 };
46 return commandTable;
47 }
@ SEC_PLAYER
Definition: Common.h:57
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:46
static bool HandleSpectatorLeaveCommand(ChatHandler *handler)
Definition: cs_spectator.cpp:74
static bool HandleSpectatorWatchCommand(ChatHandler *handler, std::string const &name)
Definition: cs_spectator.cpp:96
static bool HandleSpectatorResetCommand(ChatHandler *handler)
Definition: cs_spectator.cpp:65
static bool HandleSpectatorCommand(ChatHandler *handler)
Definition: cs_spectator.cpp:49
static bool HandleSpectatorVersionCommand(ChatHandler *handler, uint16 version)
Definition: cs_spectator.cpp:58
static bool HandleSpectatorSpectateCommand(ChatHandler *handler, std::string const &name)
Definition: cs_spectator.cpp:88

References HandleSpectatorCommand(), HandleSpectatorLeaveCommand(), HandleSpectatorResetCommand(), HandleSpectatorSpectateCommand(), HandleSpectatorVersionCommand(), HandleSpectatorWatchCommand(), and SEC_PLAYER.

◆ HandleSpectatorCommand()

static bool spectator_commandscript::HandleSpectatorCommand ( ChatHandler handler)
inlinestatic
50 {
51 handler->PSendSysMessage("Incorrect syntax.");
52 handler->PSendSysMessage("Command has subcommands:");
53 handler->PSendSysMessage(" spectate");
54 handler->PSendSysMessage(" leave");
55 return true;
56 }
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:210

References ChatHandler::PSendSysMessage().

Referenced by GetCommands().

◆ HandleSpectatorLeaveCommand()

static bool spectator_commandscript::HandleSpectatorLeaveCommand ( ChatHandler handler)
inlinestatic
75 {
76 Player* player = handler->GetSession()->GetPlayer();
77 if (!player->IsSpectator() || !player->FindMap() || !player->FindMap()->IsBattleArena())
78 {
79 handler->SendSysMessage("You are not a spectator.");
80 return true;
81 }
82
83 //player->SetIsSpectator(false);
84 player->TeleportToEntryPoint();
85 return true;
86 }
WorldSession * GetSession()
Definition: Chat.h:242
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:159
Map * FindMap() const
Definition: Object.h:532
Definition: Player.h:1064
bool TeleportToEntryPoint()
Definition: Player.cpp:1598
bool IsSpectator() const
Definition: Player.h:2559
bool IsBattleArena() const
Definition: Map.h:453
Player * GetPlayer() const
Definition: WorldSession.h:362

References WorldObject::FindMap(), WorldSession::GetPlayer(), ChatHandler::GetSession(), Map::IsBattleArena(), Player::IsSpectator(), ChatHandler::SendSysMessage(), and Player::TeleportToEntryPoint().

Referenced by GetCommands().

◆ HandleSpectatorResetCommand()

static bool spectator_commandscript::HandleSpectatorResetCommand ( ChatHandler handler)
inlinestatic
66 {
67 Player* p = handler->GetSession()->GetPlayer();
68 if (!p->IsSpectator())
69 return true;
71 return true;
72 }
AC_GAME_API void HandleResetCommand(Player *player)
Definition: ArenaSpectator.cpp:226

References WorldSession::GetPlayer(), ChatHandler::GetSession(), ArenaSpectator::HandleResetCommand(), and Player::IsSpectator().

Referenced by GetCommands().

◆ HandleSpectatorSpectateCommand()

static bool spectator_commandscript::HandleSpectatorSpectateCommand ( ChatHandler handler,
std::string const &  name 
)
inlinestatic
89 {
91 return false;
92
93 return true;
94 }
AC_GAME_API bool HandleSpectatorSpectateCommand(ChatHandler *handler, std::string const &name)
Definition: ArenaSpectator.cpp:28

References ArenaSpectator::HandleSpectatorSpectateCommand().

Referenced by GetCommands().

◆ HandleSpectatorVersionCommand()

static bool spectator_commandscript::HandleSpectatorVersionCommand ( ChatHandler handler,
uint16  version 
)
inlinestatic
59 {
60 if (version < SPECTATOR_ADDON_VERSION)
62 return true;
63 }
#define SPECTATOR_ADDON_PREFIX
Definition: ArenaSpectator.h:35
#define SPECTATOR_ADDON_VERSION
Definition: ArenaSpectator.h:33
void SendCommand(T *o, Format &&fmt, Args &&... args)
Definition: ArenaSpectator.h:47

References WorldSession::GetPlayer(), ChatHandler::GetSession(), ArenaSpectator::SendCommand(), SPECTATOR_ADDON_PREFIX, and SPECTATOR_ADDON_VERSION.

Referenced by GetCommands().

◆ HandleSpectatorWatchCommand()

static bool spectator_commandscript::HandleSpectatorWatchCommand ( ChatHandler handler,
std::string const &  name 
)
inlinestatic
97 {
99 return false;
100
101 return true;
102 }
AC_GAME_API bool HandleSpectatorWatchCommand(ChatHandler *handler, std::string const &name)
Definition: ArenaSpectator.cpp:176

References ArenaSpectator::HandleSpectatorWatchCommand().

Referenced by GetCommands().