feat: add more info for UserCache

This commit is contained in:
zimuya4153
2025-11-09 21:05:53 +08:00
Unverified
parent f352dc2215
commit 1f664c211a
9 changed files with 67 additions and 206 deletions
+3 -3
View File
@@ -1078,12 +1078,12 @@ export class UserCache {
/** 获取玩家信息 */
static getPlayerInfo(
/** 玩家名 或 xuid 或 uuid */
/** 玩家名 或 xuid 或 uuid 或 serverId 或 uniqueId */
playerIdentifier: string
): { Xuid: String, Uuid: string, Name: string } | null;
): { Xuid: string, Uuid: string, Name: string, ServerId: string, ActorUniqueID: string } | null;
/** 获取所有玩家信息 */
static getAllPlayerInfo(): { Xuid: String; Uuid: string; Name: string; }[]
static getAllPlayerInfo(): { Xuid: string, Uuid: string, Name: string, ServerId: string, ActorUniqueID: string }[]
}
type PacketDataItem = (
+8 -5
View File
@@ -216,7 +216,9 @@ const GMLIB_API = {
getXuidByName: ll.imports("GMLIB_API", "getXuidByName"),
/** 根据名字获取uuid @type {function(string):string} */
getUuidByName: ll.imports("GMLIB_API", "getUuidByName"),
/** 获取所有已记录的玩家信息 @type {function():Array.<{"Uuid":string,"Xuid":string,"Name":string}>} */
/** 根据信息获取玩家信息 @type {function():{"Uuid":string,"Xuid":string,"Name":string,"ServerId":string,"ActorUniqueID":string}} */
getPlayerInfo: ll.imports("GMLIB_API", "getPlayerInfo"),
/** 获取所有已记录的玩家信息 @type {function():Array.<{"Uuid":string,"Xuid":string,"Name":string,"ServerId":string,"ActorUniqueID":string}>} */
getAllPlayerInfo: ll.imports("GMLIB_API", "getAllPlayerInfo"),
/** 获取方块RuntimeId @type {function(string,number):number} */
getBlockRuntimeId: ll.imports("GMLIB_API", "getBlockRuntimeId"),
@@ -2107,16 +2109,17 @@ class UserCache {
/**
* 获取玩家信息
* @param {string} playerIdentifier 玩家的 xuid 或 uuid 或 名称
* @returns {{Xuid: String, Uuid: string, Name: string}?} 玩家信息
* @param {string} playerIdentifier 玩家的 xuid 或 uuid 或 realName 或 serverId 或 uniqueId
* @returns {{Xuid: string, Uuid: string, Name: string, ServerId: string, ActorUniqueID: string}?} 玩家信息
*/
static getPlayerInfo(playerIdentifier) {
return GMLIB_API.getAllPlayerInfo().find(Info => Object.keys(Info).some(InfoKey => Info[InfoKey] === playerIdentifier));
const result = GMLIB_API.getPlayerInfo(playerIdentifier)
return Object.keys(result).length === 0 ? null : result;
}
/**
* 获取所有玩家信息
* @returns {Array.<{Xuid: String, Uuid: string, Name: string}>} 包含所有玩家信息的数组
* @returns {Array.<{Xuid: string, Uuid: string, Name: string, ServerId: string, ActorUniqueID: string}>} 包含所有玩家信息的数组
*/
static getAllPlayerInfo() {
return GMLIB_API.getAllPlayerInfo();