mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-18 03:15:41 +00:00
Rewrite(Core/BanManager): Rewrite Ban system (#1576)
* Added ban manager * Delete ban functions in world class * Separate ban account to (ban account, ban ip, ban character) * Support world announce
This commit is contained in:
@@ -18,6 +18,15 @@ EndScriptData */
|
||||
#include "ObjectMgr.h"
|
||||
#include "Player.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "BanManager.h"
|
||||
|
||||
/// Ban function modes
|
||||
enum BanMode
|
||||
{
|
||||
BAN_ACCOUNT,
|
||||
BAN_CHARACTER,
|
||||
BAN_IP
|
||||
};
|
||||
|
||||
class ban_commandscript : public CommandScript
|
||||
{
|
||||
@@ -33,18 +42,21 @@ public:
|
||||
{ "playeraccount", SEC_GAMEMASTER, true, &HandleUnBanAccountByCharCommand, "" },
|
||||
{ "ip", SEC_GAMEMASTER, true, &HandleUnBanIPCommand, "" }
|
||||
};
|
||||
|
||||
static std::vector<ChatCommand> banlistCommandTable =
|
||||
{
|
||||
{ "account", SEC_GAMEMASTER, true, &HandleBanListAccountCommand, "" },
|
||||
{ "character", SEC_GAMEMASTER, true, &HandleBanListCharacterCommand, "" },
|
||||
{ "ip", SEC_GAMEMASTER, true, &HandleBanListIPCommand, "" }
|
||||
};
|
||||
|
||||
static std::vector<ChatCommand> baninfoCommandTable =
|
||||
{
|
||||
{ "account", SEC_GAMEMASTER, true, &HandleBanInfoAccountCommand, "" },
|
||||
{ "character", SEC_GAMEMASTER, true, &HandleBanInfoCharacterCommand, "" },
|
||||
{ "ip", SEC_GAMEMASTER, true, &HandleBanInfoIPCommand, "" }
|
||||
};
|
||||
|
||||
static std::vector<ChatCommand> banCommandTable =
|
||||
{
|
||||
{ "account", SEC_GAMEMASTER, true, &HandleBanAccountCommand, "" },
|
||||
@@ -52,6 +64,7 @@ public:
|
||||
{ "playeraccount", SEC_GAMEMASTER, true, &HandleBanAccountByCharCommand, "" },
|
||||
{ "ip", SEC_GAMEMASTER, true, &HandleBanIPCommand, "" }
|
||||
};
|
||||
|
||||
static std::vector<ChatCommand> commandTable =
|
||||
{
|
||||
{ "ban", SEC_GAMEMASTER, true, nullptr, "", banCommandTable },
|
||||
@@ -59,6 +72,7 @@ public:
|
||||
{ "banlist", SEC_GAMEMASTER, true, nullptr, "", banlistCommandTable },
|
||||
{ "unban", SEC_GAMEMASTER, true, nullptr, "", unbanCommandTable }
|
||||
};
|
||||
|
||||
return commandTable;
|
||||
}
|
||||
|
||||
@@ -93,24 +107,28 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (sWorld->BanCharacter(name, durationStr, reasonStr, handler->GetSession() ? handler->GetSession()->GetPlayerName() : ""))
|
||||
switch (sBan->BanCharacter(name, durationStr, reasonStr, handler->GetSession() ? handler->GetSession()->GetPlayerName() : ""))
|
||||
{
|
||||
case BAN_SUCCESS:
|
||||
case BAN_SUCCESS:
|
||||
if (atoi(durationStr) > 0)
|
||||
{
|
||||
if (atoi(durationStr) > 0)
|
||||
if (!sWorld->getBoolConfig(CONFIG_SHOW_BAN_IN_WORLD))
|
||||
handler->PSendSysMessage(LANG_BAN_YOUBANNED, name.c_str(), secsToTimeString(TimeStringToSecs(durationStr), true).c_str(), reasonStr);
|
||||
else
|
||||
handler->PSendSysMessage(LANG_BAN_YOUPERMBANNED, name.c_str(), reasonStr);
|
||||
break;
|
||||
}
|
||||
case BAN_NOTFOUND:
|
||||
else
|
||||
{
|
||||
handler->PSendSysMessage(LANG_BAN_NOTFOUND, "character", name.c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
if (!sWorld->getBoolConfig(CONFIG_SHOW_BAN_IN_WORLD))
|
||||
handler->PSendSysMessage(LANG_BAN_YOUPERMBANNED, name.c_str(), reasonStr);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
case BAN_NOTFOUND:
|
||||
{
|
||||
handler->PSendSysMessage(LANG_BAN_NOTFOUND, "character", name.c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -169,13 +187,34 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (sWorld->BanAccount(mode, nameOrIP, durationStr, reasonStr, handler->GetSession() ? handler->GetSession()->GetPlayerName() : ""))
|
||||
BanReturn banReturn;
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case BAN_ACCOUNT:
|
||||
banReturn = sBan->BanAccount(nameOrIP, durationStr, reasonStr, handler->GetSession() ? handler->GetSession()->GetPlayerName() : "");
|
||||
break;
|
||||
case BAN_CHARACTER:
|
||||
banReturn = sBan->BanAccountByPlayerName(nameOrIP, durationStr, reasonStr, handler->GetSession() ? handler->GetSession()->GetPlayerName() : "");
|
||||
break;
|
||||
case BAN_IP:
|
||||
banReturn = sBan->BanIP(nameOrIP, durationStr, reasonStr, handler->GetSession() ? handler->GetSession()->GetPlayerName() : "");
|
||||
break;
|
||||
}
|
||||
|
||||
switch (banReturn)
|
||||
{
|
||||
case BAN_SUCCESS:
|
||||
if (atoi(durationStr) > 0)
|
||||
handler->PSendSysMessage(LANG_BAN_YOUBANNED, nameOrIP.c_str(), secsToTimeString(TimeStringToSecs(durationStr), true).c_str(), reasonStr);
|
||||
{
|
||||
if (!sWorld->getBoolConfig(CONFIG_SHOW_BAN_IN_WORLD))
|
||||
handler->PSendSysMessage(LANG_BAN_YOUBANNED, nameOrIP.c_str(), secsToTimeString(TimeStringToSecs(durationStr), true).c_str(), reasonStr);
|
||||
}
|
||||
else
|
||||
handler->PSendSysMessage(LANG_BAN_YOUPERMBANNED, nameOrIP.c_str(), reasonStr);
|
||||
{
|
||||
if (!sWorld->getBoolConfig(CONFIG_SHOW_BAN_IN_WORLD))
|
||||
handler->PSendSysMessage(LANG_BAN_YOUPERMBANNED, nameOrIP.c_str(), reasonStr);
|
||||
}
|
||||
break;
|
||||
case BAN_SYNTAX_ERROR:
|
||||
return false;
|
||||
@@ -197,6 +236,8 @@ public:
|
||||
case BAN_LONGER_EXISTS:
|
||||
handler->PSendSysMessage("Unsuccessful! A longer ban is already present on this account!");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -629,16 +670,16 @@ public:
|
||||
if (!nameStr)
|
||||
return false;
|
||||
|
||||
std::string name = nameStr;
|
||||
std::string CharacterName = nameStr;
|
||||
|
||||
if (!normalizePlayerName(name))
|
||||
if (!normalizePlayerName(CharacterName))
|
||||
{
|
||||
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sWorld->RemoveBanCharacter(name))
|
||||
if (!sBan->RemoveBanCharacter(CharacterName))
|
||||
{
|
||||
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
handler->SetSentErrorMessage(true);
|
||||
@@ -693,10 +734,29 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
if (sWorld->RemoveBanAccount(mode, nameOrIP))
|
||||
handler->PSendSysMessage(LANG_UNBAN_UNBANNED, nameOrIP.c_str());
|
||||
else
|
||||
handler->PSendSysMessage(LANG_UNBAN_ERROR, nameOrIP.c_str());
|
||||
switch (mode)
|
||||
{
|
||||
case BAN_ACCOUNT:
|
||||
if (sBan->RemoveBanAccount(nameOrIP))
|
||||
handler->PSendSysMessage(LANG_UNBAN_UNBANNED, nameOrIP.c_str());
|
||||
else
|
||||
handler->PSendSysMessage(LANG_UNBAN_ERROR, nameOrIP.c_str());
|
||||
break;
|
||||
case BAN_CHARACTER:
|
||||
if (sBan->RemoveBanAccountByPlayerName(nameOrIP))
|
||||
handler->PSendSysMessage(LANG_UNBAN_UNBANNED, nameOrIP.c_str());
|
||||
else
|
||||
handler->PSendSysMessage(LANG_UNBAN_ERROR, nameOrIP.c_str());
|
||||
break;
|
||||
case BAN_IP:
|
||||
if (sBan->RemoveBanIP(nameOrIP))
|
||||
handler->PSendSysMessage(LANG_UNBAN_UNBANNED, nameOrIP.c_str());
|
||||
else
|
||||
handler->PSendSysMessage(LANG_UNBAN_ERROR, nameOrIP.c_str());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user