Skip to content

Commit 11aff6b

Browse files
committed
chore: clean some code
1 parent f749f86 commit 11aff6b

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/legacy/api/EventAPI.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -804,12 +804,12 @@ void InitBasicEventListeners() {
804804
EventBus& bus = EventBus::getInstance();
805805

806806
bus.emplaceListener<ExecutingCommandEvent>([](ExecutingCommandEvent& ev) {
807-
if (ev.commandContext().getCommandOrigin().getOriginType() == CommandOriginType::DedicatedServer) {
807+
auto originType = ev.commandContext().getCommandOrigin().getOriginType();
808+
if (originType == CommandOriginType::DedicatedServer) {
808809
std::string cmd = ev.commandContext().mCommand;
809810
if (cmd.starts_with("/")) {
810811
cmd.erase(0, 1);
811812
}
812-
813813
if (!ProcessDebugEngine(cmd)) {
814814
ev.cancel();
815815
return;
@@ -831,8 +831,7 @@ void InitBasicEventListeners() {
831831
std::string prefix = LLSEFindCmdReg(false, cmd, paras, &isFromOtherEngine);
832832

833833
if (!prefix.empty()) {
834-
// LLSE Registered Cmd
835-
834+
// LSE Registered Cmd
836835
bool callbackRes = CallServerCmdCallback(prefix, paras);
837836
IF_LISTENED(EVENT_TYPES::onConsoleCmd) {
838837
if (!CallEvent(EVENT_TYPES::onConsoleCmd, String::newString(cmd))) {
@@ -858,7 +857,7 @@ void InitBasicEventListeners() {
858857
}
859858
IF_LISTENED_END(EVENT_TYPES::onConsoleCmd);
860859
}
861-
} else if (ev.commandContext().mOrigin->getOriginType() == CommandOriginType::Player) {
860+
} else if (originType == CommandOriginType::Player) {
862861
std::string cmd = ev.commandContext().mCommand;
863862
if (cmd.starts_with("/")) {
864863
cmd.erase(0, 1);
@@ -903,9 +902,7 @@ void InitBasicEventListeners() {
903902
}
904903
IF_LISTENED_END(EVENT_TYPES::onPlayerCmd);
905904
}
906-
return;
907905
}
908-
return;
909906
});
910907

911908
// ===== onServerStarted =====

src/legacy/api/LlAPI.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ Local<Value> LlClass::onUnload(const script::Arguments& args) {
377377
EngineScope enter(engine);
378378
func.get().call();
379379
});
380+
return {};
380381
}
381382
CATCH("Fail in onUnload");
382383
}

0 commit comments

Comments
 (0)