TrinityCore
Loading...
Searching...
No Matches
cs_bg.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "Battleground.h"
19#include "Chat.h"
20#include "ChatCommand.h"
21#include "Language.h"
22#include "Player.h"
23#include "RBAC.h"
24#include "ScriptMgr.h"
25
26using namespace Trinity::ChatCommands;
27
29{
30public:
31 bg_commandscript() : CommandScript("bg_commandscript") { }
32
33 std::span<ChatCommandBuilder const> GetCommands() const override
34 {
35 static ChatCommandTable commandTable =
36 {
39 };
40 return commandTable;
41 }
42
43 static bool HandleBgStartCommand(ChatHandler* handler)
44 {
45 Battleground* bg = handler->GetPlayer()->GetBattleground();
46 if (!bg)
47 {
49 handler->SetSentErrorMessage(true);
50 return false;
51 }
52
53 bg->SetStartDelayTime(0);
54
55 return true;
56 }
57
58 static bool HandleBgStopCommand(ChatHandler* handler)
59 {
60 Battleground* bg = handler->GetPlayer()->GetBattleground();
61 if (!bg)
62 {
64 handler->SetSentErrorMessage(true);
65 return false;
66 }
67
69
70 return true;
71 }
72};
73
@ LANG_COMMAND_BG_STOP_HELP
Definition Language.h:451
@ LANG_COMMAND_BG_START_HELP
Definition Language.h:450
@ LANG_COMMAND_NO_BATTLEGROUND_FOUND
Definition Language.h:1097
Role Based Access Control related classes definition.
@ TEAM_OTHER
virtual void EndBattleground(Team winner)
void SetStartDelayTime(int Time)
void SetSentErrorMessage(bool val)
Definition Chat.h:127
Player * GetPlayer() const
Definition Chat.cpp:37
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:111
Battleground * GetBattleground() const
Definition Player.cpp:25650
std::span< ChatCommandBuilder const > GetCommands() const override
Definition cs_bg.cpp:33
static bool HandleBgStartCommand(ChatHandler *handler)
Definition cs_bg.cpp:43
static bool HandleBgStopCommand(ChatHandler *handler)
Definition cs_bg.cpp:58
void AddSC_bg_commandscript()
Definition cs_bg.cpp:74
ChatCommandBuilder const [] ChatCommandTable
Definition ChatCommand.h:49
@ RBAC_PERM_COMMAND_BG_STOP
Definition RBAC.h:755
@ RBAC_PERM_COMMAND_BG_START
Definition RBAC.h:754