Skip to content

Commit e5fb983

Browse files
committed
fix: fix command overload #196
1 parent 711bbe2 commit e5fb983

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/legacy/api/CommandAPI.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,24 @@ Local<Value> CommandClass::addOverload(const Arguments& args) {
511511
cmd.execute(onExecute);
512512
});
513513
};
514-
514+
if (args.size() == 0) {
515+
if (ll::getGamingStatus() == ll::GamingStatus::Starting) {
516+
EventBus::getInstance().emplaceListener<ServerStartedEvent>(
517+
[commandName(commandName), e(EngineScope::currentEngine())](ServerStartedEvent&) {
518+
getEngineData(e)->plugin->registeredCommands[commandName].push_back({});
519+
auto cmd = ll::command::CommandRegistrar::getInstance()
520+
.getOrCreateCommand(commandName)
521+
.runtimeOverload(getEngineData(e)->plugin);
522+
cmd.execute(onExecute);
523+
}
524+
);
525+
} else {
526+
getEngineOwnData()->plugin->registeredCommands[commandName].push_back({});
527+
auto cmd = get().runtimeOverload(getEngineOwnData()->plugin);
528+
cmd.execute(onExecute);
529+
}
530+
return Boolean::newBoolean(true);
531+
}
515532
if (args[0].isNumber()) {
516533
if (ll::getGamingStatus() == ll::GamingStatus::Starting) {
517534
std::vector<std::string> paramNames;

0 commit comments

Comments
 (0)