Skip to content

Commit f49130d

Browse files
committed
refactor: recover getAllPlayerInfo's function
1 parent 8c97f9f commit f49130d

File tree

3 files changed

+5
-42
lines changed

3 files changed

+5
-42
lines changed

docs/apis/DataAPI/PlayerData.md

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ All data will be destroyed uniformly only when the server is shut down.
88

99
As such, LLSE gives developers the ability to track data about a particular player throughout the plugin's lifecycle.
1010

11-
12-
1311
For a specific player object `pl`, with the following interfaces:
1412

1513
#### Store Player Binding Data
@@ -25,8 +23,6 @@ For a specific player object `pl`, with the following interfaces:
2523
- Return value: Whether the save was successful or not.
2624
- Return value type: `Boolean`
2725

28-
29-
3026
#### Get Player Binding Data
3127

3228
`pl.getExtraData(name)`
@@ -38,8 +34,6 @@ For a specific player object `pl`, with the following interfaces:
3834
- Return value type: `Any type`, depending on the type of data stored.
3935
- If the return value is `Null`, it means that the specified binding data is not obtained, or the data is empty.
4036

41-
42-
4337
#### Delete Player Binding Data
4438

4539
`pl.delExtraData(name)`
@@ -50,8 +44,6 @@ For a specific player object `pl`, with the following interfaces:
5044
- Return value: Whether the deletion is successful.
5145
- Return value type: `Boolean`
5246

53-
54-
5547
## 👨‍💻 XUID Database
5648

5749
The XUID database allows you to query the correspondence between player names and XUIDs even when players are offline.
@@ -68,8 +60,6 @@ When a player enters the server for the first time, his name and XUID are automa
6860
- Return value type: `String`
6961
- If the return value is `Null`, it means the query failed.
7062

71-
72-
7363
#### Query Player Name Based on XUID
7464

7565
`data.xuid2name(xuid)`
@@ -81,8 +71,6 @@ When a player enters the server for the first time, his name and XUID are automa
8171
- Return value type: `String`
8272
- If the return value is `Null`, it means the query failed.
8373

84-
85-
8674
#### Query UUID by Player Name
8775

8876
`data.name2uuid(name)`
@@ -94,8 +82,6 @@ When a player enters the server for the first time, his name and XUID are automa
9482
- Return value type: `String`
9583
- If the return value is `Null`, it means the query failed.
9684

97-
98-
9985
#### Query UUID Based on XUID
10086

10187
`data.xuid2uuid(xuid)`
@@ -107,9 +93,6 @@ When a player enters the server for the first time, his name and XUID are automa
10793
- Return value type: `String`
10894
- If the return value is `Null`, it means the query failed.
10995

110-
111-
!!! tip
112-
getAllPlayerInfo has been deprecated, it will only return online players's data
11396
#### Get all player information
11497

11598
`data.getAllPlayerInfo()`
@@ -121,6 +104,4 @@ When a player enters the server for the first time, his name and XUID are automa
121104
- `xuid`: Player's XUID.
122105
- `uuid`: Player's UUID.
123106

124-
125-
126107
Tip: The player name stored in the XUID database is named corresponding to the player object. `realName` field.

docs/apis/DataAPI/PlayerData.zh.md

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
由此,脚本引擎给予开发者在插件的整个生命周期中跟踪某个特定玩家相关数据的能力。
1010

11-
12-
1311
对于某个特定的玩家对象`pl`,有如下这些接口:
1412

1513
#### 储存玩家绑定数据
@@ -25,8 +23,6 @@
2523
- 返回值:是否成功储存
2624
- 返回值类型:`Boolean`
2725

28-
29-
3026
#### 获取玩家绑定数据
3127

3228
`pl.getExtraData(name)`
@@ -38,8 +34,6 @@
3834
- 返回值类型:`任意类型`,取决于储存的数据类型
3935
- 如返回值为 `Null` 则表示未获取到指定的绑定数据,或者数据为空
4036

41-
42-
4337
#### 删除玩家绑定数据
4438

4539
`pl.delExtraData(name)`
@@ -50,8 +44,6 @@
5044
- 返回值:是否删除成功
5145
- 返回值类型:`Boolean`
5246

53-
54-
5547
## 👨‍💻 XUID 数据库
5648

5749
XUID数据库让你可以即使在玩家离线的时候,也可以查询玩家名字与XUID的对应关系。
@@ -68,8 +60,6 @@ XUID数据库让你可以即使在玩家离线的时候,也可以查询玩家
6860
- 返回值类型:`String`
6961
- 如果返回值为`Null`,则代表查询失败
7062

71-
72-
7363
#### 根据XUID查询玩家名
7464

7565
`data.xuid2name(xuid)`
@@ -81,8 +71,6 @@ XUID数据库让你可以即使在玩家离线的时候,也可以查询玩家
8171
- 返回值类型:`String`
8272
- 如果返回值为`Null`,则代表查询失败
8373

84-
85-
8674
#### 根据玩家名查询UUID
8775

8876
`data.name2uuid(name)`
@@ -94,8 +82,6 @@ XUID数据库让你可以即使在玩家离线的时候,也可以查询玩家
9482
- 返回值类型:`String`
9583
- 如果返回值为`Null`,则代表查询失败
9684

97-
98-
9985
#### 根据XUID查询玩家UUID
10086

10187
`data.xuid2uuid(xuid)`
@@ -107,9 +93,6 @@ XUID数据库让你可以即使在玩家离线的时候,也可以查询玩家
10793
- 返回值类型:`String`
10894
- 如果返回值为`Null`,则代表查询失败
10995

110-
111-
!!!tip
112-
getAllPlayerInfo已被弃用,它现在只会返回在线玩家的信息
11396
#### 获取所有的玩家信息
11497

11598
`data.getAllPlayerInfo()`
@@ -121,6 +104,4 @@ XUID数据库让你可以即使在玩家离线的时候,也可以查询玩家
121104
- `xuid`: 玩家XUID
122105
- `uuid`: 玩家UUID
123106

124-
125-
126107
提示:XUID数据库中储存的玩家名为玩家对象对应的`realName`字段

src/legacy/api/DataAPI.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -747,11 +747,12 @@ Local<Value> DataClass::getAllPlayerInfo(const Arguments& args) {
747747
auto arr = Array::newArray();
748748
auto level = ll::service::getLevel();
749749
if (level.has_value()) {
750-
level->forEachPlayer([&arr](Player& player) {
750+
ll::service::PlayerInfo::getInstance().forEach([&arr](const ll::service::PlayerInfo::PlayerInfoEntry& entry
751+
) {
751752
auto obj = Object::newObject();
752-
obj.set("name", String::newString(player.getRealName()));
753-
obj.set("xuid", String::newString(player.getXuid()));
754-
obj.set("uuid", String::newString(player.getUuid().asString()));
753+
obj.set("name", String::newString(entry.name));
754+
obj.set("xuid", String::newString(entry.xuid));
755+
obj.set("uuid", String::newString(entry.uuid.asString()));
755756
arr.add(obj);
756757
return true;
757758
});

0 commit comments

Comments
 (0)