Skip to content

Commit

Permalink
fix: fix mc.runcmd & mc.runcmdEx
Browse files Browse the repository at this point in the history
  • Loading branch information
ShrBox committed Jan 23, 2024
1 parent e9db611 commit 9d802cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
18 changes: 8 additions & 10 deletions src/api/CommandAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ Local<Value> McClass::runcmd(const Arguments& args) {
)
);
try {
return Boolean::newBoolean(ll::service::getMinecraft()->getCommands().executeCommand(context, true));
return Boolean::newBoolean(ll::service::getMinecraft()->getCommands().executeCommand(context, false));
}
CATCH("Fail in RunCmd!")
}
Expand All @@ -179,10 +179,10 @@ Local<Value> McClass::runcmdEx(const Arguments& args) {
)
);
try {
MCRESULT result = ll::service::getMinecraft()->getCommands().executeCommand(context, false);
MCRESULT result = ll::service::getMinecraft()->getCommands().executeCommand(context, true);
Local<Object> resObj = Object::newObject();
resObj.set("success", result.isSuccess());
resObj.set("output", {});
resObj.set("output", result.getFullCode());
return resObj;
}
CATCH("Fail in RunCmdEx!")
Expand Down Expand Up @@ -474,13 +474,11 @@ Local<Value> CommandClass::setCallback(const Arguments& args) {
CHECK_ARGS_COUNT(args, 1);
CHECK_ARG_TYPE(args[0], ValueKind::kFunction);
try {
auto func = args[0].asFunction();
DynamicCommandInstance* command = get();
auto& commandName = command->getCommandName();
localShareData->commandCallbacks[commandName] = {
EngineScope::currentEngine(),
0,
script::Global<Function>(func)};
auto func = args[0].asFunction();
DynamicCommandInstance* command = get();
auto& commandName = command->getCommandName();
localShareData
->commandCallbacks[commandName] = {EngineScope::currentEngine(), 0, script::Global<Function>(func)};
if (registered) return Boolean::newBoolean(true);
get()->setCallback(onExecute);
return Boolean::newBoolean(true);
Expand Down
3 changes: 2 additions & 1 deletion src/api/EventAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,8 @@ void InitBasicEventListeners() {
// });
bus.emplaceListener<ExecutingCommandEvent>([](ExecutingCommandEvent& ev) {
if (ev.commandContext().getCommandOrigin().getOriginType() == CommandOriginType::DedicatedServer) {
std::string cmd = ev.commandContext().mCommand.erase(0, 1);
std::string cmd = ev.commandContext().mCommand;
cmd.erase(0, 1);

if (!ProcessDebugEngine(cmd)) {
ev.cancel();
Expand Down

0 comments on commit 9d802cd

Please sign in to comment.