54 {
55 if (!target)
56 {
58 }
59
60 if (!target)
61 {
62 return false;
63 }
64
65
66 std::vector<std::pair<uint32, uint32>> itemList;
67
69 {
71
73 switch (itemTokens.size())
74 {
75 case 1:
76 itemCount = 1;
77 break;
78 case 2:
79 itemCount = *Acore::StringTo<uint32>(itemTokens.at(1));
80 break;
81 default:
83 continue;
84 }
85
86 uint32 itemID = *Acore::StringTo<uint32>(itemTokens.at(0));
87
89 if (!itemTemplate)
90 {
92 return false;
93 }
94
96 {
98 return false;
99 }
100
102 {
105 }
106
107 itemList.emplace_back(itemID, itemCount);
108
110 {
112 return false;
113 }
114 }
115
116
118
119
123
124 for (auto const& [itemID, itemCount] : itemList)
125 {
127 {
128 item->SaveToDB(trans);
129 draft.AddItem(item);
130 }
131 }
132
133 draft.SendMailTo(trans,
MailReceiver(target->GetConnectedPlayer(), target->GetGUID().GetCounter()), sender);
135
137 return true;
138 }
std::uint32_t uint32
Definition: Define.h:107
#define sObjectMgr
Definition: ObjectMgr.h:1635
@ LANG_COMMAND_INVALID_ITEM_COUNT
Definition: Language.h:84
@ LANG_COMMAND_MAIL_ITEMS_LIMIT
Definition: Language.h:85
@ LANG_MAIL_SENT
Definition: Language.h:209
@ LANG_COMMAND_ITEMIDINVALID
Definition: Language.h:467
#define MAX_MAIL_ITEMS
Definition: Mail.h:33
@ MAIL_STATIONERY_GM
Definition: Mail.h:59
@ MAIL_NORMAL
Definition: Mail.h:37
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:69
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
std::vector< std::string_view > Tokenize(std::string_view str, char sep, bool keepEmpty)
Definition: Tokenize.cpp:20
std::string StringFormat(FormatString< Args... > fmt, Args &&... args)
Default AC string format function.
Definition: StringFormat.h:34
std::string playerLink(std::string const &name) const
Definition: Chat.h:231
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:210
WorldSession * GetSession()
Definition: Chat.h:242
void SendErrorMessage(uint32 entry)
Definition: Chat.cpp:215
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:159
static Optional< PlayerIdentifier > FromTargetOrSelf(ChatHandler *handler)
Definition: ChatCommandTags.h:184
static Item * CreateItem(uint32 item, uint32 count, Player const *player=nullptr, bool clone=false, uint32 randomPropertyId=0)
Definition: Item.cpp:1087
Definition: ItemTemplate.h:619
int32 MaxCount
Definition: ItemTemplate.h:644
uint32 GetMaxStackSize() const
Definition: ItemTemplate.h:729
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:112
LowType GetCounter() const
Definition: ObjectGuid.h:145
uint32 LowType
Definition: ObjectGuid.h:122
Player * GetPlayer() const
Definition: WorldSession.h:362