Andreas Maerten 99afa8dfbb refactor!: Rewrite of the old notification service (#2866)
The main goal was improving the readability of the original code however some ugliness remains.

- Swapped from pointer singleton to instance singleton
- Actually make use of the alpha logic that used to be present
- Added a counter to notifications to indicate if something is being spammed
- Notification timeouts reset if they're sent to the queue again
2024-03-23 00:04:49 +01:00

31 lines
741 B
C++

#include "backend/player_command.hpp"
#include "natives.hpp"
namespace big
{
class host_kick : player_command
{
using player_command::player_command;
virtual CommandAccessLevel get_access_level() override
{
return CommandAccessLevel::TOXIC;
}
virtual void execute(player_ptr player, const command_arguments& _args, const std::shared_ptr<command_context> ctx) override
{
if (!player)
return;
if (!g_player_service->get_self()->is_host())
{
g_notification_service.push_error("HOST_KICK"_T.data(), "BACKEND_HOST_KICK_FAILED"_T.data());
return;
}
NETWORK::NETWORK_SESSION_KICK_PLAYER(player->id());
}
};
host_kick g_host_kick("hostkick", "HOST_KICK", "HOST_KICK_DESC", 0, false);
}