4jcraft/Minecraft.World/Commands/Command.cpp
MatthewBeshay dfb0e3b03e refactor: replace NULL with nullptr across C++ codebase
Excludes vendored C libs (zlib, Miles, DirectXMath, boost, Iggy).
2026-03-30 16:25:52 +11:00

45 lines
1.7 KiB
C++

#include "../Platform/stdafx.h"
#include "../Headers/net.minecraft.commands.h"
#include "../../Minecraft.Client/MinecraftServer.h"
#include "../../Minecraft.Client/Network/PlayerList.h"
#include "../../Minecraft.Client/Player/ServerPlayer.h"
#include "Command.h"
AdminLogCommand* Command::logger;
int Command::getPermissionLevel() { return LEVEL_OWNERS; }
bool Command::canExecute(std::shared_ptr<CommandSender> source) {
return source->hasPermission(getId());
}
void Command::logAdminAction(std::shared_ptr<CommandSender> source,
ChatPacket::EChatPacketMessage messageType,
const std::wstring& message, int customData,
const std::wstring& additionalMessage) {
logAdminAction(source, 0, messageType, message, customData,
additionalMessage);
}
void Command::logAdminAction(std::shared_ptr<CommandSender> source, int type,
ChatPacket::EChatPacketMessage messageType,
const std::wstring& message, int customData,
const std::wstring& additionalMessage) {
if (logger != nullptr) {
logger->logAdminCommand(source, type, messageType, message, customData,
additionalMessage);
}
}
void Command::setLogger(AdminLogCommand* logger) { Command::logger = logger; }
std::shared_ptr<ServerPlayer> Command::getPlayer(PlayerUID playerId) {
std::shared_ptr<ServerPlayer> player =
MinecraftServer::getInstance()->getPlayers()->getPlayer(playerId);
if (player == nullptr) {
return nullptr;
} else {
return player;
}
}