Skip to content

Commit 0d61ea6

Browse files
committed
fix: fix event cancellation #199
1 parent 33811dc commit 0d61ea6

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/legacy/api/EventAPI.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,11 @@ void InitBasicEventListeners() {
821821
// LLSE Registered Cmd
822822

823823
bool callbackRes = CallServerCmdCallback(prefix, paras);
824-
IF_LISTENED(EVENT_TYPES::onConsoleCmd) { CallEvent(EVENT_TYPES::onConsoleCmd, String::newString(cmd)); }
824+
IF_LISTENED(EVENT_TYPES::onConsoleCmd) {
825+
if (!CallEvent(EVENT_TYPES::onConsoleCmd, String::newString(cmd))) {
826+
ev.cancel();
827+
}
828+
}
825829
IF_LISTENED_END(EVENT_TYPES::onConsoleCmd);
826830
if (!callbackRes) {
827831
ev.cancel();
@@ -854,7 +858,13 @@ void InitBasicEventListeners() {
854858
if (static_cast<int>(permission_level) >= perm) {
855859
bool callbackRes = CallPlayerCmdCallback(player, prefix, paras);
856860
IF_LISTENED(EVENT_TYPES::onPlayerCmd) {
857-
CallEvent(EVENT_TYPES::onPlayerCmd, PlayerClass::newPlayer(player), String::newString(cmd));
861+
if (!CallEvent(
862+
EVENT_TYPES::onPlayerCmd,
863+
PlayerClass::newPlayer(player),
864+
String::newString(cmd)
865+
)) {
866+
ev.cancel();
867+
}
858868
}
859869
IF_LISTENED_END(EVENT_TYPES::onPlayerCmd);
860870
if (!callbackRes) {

0 commit comments

Comments
 (0)