mirror of
https://github.com/NathanHandley/mod-ah-bot-plus.git
synced 2026-01-13 09:17:21 +00:00
added chat commands for GMs
This commit is contained in:
@@ -1584,6 +1584,29 @@ void AuctionHouseBot::InitializeConfiguration()
|
||||
NeutralConfig.SetMaxItems(sConfigMgr->GetOption<uint32>("AuctionHouseBot.Neutral.MaxItems", 15000));
|
||||
}
|
||||
|
||||
void AuctionHouseBot::EmptyAuctionHouses()
|
||||
{
|
||||
vector<FactionSpecificAuctionHouseConfig> configs = { AllianceConfig, HordeConfig, NeutralConfig };
|
||||
auto trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
for (FactionSpecificAuctionHouseConfig config : configs) {
|
||||
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config.GetAHFID());
|
||||
auto auctionEntryMap = auctionHouse->GetAuctions();
|
||||
for (auto itr = auctionEntryMap.begin(); itr != auctionEntryMap.end();)
|
||||
{
|
||||
AuctionEntry* auction = itr->second;
|
||||
|
||||
auction->DeleteFromDB(trans);
|
||||
sAuctionMgr->RemoveAItem(auction->item_guid);
|
||||
auctionHouse->RemoveAuction(auction);
|
||||
|
||||
itr = auctionEntryMap.erase(itr);
|
||||
}
|
||||
}
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
}
|
||||
|
||||
uint32 AuctionHouseBot::GetRandomStackValue(std::string configKeyString, uint32 defaultValue)
|
||||
{
|
||||
uint32 stackValue = sConfigMgr->GetOption<uint32>(configKeyString, defaultValue);
|
||||
|
||||
@@ -298,6 +298,7 @@ public:
|
||||
|
||||
void Update();
|
||||
void InitializeConfiguration();
|
||||
void EmptyAuctionHouses();
|
||||
uint32 GetRandomStackValue(std::string configKeyString, uint32 defaultValue);
|
||||
uint32 GetRandomStackIncrementValue(std::string configKeyString, uint32 defaultValue);
|
||||
void SetCyclesBetweenBuyOrSell();
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
|
||||
*/
|
||||
|
||||
#include "Chat.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "AuctionHouseBot.h"
|
||||
#include "Log.h"
|
||||
@@ -118,9 +119,59 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class AHBot_CommandScript : public CommandScript
|
||||
{
|
||||
public:
|
||||
AHBot_CommandScript() : CommandScript("AHBot_CommandScript") { }
|
||||
|
||||
Acore::ChatCommands::ChatCommandTable GetCommands() const override
|
||||
{
|
||||
static Acore::ChatCommands::ChatCommandTable AHBotCommandTable = {
|
||||
{"update", HandleAHBotUpdateCommand, SEC_GAMEMASTER, Acore::ChatCommands::Console::Yes},
|
||||
{"reload", HandleAHBotReloadCommand, SEC_GAMEMASTER, Acore::ChatCommands::Console::Yes},
|
||||
{"empty", HandleAHBotEmptyCommand, SEC_GAMEMASTER, Acore::ChatCommands::Console::Yes}
|
||||
};
|
||||
|
||||
static Acore::ChatCommands::ChatCommandTable commandTable = {
|
||||
{"ahbot", AHBotCommandTable},
|
||||
};
|
||||
|
||||
return commandTable;
|
||||
}
|
||||
|
||||
static bool HandleAHBotUpdateCommand(ChatHandler* handler, const char* /*args*/)
|
||||
{
|
||||
LOG_INFO("module", "AuctionHouseBot: Updating Auction House...");
|
||||
handler->PSendSysMessage("AuctionHouseBot: Updating Auction House...");
|
||||
AuctionHouseBot::instance()->Update();
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleAHBotReloadCommand(ChatHandler* handler, char const* /*args*/)
|
||||
{
|
||||
LOG_INFO("module", "AuctionHouseBot: Reloading Config...");
|
||||
handler->PSendSysMessage("AuctionHouseBot: Reloading Config...");
|
||||
|
||||
// Reload config file with isReload = true
|
||||
sConfigMgr->LoadModulesConfigs(true, false);
|
||||
AuctionHouseBot::instance()->InitializeConfiguration();
|
||||
AuctionHouseBot::instance()->PopulateItemCandidatesAndProportions();
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleAHBotEmptyCommand(ChatHandler* handler, char const* /*args*/)
|
||||
{
|
||||
LOG_INFO("module", "AuctionHouseBot: Emptying Auction House...");
|
||||
handler->PSendSysMessage("AuctionHouseBot: Emptying Auction House...");
|
||||
AuctionHouseBot::instance()->EmptyAuctionHouses();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
void AddAHBotScripts()
|
||||
{
|
||||
new AHBot_WorldScript();
|
||||
new AHBot_AuctionHouseScript();
|
||||
new AHBot_MailScript();
|
||||
new AHBot_CommandScript();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user