AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Acore::ChatCommands::PlayerIdentifier Struct Reference

#include "ChatCommandTags.h"

Inheritance diagram for Acore::ChatCommands::PlayerIdentifier:
Acore::Impl::ChatCommands::ContainerTag

Public Types

using value_type = Player *
 
- Public Types inherited from Acore::Impl::ChatCommands::ContainerTag
using ChatCommandResult = Acore::Impl::ChatCommands::ChatCommandResult
 

Public Member Functions

 PlayerIdentifier ()
 
 PlayerIdentifier (Player &player)
 
 operator ObjectGuid () const
 
 operator std::string const & () const
 
 operator std::string_view () const
 
std::string const & GetName () const
 
ObjectGuid GetGUID () const
 
bool IsConnected () const
 
PlayerGetConnectedPlayer () const
 
ChatCommandResult TryConsume (ChatHandler const *handler, std::string_view args)
 

Static Public Member Functions

static Optional< PlayerIdentifierFromTarget (ChatHandler *handler)
 
static Optional< PlayerIdentifierFromSelf (ChatHandler *handler)
 
static Optional< PlayerIdentifierFromTargetOrSelf (ChatHandler *handler)
 

Private Attributes

std::string _name
 
ObjectGuid _guid
 
Player_player
 

Detailed Description

Member Typedef Documentation

◆ value_type

Constructor & Destructor Documentation

◆ PlayerIdentifier() [1/2]

Acore::ChatCommands::PlayerIdentifier::PlayerIdentifier ( )
inline
172: _name(), _guid(), _player(nullptr) {}
ObjectGuid _guid
Definition: ChatCommandTags.h:198
Player * _player
Definition: ChatCommandTags.h:199
std::string _name
Definition: ChatCommandTags.h:197

◆ PlayerIdentifier() [2/2]

Acore::ChatCommands::PlayerIdentifier::PlayerIdentifier ( Player player)
136 : _name(player.GetName()), _guid(player.GetGUID()), _player(&player) {}
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:109
std::string const & GetName() const
Definition: Object.h:458

Member Function Documentation

◆ FromSelf()

Optional< Acore::ChatCommands::PlayerIdentifier > Acore::ChatCommands::PlayerIdentifier::FromSelf ( ChatHandler handler)
static
148{
149 if (Player* player = handler->GetPlayer())
150 return { *player };
151
152 return std::nullopt;
153}
Player * GetPlayer() const
Definition: Chat.cpp:38
Definition: Player.h:1064

References ChatHandler::GetPlayer().

Referenced by instance_commandscript::HandleInstanceGetBossStateCommand(), and instance_commandscript::HandleInstanceSetBossStateCommand().

◆ FromTarget()

◆ FromTargetOrSelf()

static Optional< PlayerIdentifier > Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf ( ChatHandler handler)
inlinestatic
189 {
190 if (Optional<PlayerIdentifier> fromTarget = FromTarget(handler))
191 return fromTarget;
192 else
193 return FromSelf(handler);
194 }
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:24
static Optional< PlayerIdentifier > FromTarget(ChatHandler *handler)
Definition: ChatCommandTags.cpp:138
static Optional< PlayerIdentifier > FromSelf(ChatHandler *handler)
Definition: ChatCommandTags.cpp:147

Referenced by misc_commandscript::HandleAddItemCommand(), arena_commandscript::HandleArenaCaptainCommand(), arena_commandscript::HandleArenaCreateCommand(), cache_commandscript::HandleCacheDeleteCommand(), cache_commandscript::HandleCacheInfoCommand(), cache_commandscript::HandleCacheRefreshCommand(), character_commandscript::HandleCharacterChangeAccountCommand(), character_commandscript::HandleCharacterLevelCommand(), character_commandscript::HandleCharacterReputationCommand(), character_commandscript::HandleCharacterTitlesCommand(), misc_commandscript::HandleCombatStopCommand(), deserter_commandscript::HandleDeserterRemove(), misc_commandscript::HandleFreezeCommand(), gear_commandscript::HandleGearRepairCommand(), misc_commandscript::HandleGetDistanceCommand(), misc_commandscript::HandleGPSCommand(), group_commandscript::HandleGroupDisbandCommand(), group_commandscript::HandleGroupLeaderCommand(), group_commandscript::HandleGroupListCommand(), group_commandscript::HandleGroupRemoveCommand(), misc_commandscript::HandleGroupSummonCommand(), guild_commandscript::HandleGuildCreateCommand(), guild_commandscript::HandleGuildInfoCommand(), guild_commandscript::HandleGuildInviteCommand(), guild_commandscript::HandleGuildRankCommand(), guild_commandscript::HandleGuildUninviteCommand(), inventory_commandscript::HandleInventoryCountCommand(), misc_commandscript::HandleKickPlayerCommand(), learn_commandscript::HandleLearnAllDefaultCommand(), character_commandscript::HandleLevelUpCommand(), lfg_commandscript::HandleLfgGroupInfoCommand(), lfg_commandscript::HandleLfgPlayerInfoCommand(), misc_commandscript::HandlePInfoCommand(), player_commandscript::HandlePlayerLearnCommand(), player_commandscript::HandlePlayerUnLearnCommand(), quest_commandscript::HandleQuestAdd(), quest_commandscript::HandleQuestComplete(), quest_commandscript::HandleQuestRemove(), quest_commandscript::HandleQuestReward(), misc_commandscript::HandleRecallCommand(), reset_commandscript::HandleResetSpellsCommand(), misc_commandscript::HandleReviveCommand(), send_commandscript::HandleSendItemsCommand(), send_commandscript::HandleSendMailCommand(), send_commandscript::HandleSendMessageCommand(), send_commandscript::HandleSendMoneyCommand(), tele_commandscript::HandleTeleNameCommand(), misc_commandscript::HandleUnFreezeCommand(), misc_commandscript::HandleUnmuteCommand(), and misc_commandscript::HandleUnstuckCommand().

◆ GetConnectedPlayer()

◆ GetGUID()

◆ GetName()

std::string const & Acore::ChatCommands::PlayerIdentifier::GetName ( ) const
inline

◆ IsConnected()

bool Acore::ChatCommands::PlayerIdentifier::IsConnected ( ) const
inline
181{ return (_player != nullptr); }

◆ operator ObjectGuid()

Acore::ChatCommands::PlayerIdentifier::operator ObjectGuid ( ) const
inline
175{ return _guid; }

◆ operator std::string const &()

Acore::ChatCommands::PlayerIdentifier::operator std::string const & ( ) const
inline
176{ return _name; }

◆ operator std::string_view()

Acore::ChatCommands::PlayerIdentifier::operator std::string_view ( ) const
inline
177{ return _name; }

◆ TryConsume()

ChatCommandResult Acore::ChatCommands::PlayerIdentifier::TryConsume ( ChatHandler const *  handler,
std::string_view  args 
)
91{
92 Variant<Hyperlink<player>, ObjectGuid::LowType, std::string_view> val;
93 ChatCommandResult next = ArgInfo<decltype(val)>::TryConsume(val, handler, args);
94 if (!next)
95 return next;
96
97 if (val.holds_alternative<ObjectGuid::LowType>())
98 {
99 _guid = ObjectGuid::Create<HighGuid::Player>(val.get<ObjectGuid::LowType>());
100
102 {
103 _name = _player->GetName();
104 }
105 else if (!sCharacterCache->GetCharacterNameByGuid(_guid, _name))
106 {
108 }
109
110 return next;
111 }
112 else
113 {
114 if (val.holds_alternative<Hyperlink<player>>())
115 _name.assign(static_cast<std::string_view>(val.get<Hyperlink<player>>()));
116 else
117 _name.assign(val.get<std::string_view>());
118
121
123 {
124 _guid = _player->GetGUID();
125 }
126 else if (!(_guid = sCharacterCache->GetCharacterGuidByName(_name)))
127 {
129 }
130
131 return next;
132 }
133}
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:206
#define sCharacterCache
Definition: CharacterCache.h:83
@ LANG_CMDPARSER_CHAR_GUID_NO_EXIST
Definition: Language.h:998
@ LANG_CMDPARSER_CHAR_NAME_INVALID
Definition: Language.h:1000
@ LANG_CMDPARSER_CHAR_NAME_NO_EXIST
Definition: Language.h:999
std::string FormatAcoreString(ChatHandler const *handler, AcoreStrings which, Ts &&... args)
Definition: ChatCommandHelpers.h:126
Player * FindPlayerByLowGUID(ObjectGuid::LowType lowguid)
Definition: ObjectAccessor.cpp:254
Player * FindPlayerByName(std::string const &name, bool checkInWorld=true)
Definition: ObjectAccessor.cpp:274
Definition: ChatCommandArgs.h:50
Definition: ChatCommandHelpers.h:101
ChatCommandResult TryConsume(ChatHandler const *handler, std::string_view args)
Definition: ChatCommandTags.cpp:90
LowType GetCounter() const
Definition: ObjectGuid.h:145
std::string ToString() const
Definition: ObjectGuid.cpp:47
uint32 LowType
Definition: ObjectGuid.h:122

References ObjectAccessor::FindPlayerByLowGUID(), ObjectAccessor::FindPlayerByName(), Acore::Impl::ChatCommands::FormatAcoreString(), Acore::ChatCommands::Variant< T1, Ts >::get(), Acore::ChatCommands::Variant< T1, Ts >::holds_alternative(), LANG_CMDPARSER_CHAR_GUID_NO_EXIST, LANG_CMDPARSER_CHAR_NAME_INVALID, LANG_CMDPARSER_CHAR_NAME_NO_EXIST, normalizePlayerName(), and sCharacterCache.

Member Data Documentation

◆ _guid

ObjectGuid Acore::ChatCommands::PlayerIdentifier::_guid
private

◆ _name

std::string Acore::ChatCommands::PlayerIdentifier::_name
private

◆ _player

Player* Acore::ChatCommands::PlayerIdentifier::_player
private