Skip to content
This repository has been archived by the owner on Oct 28, 2023. It is now read-only.

Commit

Permalink
Add /helper update
Browse files Browse the repository at this point in the history
  • Loading branch information
ShrBox committed Jan 21, 2022
1 parent ae9c4d2 commit 4446b69
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions LLHelper/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <SendPacketAPI.h>
#include <MC/MinecraftPackets.hpp>
#include "settings.h"
#include <thread>

std::unique_ptr<KVDB> db;
playerMap<string> ORIG_NAME;
std::unordered_map<string, string> CNAME;
Expand Down Expand Up @@ -300,7 +302,8 @@ class TransferCommand : public Command {

class HelperCommand : public Command {
enum HelperOP : int {
reload = 0
reload = 0,
update = 1
} action;

public:
Expand All @@ -310,16 +313,19 @@ class HelperCommand : public Command {
loadCfg();
outp.success(tr("hreload.success"));
break;
default:
outp.error("Error");
case update:
std::thread th([]() {
CheckAutoUpdate(true, false);
});
th.detach();
}

}
static void setup(CommandRegistry* registry) {
using RegisterCommandHelper::makeMandatory;
using RegisterCommandHelper::makeOptional;
registry->registerCommand("helper", "LLHelper", CommandPermissionLevel::GameMasters, { (CommandFlagValue)0 }, { (CommandFlagValue)0x80 });
registry->addEnum<HelperOP>("HelperOP", {{"reload", HelperOP::reload}});
registry->addEnum<HelperOP>("HelperOP", { {"reload", HelperOP::reload}, {"update", HelperOP::update}});
registry->registerOverload<HelperCommand>("helper", makeMandatory<CommandParameterDataType::ENUM>(&HelperCommand::action, "optinal", "HelperOP"));
}
};
Expand Down

0 comments on commit 4446b69

Please sign in to comment.