Advertisement
CodeHz

minecraft_test_mod

Jan 24th, 2018
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <minecraft/command/Command.h>
  3. #include <minecraft/command/CommandMessage.h>
  4. #include <minecraft/command/CommandOutput.h>
  5. #include <minecraft/command/CommandParameterData.h>
  6. #include <minecraft/command/CommandRegistry.h>
  7. #include <minecraft/command/CommandVersion.h>
  8.  
  9. #include "minecraft.h"
  10.  
  11. class TestCommand : public Command {
  12.  
  13. public:
  14.     CommandMessage test;
  15.  
  16.     ~TestCommand() override = default;
  17.  
  18.     static void setup(CommandRegistry& registry) {
  19.         registry.registerCommand("test", "command.test.description", (CommandPermissionLevel) 0, (CommandFlag) 0, (CommandFlag) 0);
  20.         registry.registerOverload<TestCommand>("test", CommandVersion(1, INT_MAX), CommandParameterData(CommandMessage::type_id(), &CommandRegistry::parse<CommandMessage>, "message", (CommandParameterDataType) 0, nullptr, offsetof(TestCommand, test), false, -1));
  21.     }
  22.  
  23.     void execute(CommandOrigin const& origin, CommandOutput& outp) override {
  24.         outp.addMessage("Β§aThis absolutely Β§dworked! Β§e" + test.getMessage(origin));
  25.         outp.success();
  26.     }
  27.  
  28. };
  29.  
  30. extern "C" {
  31.  
  32. void mod_init() {
  33.     std::cout << "Loading TEST command\n";
  34. }
  35.  
  36. void mod_set_minecraft(Minecraft *mc) {
  37.     std::cout << "Minecraft Loaded";
  38.     TestCommand::setup(mc->getCommands()->getRegistry());
  39. }
  40.  
  41. void mod_set_server(ServerInstance *instance) {
  42.     mod_set_minecraft(instance->minecraft);
  43. }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement