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

Public Member Functions

 group_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 HandleGroupLeaderCommand (ChatHandler *handler, Optional< PlayerIdentifier > target)
 
static bool HandleGroupDisbandCommand (ChatHandler *handler, Optional< PlayerIdentifier > target)
 
static bool HandleGroupRemoveCommand (ChatHandler *handler, Optional< PlayerIdentifier > target)
 
static bool HandleGroupJoinCommand (ChatHandler *handler, std::string const &playerInGroup, std::string const &playerName)
 
static bool HandleGroupListCommand (ChatHandler *handler, Optional< PlayerIdentifier > target)
 

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

◆ group_commandscript()

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

Member Function Documentation

◆ GetCommands()

ChatCommandTable group_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

32 {
33 static ChatCommandTable groupCommandTable =
34 {
35 { "list", HandleGroupListCommand, SEC_GAMEMASTER, Console::Yes },
36 { "join", HandleGroupJoinCommand, SEC_GAMEMASTER, Console::No },
37 { "remove", HandleGroupRemoveCommand, SEC_GAMEMASTER, Console::No },
38 { "disband", HandleGroupDisbandCommand, SEC_GAMEMASTER, Console::No },
39 { "leader", HandleGroupLeaderCommand, SEC_GAMEMASTER, Console::No }
40 };
41
42 static ChatCommandTable commandTable =
43 {
44 { "group", groupCommandTable }
45 };
46
47 return commandTable;
48 }
@ SEC_GAMEMASTER
Definition: Common.h:59
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:46
static bool HandleGroupListCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_group.cpp:188
static bool HandleGroupRemoveCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_group.cpp:105
static bool HandleGroupJoinCommand(ChatHandler *handler, std::string const &playerInGroup, std::string const &playerName)
Definition: cs_group.cpp:132
static bool HandleGroupDisbandCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_group.cpp:78
static bool HandleGroupLeaderCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_group.cpp:50

References HandleGroupDisbandCommand(), HandleGroupJoinCommand(), HandleGroupLeaderCommand(), HandleGroupListCommand(), HandleGroupRemoveCommand(), and SEC_GAMEMASTER.

◆ HandleGroupDisbandCommand()

static bool group_commandscript::HandleGroupDisbandCommand ( ChatHandler handler,
Optional< PlayerIdentifier target 
)
inlinestatic
79 {
80 if (!target)
81 {
82 target = PlayerIdentifier::FromTargetOrSelf(handler);
83 }
84
85 if (!target || !target->IsConnected())
86 {
87 return false;
88 }
89
90 Player* player = nullptr;
91 Group* group = nullptr;
92 ObjectGuid guid;
93
94 if (handler->GetPlayerGroupAndGUIDByName(target->GetName().c_str(), player, group, guid))
95 {
96 if (group)
97 {
98 group->Disband();
99 }
100 }
101
102 return true;
103 }
bool GetPlayerGroupAndGUIDByName(const char *cname, Player *&player, Group *&group, ObjectGuid &guid, bool offline=false)
Definition: Chat.cpp:917
static Optional< PlayerIdentifier > FromTargetOrSelf(ChatHandler *handler)
Definition: ChatCommandTags.h:184
Definition: ObjectGuid.h:118
Definition: Player.h:1064
Definition: Group.h:169
void Disband(bool hideDestroy=false)
Definition: Group.cpp:751

References Group::Disband(), Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf(), and ChatHandler::GetPlayerGroupAndGUIDByName().

Referenced by GetCommands().

◆ HandleGroupJoinCommand()

static bool group_commandscript::HandleGroupJoinCommand ( ChatHandler handler,
std::string const &  playerInGroup,
std::string const &  playerName 
)
inlinestatic
133 {
134 if (playerInGroup.empty() || playerName.empty())
135 {
136 return false;
137 }
138
139 Player* playerSource = nullptr;
140 Group* groupSource = nullptr;
141 ObjectGuid guidSource;
142 ObjectGuid guidTarget;
143
144 if (handler->GetPlayerGroupAndGUIDByName(playerInGroup.c_str(), playerSource, groupSource, guidSource, true))
145 {
146 if (groupSource)
147 {
148 Group* groupTarget = nullptr;
149 Player* playerTarget = nullptr;
150
151 if (handler->GetPlayerGroupAndGUIDByName(playerName.c_str(), playerTarget, groupTarget, guidTarget, true))
152 {
153 if (!groupTarget && playerTarget->GetGroup() != groupSource)
154 {
155 if (!groupSource->IsFull())
156 {
157 groupSource->AddMember(playerTarget);
158 groupSource->BroadcastGroupUpdate();
159 handler->PSendSysMessage(LANG_GROUP_PLAYER_JOINED, playerTarget->GetName(), playerSource->GetName());
160 return true;
161 }
162 else
163 {
164 // group is full
166 return true;
167 }
168 }
169 else
170 {
171 // group is full or target player already in a group
172 handler->PSendSysMessage(LANG_GROUP_ALREADY_IN_GROUP, playerTarget->GetName());
173 return true;
174 }
175 }
176 }
177 else
178 {
179 // specified source player is not in a group
180 handler->PSendSysMessage(LANG_GROUP_NOT_IN_GROUP, playerSource->GetName());
181 return true;
182 }
183 }
184
185 return true;
186 }
@ LANG_GROUP_PLAYER_JOINED
Definition: Language.h:935
@ LANG_GROUP_NOT_IN_GROUP
Definition: Language.h:936
@ LANG_GROUP_FULL
Definition: Language.h:937
@ LANG_GROUP_ALREADY_IN_GROUP
Definition: Language.h:934
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:210
std::string const & GetName() const
Definition: Object.h:458
Group * GetGroup()
Definition: Player.h:2451
void BroadcastGroupUpdate(void)
Definition: Group.cpp:2195
bool AddMember(Player *player)
Definition: Group.cpp:388
bool IsFull() const
Definition: Group.cpp:2256

References Group::AddMember(), Group::BroadcastGroupUpdate(), Player::GetGroup(), WorldObject::GetName(), ChatHandler::GetPlayerGroupAndGUIDByName(), Group::IsFull(), LANG_GROUP_ALREADY_IN_GROUP, LANG_GROUP_FULL, LANG_GROUP_NOT_IN_GROUP, LANG_GROUP_PLAYER_JOINED, and ChatHandler::PSendSysMessage().

Referenced by GetCommands().

◆ HandleGroupLeaderCommand()

static bool group_commandscript::HandleGroupLeaderCommand ( ChatHandler handler,
Optional< PlayerIdentifier target 
)
inlinestatic
51 {
52 if (!target)
53 {
54 target = PlayerIdentifier::FromTargetOrSelf(handler);
55 }
56
57 if (!target)
58 {
59 return false;
60 }
61
62 Player* player = nullptr;
63 Group* group = nullptr;
64 ObjectGuid guid;
65
66 if (handler->GetPlayerGroupAndGUIDByName(target->GetName().c_str(), player, group, guid))
67 {
68 if (group && group->GetLeaderGUID() != guid)
69 {
70 group->ChangeLeader(guid);
71 group->SendUpdate();
72 }
73 }
74
75 return true;
76 }
void SendUpdate()
Definition: Group.cpp:1661
void ChangeLeader(ObjectGuid guid)
Definition: Group.cpp:710
ObjectGuid GetLeaderGUID() const
Definition: Group.cpp:2292

References Group::ChangeLeader(), Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf(), Group::GetLeaderGUID(), ChatHandler::GetPlayerGroupAndGUIDByName(), and Group::SendUpdate().

Referenced by GetCommands().

◆ HandleGroupListCommand()

static bool group_commandscript::HandleGroupListCommand ( ChatHandler handler,
Optional< PlayerIdentifier target 
)
inlinestatic
189 {
190 if (!target)
191 {
192 target = PlayerIdentifier::FromTargetOrSelf(handler);
193 }
194
195 if (!target)
196 {
197 return false;
198 }
199
200 Group* groupTarget = nullptr;
201
202 if (target->IsConnected())
203 {
204 groupTarget = target->GetConnectedPlayer()->GetGroup();
205 }
206
207 if (!groupTarget)
208 {
209 if (ObjectGuid groupGUID = sCharacterCache->GetCharacterGroupGuidByGuid(target->GetGUID()))
210 {
211 groupTarget = sGroupMgr->GetGroupByGUID(groupGUID.GetCounter());
212 }
213 }
214
215 if (!groupTarget)
216 {
217 handler->PSendSysMessage(LANG_GROUP_NOT_IN_GROUP, target->GetName());
218 return true;
219 }
220
221 handler->PSendSysMessage(LANG_GROUP_TYPE, (groupTarget->isRaidGroup() ? "Raid" : "Party"), groupTarget->GetMembersCount());
222
223 for (auto const& slot : groupTarget->GetMemberSlots())
224 {
225 std::string flags;
226
227 if (slot.flags & MEMBER_FLAG_ASSISTANT)
228 {
229 flags = "Assistant";
230 }
231
232 if (slot.flags & MEMBER_FLAG_MAINTANK)
233 {
234 if (!flags.empty())
235 {
236 flags.append(", ");
237 }
238
239 flags.append("MainTank");
240 }
241
242 if (slot.flags & MEMBER_FLAG_MAINASSIST)
243 {
244 if (!flags.empty())
245 {
246 flags.append(", ");
247 }
248
249 flags.append("MainAssist");
250 }
251
252 if (flags.empty())
253 {
254 flags = "None";
255 }
256 }
257
258 return true;
259 }
#define sGroupMgr
Definition: GroupMgr.h:51
@ MEMBER_FLAG_ASSISTANT
Definition: Group.h:73
@ MEMBER_FLAG_MAINASSIST
Definition: Group.h:75
@ MEMBER_FLAG_MAINTANK
Definition: Group.h:74
@ LANG_GROUP_TYPE
Definition: Language.h:938
#define sCharacterCache
Definition: CharacterCache.h:83
MemberSlotList const & GetMemberSlots() const
Definition: Group.h:242
uint32 GetMembersCount() const
Definition: Group.h:245
bool isRaidGroup() const
Definition: Group.cpp:2267

References Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf(), Group::GetMembersCount(), Group::GetMemberSlots(), Group::isRaidGroup(), LANG_GROUP_NOT_IN_GROUP, LANG_GROUP_TYPE, MEMBER_FLAG_ASSISTANT, MEMBER_FLAG_MAINASSIST, MEMBER_FLAG_MAINTANK, ChatHandler::PSendSysMessage(), sCharacterCache, and sGroupMgr.

Referenced by GetCommands().

◆ HandleGroupRemoveCommand()

static bool group_commandscript::HandleGroupRemoveCommand ( ChatHandler handler,
Optional< PlayerIdentifier target 
)
inlinestatic
106 {
107 if (!target)
108 {
109 target = PlayerIdentifier::FromTargetOrSelf(handler);
110 }
111
112 if (!target || !target->IsConnected())
113 {
114 return false;
115 }
116
117 Player* player = nullptr;
118 Group* group = nullptr;
119 ObjectGuid guid;
120
121 if (handler->GetPlayerGroupAndGUIDByName(target->GetName().c_str(), player, group, guid, true))
122 {
123 if (group)
124 {
125 group->RemoveMember(guid);
126 }
127 }
128
129 return true;
130 }
bool RemoveMember(ObjectGuid guid, const RemoveMethod &method=GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker=ObjectGuid::Empty, const char *reason=nullptr)
Definition: Group.cpp:544

References Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf(), ChatHandler::GetPlayerGroupAndGUIDByName(), and Group::RemoveMember().

Referenced by GetCommands().