mirror of
https://github.com/YimMenu/YimMenuV2.git
synced 2026-10-10 11:53:14 +08:00
37 lines
1.0 KiB
C++
37 lines
1.0 KiB
C++
#include "PlayerCommand.hpp"
|
|
|
|
#include "game/backend/Players.hpp"
|
|
#include "game/backend/Self.hpp"
|
|
|
|
namespace YimMenu
|
|
{
|
|
PlayerAllCommand::PlayerAllCommand(std::string name, std::string label, std::string description, int num_args, PlayerCommand* parent) :
|
|
Command(name + "all", label, description, num_args),
|
|
m_PlayerCommand(parent)
|
|
{
|
|
}
|
|
|
|
void PlayerAllCommand::OnCall()
|
|
{
|
|
for (auto& p : Players::GetPlayers())
|
|
if (p.second.IsValid() && (!Self::GetPlayer().IsValid() || p.second.GetId() != Self::GetPlayer().GetId()))
|
|
m_PlayerCommand->Call(p.second);
|
|
}
|
|
|
|
PlayerCommand::PlayerCommand(std::string name, std::string label, std::string description, int num_args, bool all_version) :
|
|
Command::Command(name, label, description, num_args + 1)
|
|
{
|
|
if (all_version)
|
|
m_AllCommand = std::make_unique<PlayerAllCommand>(name, label, description, num_args, this);
|
|
}
|
|
|
|
void PlayerCommand::OnCall()
|
|
{
|
|
LOG(WARNING) << GetName() << " requires a player argument";
|
|
}
|
|
|
|
void PlayerCommand::Call(Player target)
|
|
{
|
|
OnCall(target);
|
|
}
|
|
} |