aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/CommandDispatcher.cpp
blob: 68b74ca9ec80f94fa2a5a5bc30a78ecfc0d659f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "stdafx.h"
#include "net.minecraft.commands.h"
#include "CommandDispatcher.h"

void CommandDispatcher::performCommand(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);
	}
}

Command *CommandDispatcher::addCommand(Command *command)
{
	commandsById[command->getId()] = command;
	commands.insert(command);
	return command;
}