Skip to content

Commit 74284d7

Browse files
authored
fix: fix getAllTags (#56)
1 parent e209409 commit 74284d7

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/legacy/api/EntityAPI.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,11 +1357,9 @@ Local<Value> EntityClass::getAllTags(const Arguments& args) {
13571357
if (!entity) return Local<Value>();
13581358

13591359
Local<Array> arr = Array::newArray();
1360-
CompoundTag tag = CompoundTag();
1361-
entity->save(tag);
1362-
tag.at("tags").get<ListTag>().forEachCompoundTag([&arr](const CompoundTag& tag) {
1363-
arr.add(String::newString(tag.toString()));
1364-
});
1360+
for (auto tag : entity->getTags()) {
1361+
arr.add(String::newString(tag));
1362+
}
13651363
return arr;
13661364
}
13671365
CATCH("Fail in getAllTags!");

src/legacy/api/PlayerAPI.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2917,11 +2917,9 @@ Local<Value> PlayerClass::getAllTags(const Arguments& args) {
29172917
if (!player) return Local<Value>();
29182918

29192919
Local<Array> arr = Array::newArray();
2920-
CompoundTag tag = CompoundTag();
2921-
player->save(tag);
2922-
tag.at("Tags").get<ListTag>().forEachCompoundTag([&arr](const CompoundTag& tag) {
2923-
arr.add(String::newString(tag.toString()));
2924-
});
2920+
for (auto tag : player->getTags()) {
2921+
arr.add(String::newString(tag));
2922+
}
29252923
return arr;
29262924
}
29272925
CATCH("Fail in getAllTags!");

0 commit comments

Comments
 (0)