aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/CommandDispatcher.cpp
diff options
context:
space:
mode:
authordaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
committerdaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
commitb691c43c44ff180d10e7d4a9afc83b98551ff586 (patch)
tree3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.World/CommandDispatcher.cpp
parentdef8cb415354ac390b7e89052a50605285f1aca9 (diff)
Initial commit
Diffstat (limited to 'Minecraft.World/CommandDispatcher.cpp')
-rw-r--r--Minecraft.World/CommandDispatcher.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/Minecraft.World/CommandDispatcher.cpp b/Minecraft.World/CommandDispatcher.cpp
new file mode 100644
index 00000000..68b74ca9
--- /dev/null
+++ b/Minecraft.World/CommandDispatcher.cpp
@@ -0,0 +1,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;
+} \ No newline at end of file