Skip to content

Commit 1dd694e

Browse files
committed
fix: add missing Logger::setPlayer
1 parent 3dbdd8d commit 1dd694e

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/legacy/api/LoggerAPI.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
#include "api/LoggerAPI.h"
22

33
#include "api/APIHelp.h"
4+
#include "api/PlayerAPI.h"
45
#include "engine/EngineOwnData.h"
56
#include "ll/api/Logger.h"
7+
#include "ll/api/service/Bedrock.h"
8+
#include "mc/world/actor/player/Player.h"
9+
#include "mc/world/level/Level.h"
610
#include "utils/Utils.h"
711

812
#include <fstream>
913
#include <iostream>
1014
#include <string>
15+
#include <string_view>
1116

1217
//////////////////// Classes ////////////////////
1318

@@ -169,8 +174,20 @@ Local<Value> LoggerClass::setFile(const Arguments& args) {
169174
}
170175

171176
Local<Value> LoggerClass::setPlayer(const Arguments& args) {
177+
CHECK_ARGS_COUNT(args, 1)
172178
try {
173-
return Boolean::newBoolean(false);
179+
Player* player = PlayerClass::extract(args[0]);
180+
if (!player) {
181+
return Boolean::newBoolean(false);
182+
}
183+
ENGINE_OWN_DATA()->logger.setPlayerOutputFunc([uuid(player->getUuid())](std::string_view str) {
184+
ll::service::getLevel()->getPlayer(uuid)->sendMessage(str);
185+
});
186+
if (args.size() >= 2) {
187+
ENGINE_OWN_DATA()->logger.fileLevel = args[1].toInt();
188+
UpdateMaxLogLevel();
189+
}
190+
return Boolean::newBoolean(true);
174191
}
175192
CATCH("Fail in LoggerSetPlayer!")
176193
}

0 commit comments

Comments
 (0)