mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-04-23 20:53:39 +00:00
31 lines
949 B
C++
31 lines
949 B
C++
#include "../Platform/stdafx.h"
|
|
#include "../Headers/net.minecraft.commands.h"
|
|
#include "CommandDispatcher.h"
|
|
|
|
int CommandDispatcher::performCommand(std::shared_ptr<CommandSender> sender,
|
|
EGameCommand command,
|
|
byteArray commandData) {
|
|
AUTO_VAR(it, commandsById.find(command));
|
|
|
|
if (it != commandsById.end()) {
|
|
Command* command = it->second;
|
|
if (command->canExecute(sender)) {
|
|
command->execute(sender, commandData);
|
|
} else {
|
|
#ifndef _CONTENT_PACKAGE
|
|
sender->sendMessage(
|
|
L"\u00A7cYou do not have permission to use this command.");
|
|
#endif
|
|
}
|
|
} else {
|
|
app.DebugPrintf("Command %d not found!\n", command);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
Command* CommandDispatcher::addCommand(Command* command) {
|
|
commandsById[command->getId()] = command;
|
|
commands.insert(command);
|
|
return command;
|
|
} |