Skip to content

Commit 187022b

Browse files
committed
refactor: add pointer check for getPlayerNbt
1 parent 4fa53a4 commit 187022b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/legacy/api/PlayerAPI.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,14 @@ Local<Value> McClass::getPlayerNbt(const Arguments& args) {
335335
if (player) {
336336
player->save(*tag);
337337
} else {
338-
if (auto tagptr = MoreGlobal::getDBStorage()->loadPlayerDataFromTag(uuid.asString()); tagptr) {
339-
tag = std::move(tagptr.get());
338+
DBStorage* db = MoreGlobal::getDBStorage();
339+
if (db) {
340+
auto tagPtr = db->loadPlayerDataFromTag(uuid.asString());
341+
if (tagPtr) {
342+
tag = std::move(tagPtr.get());
343+
}
344+
} else {
345+
return Local<Value>();
340346
}
341347
}
342348

0 commit comments

Comments
 (0)