Skip to content

Commit

Permalink
fix: fix onConsoleCmd
Browse files Browse the repository at this point in the history
  • Loading branch information
ShrBox committed Jan 23, 2024
1 parent 4918313 commit 323a2a1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
8 changes: 3 additions & 5 deletions src/api/CommandCompatibleAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ void LLSERegisterNewCmd(bool isPlayerCmd, string cmd, const string& describe, in
localShareData->playerCmdCallbacks[cmd] = {EngineScope::currentEngine(), level, script::Global<Function>(func)};
globalShareData->playerRegisteredCmd[cmd] = LLSE_BACKEND_TYPE;
} else {
localShareData->consoleCmdCallbacks[cmd] = {
EngineScope::currentEngine(),
level,
script::Global<Function>(func)};
localShareData
->consoleCmdCallbacks[cmd] = {EngineScope::currentEngine(), level, script::Global<Function>(func)};
globalShareData->consoleRegisteredCmd[cmd] = LLSE_BACKEND_TYPE;
}

Expand Down Expand Up @@ -125,7 +123,7 @@ void ProcessRegCmdQueue() {
toRegCmdQueue.clear();
}

string LLSEFindCmdReg(bool isPlayerCmd, const string& cmd, vector<string>& receiveParas, bool* fromOtherEngine) {
std::string LLSEFindCmdReg(bool isPlayerCmd, const string& cmd, vector<string>& receiveParas, bool* fromOtherEngine) {
std::unordered_map<std::string, std::string>& registeredMap =
isPlayerCmd ? globalShareData->playerRegisteredCmd : globalShareData->consoleRegisteredCmd;
for (auto& [prefix, fromEngine] : registeredMap) {
Expand Down
13 changes: 6 additions & 7 deletions src/api/EventAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "ll/api/schedule/Scheduler.h"
#include "ll/api/schedule/Task.h"
#include "ll/api/service/Bedrock.h"
#include "ll/api/utils/StringUtils.h"
#include "main/Global.h"
#include "mc/server/commands/CommandOriginType.h"
#include "mc/world/actor/player/Player.h"
Expand All @@ -29,8 +30,6 @@
#include <list>
#include <shared_mutex>



//////////////////// Listeners ////////////////////

enum class EVENT_TYPES : int {
Expand Down Expand Up @@ -1363,9 +1362,9 @@ void InitBasicEventListeners() {
// }
// return true;
// });
bus.emplaceListener<ExecuteCommandEvent>([](ExecuteCommandEvent& ev) {
bus.emplaceListener<ExecutingCommandEvent>([](ExecutingCommandEvent& ev) {
if (ev.commandContext().getCommandOrigin().getOriginType() == CommandOriginType::DedicatedServer) {
string cmd = ev.commandContext().mCommand;
std::string cmd = ev.commandContext().mCommand.erase(0, 1);

if (!ProcessDebugEngine(cmd)) return false;
#ifdef LLSE_BACKEND_NODEJS
Expand All @@ -1374,9 +1373,9 @@ void InitBasicEventListeners() {
if (!PythonHelper::processConsolePipCmd(ev.mCommand)) return false;
#endif
// CallEvents
vector<string> paras;
bool isFromOtherEngine = false;
string prefix = LLSEFindCmdReg(false, cmd, paras, &isFromOtherEngine);
std::vector<std::string> paras;
bool isFromOtherEngine = false;
std::string prefix = LLSEFindCmdReg(false, cmd, paras, &isFromOtherEngine);

if (!prefix.empty()) {
// LLSE Registered Cmd
Expand Down
2 changes: 1 addition & 1 deletion src/main/BuiltinCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extern ScriptEngine* debugEngine;
bool ProcessDebugEngine(const std::string& cmd) {
#ifdef LLSE_BACKEND_PYTHON
// process python debug seperately
return PythonHelper::processPythonDebugEngine(cmd);
return PythonHelper::processPythonDebugEngine(cmd;
#endif
if (isInConsoleDebugMode) {
EngineScope enter(debugEngine);
Expand Down

0 comments on commit 323a2a1

Please sign in to comment.