Skip to content

Commit 959f570

Browse files
committed
Merge branch 'main' into fix/AssetInstanceKeyValues
2 parents 34f84fa + 84e5141 commit 959f570

File tree

3 files changed

+175
-1
lines changed

3 files changed

+175
-1
lines changed

Runtime/Client/LootLockerEndPoints.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public class LootLockerEndPoints
4343
public static EndPointClass setProfilePublic = new EndPointClass("v1/player/profile/public", LootLockerHTTPMethod.POST);
4444
public static EndPointClass getPlayerName = new EndPointClass("player/name", LootLockerHTTPMethod.GET);
4545
public static EndPointClass setPlayerName = new EndPointClass("player/name", LootLockerHTTPMethod.PATCH);
46+
public static EndPointClass lookupPlayerNames = new EndPointClass("player/lookup/name", LootLockerHTTPMethod.GET);
4647

4748
// Character
4849
[Header("Character")]

Runtime/Game/LootLockerSDKManager.cs

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,104 @@ public static void GetPlayerName(Action<PlayerNameResponse> onComplete)
678678
LootLockerAPIManager.GetPlayerName(onComplete);
679679
}
680680

681+
public static void LookupPlayerNamesByPlayerIds(ulong[] playerIds, Action<PlayerNameLookupResponse> onComplete)
682+
{
683+
if (!CheckInitialized())
684+
{
685+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<PlayerNameLookupResponse>());
686+
return;
687+
}
688+
689+
LootLockerAPIManager.LookupPlayerNames(new LookupPlayerNamesRequest()
690+
{
691+
player_ids = playerIds
692+
}, onComplete);
693+
}
694+
695+
public static void LookupPlayerNamesByPlayerPublicUIds(string[] playerPublicUIds, Action<PlayerNameLookupResponse> onComplete)
696+
{
697+
if (!CheckInitialized())
698+
{
699+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<PlayerNameLookupResponse>());
700+
return;
701+
}
702+
703+
LootLockerAPIManager.LookupPlayerNames(new LookupPlayerNamesRequest()
704+
{
705+
player_public_uids = playerPublicUIds
706+
}, onComplete);
707+
}
708+
709+
public static void LookupPlayerNamesBySteamIds(ulong[] steamIds, Action<PlayerNameLookupResponse> onComplete)
710+
{
711+
if (!CheckInitialized())
712+
{
713+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<PlayerNameLookupResponse>());
714+
return;
715+
}
716+
717+
LootLockerAPIManager.LookupPlayerNames(new LookupPlayerNamesRequest()
718+
{
719+
steam_ids = steamIds
720+
}, onComplete);
721+
}
722+
723+
public static void LookupPlayerNamesBySteamIds(string[] steamIds, Action<PlayerNameLookupResponse> onComplete)
724+
{
725+
if (!CheckInitialized())
726+
{
727+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<PlayerNameLookupResponse>());
728+
return;
729+
}
730+
731+
LootLockerAPIManager.LookupPlayerNames(new LookupPlayerNamesRequest()
732+
{
733+
steam_ids = steamIds.Select(steamId => Convert.ToUInt64(steamId)).ToArray()
734+
}, onComplete);
735+
}
736+
737+
public static void LookupPlayerNamesByPSNIds(ulong[] psnIds, Action<PlayerNameLookupResponse> onComplete)
738+
{
739+
if (!CheckInitialized())
740+
{
741+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<PlayerNameLookupResponse>());
742+
return;
743+
}
744+
745+
LootLockerAPIManager.LookupPlayerNames(new LookupPlayerNamesRequest()
746+
{
747+
psn_ids = psnIds
748+
}, onComplete);
749+
}
750+
751+
public static void LookupPlayerNamesByPSNIds(string[] psnIds, Action<PlayerNameLookupResponse> onComplete)
752+
{
753+
if (!CheckInitialized())
754+
{
755+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<PlayerNameLookupResponse>());
756+
return;
757+
}
758+
759+
LootLockerAPIManager.LookupPlayerNames(new LookupPlayerNamesRequest()
760+
{
761+
psn_ids = psnIds.Select(psnId => Convert.ToUInt64(psnId)).ToArray()
762+
}, onComplete);
763+
}
764+
765+
public static void LookupPlayerNamesByXboxIds(string[] xboxIds, Action<PlayerNameLookupResponse> onComplete)
766+
{
767+
if (!CheckInitialized())
768+
{
769+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<PlayerNameLookupResponse>());
770+
return;
771+
}
772+
773+
LootLockerAPIManager.LookupPlayerNames(new LookupPlayerNamesRequest()
774+
{
775+
xbox_ids = xboxIds
776+
}, onComplete);
777+
}
778+
681779
public static void SetPlayerName(string name, Action<PlayerNameResponse> onComplete)
682780
{
683781
if (!CheckInitialized())

Runtime/Game/Requests/PlayerRequest.cs

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Newtonsoft.Json;
1+
using Newtonsoft.Json;
22
using System;
33
using System.Collections;
44
using System.Collections.Generic;
@@ -29,6 +29,39 @@ public class PlayerNameRequest
2929
{
3030
public string name { get; set; }
3131
}
32+
33+
public class LookupPlayerNamesRequest
34+
{
35+
public ulong[] player_ids { get; set; }
36+
public string[] player_public_uids { get; set; }
37+
public ulong[] steam_ids { get; set; }
38+
public ulong[] psn_ids { get; set; }
39+
public string[] xbox_ids { get; set; }
40+
41+
public LookupPlayerNamesRequest()
42+
{
43+
player_ids = new ulong[]{};
44+
player_public_uids = new string[]{};
45+
steam_ids = new ulong[]{};
46+
psn_ids = new ulong[]{};
47+
xbox_ids = new string[]{};
48+
}
49+
}
50+
51+
[System.Serializable]
52+
public class PlayerNameLookupResponse : LootLockerResponse
53+
{
54+
public PlayerNameWithIDs[] players { get; set; }
55+
}
56+
57+
public class PlayerNameWithIDs : LootLockerResponse
58+
{
59+
public uint player_id { get; set; }
60+
public string player_public_uid { get; set; }
61+
public string name { get; set; }
62+
public string last_active_platform { get; set; }
63+
public string platform_player_id { get; set; }
64+
}
3265

3366
[System.Serializable]
3467
public class PlayerNameResponse : LootLockerResponse
@@ -400,6 +433,48 @@ public static void GetPlayerName(Action<PlayerNameResponse> onComplete)
400433
onComplete?.Invoke(response);
401434
}), true);
402435
}
436+
437+
public static void LookupPlayerNames(LookupPlayerNamesRequest lookupPlayerNamesRequest, Action<PlayerNameLookupResponse> onComplete)
438+
{
439+
EndPointClass endPoint = LootLockerEndPoints.lookupPlayerNames;
440+
441+
string getVariable = endPoint.endPoint + "?";
442+
443+
foreach (var playerID in lookupPlayerNamesRequest.player_ids)
444+
{
445+
getVariable += $"player_id={playerID}&";
446+
}
447+
foreach (var playerPublicUID in lookupPlayerNamesRequest.player_public_uids)
448+
{
449+
getVariable += $"player_public_uid={playerPublicUID}&";
450+
}
451+
foreach (var steamID in lookupPlayerNamesRequest.steam_ids)
452+
{
453+
getVariable += $"steam_id={steamID}&";
454+
}
455+
foreach (var psnID in lookupPlayerNamesRequest.psn_ids)
456+
{
457+
getVariable += $"psn_id={psnID}&";
458+
}
459+
foreach (var xboxID in lookupPlayerNamesRequest.xbox_ids)
460+
{
461+
getVariable += $"xbox_id={xboxID}&";
462+
}
463+
464+
LootLockerServerRequest.CallAPI(getVariable, endPoint.httpMethod, null, (Action<LootLockerResponse>)((serverResponse) =>
465+
{
466+
PlayerNameLookupResponse response = new PlayerNameLookupResponse();
467+
if (string.IsNullOrEmpty(serverResponse.Error))
468+
response = JsonConvert.DeserializeObject<PlayerNameLookupResponse>(serverResponse.text);
469+
470+
//LootLockerSDKManager.DebugMessage(serverResponse.text, !string.IsNullOrEmpty(serverResponse.Error));
471+
response.text = serverResponse.text;
472+
response.success = serverResponse.success;
473+
response.Error = serverResponse.Error;
474+
response.statusCode = serverResponse.statusCode;
475+
onComplete?.Invoke(response);
476+
}), true);
477+
}
403478

404479
public static void SetPlayerName(PlayerNameRequest data, Action<PlayerNameResponse> onComplete)
405480
{

0 commit comments

Comments
 (0)