Skip to content

Commit dca98ed

Browse files
Mikkel Sørensenkristijan-ujevic
authored andcommitted
Makes it impossible to set Player name to "Player"
1 parent 0792c40 commit dca98ed

File tree

1 file changed

+48
-39
lines changed

1 file changed

+48
-39
lines changed

Runtime/Game/LootLockerSDKManager.cs

Lines changed: 48 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,8 @@ public static void StartSteamSession(string steamId64, Action<LootLockerSessionR
389389

390390
CurrentPlatform.Set(Platforms.Steam);
391391
LootLockerSessionRequest sessionRequest = new LootLockerSessionRequest(steamId64);
392-
LootLockerAPIManager.Session(sessionRequest, response => {
392+
LootLockerAPIManager.Session(sessionRequest, response =>
393+
{
393394
if (!response.success)
394395
{
395396
CurrentPlatform.Reset();
@@ -793,7 +794,8 @@ public static void WhiteLabelLogin(string email, string password, bool remember,
793794
remember = remember
794795
};
795796

796-
LootLockerAPIManager.WhiteLabelLogin(input, response => {
797+
LootLockerAPIManager.WhiteLabelLogin(input, response =>
798+
{
797799
PlayerPrefs.SetString("LootLockerWhiteLabelSessionToken", response.SessionToken);
798800
PlayerPrefs.SetString("LootLockerWhiteLabelSessionEmail", email);
799801
PlayerPrefs.Save();
@@ -1416,12 +1418,19 @@ public static void SetPlayerName(string name, Action<PlayerNameResponse> onCompl
14161418
return;
14171419
}
14181420

1419-
if (CurrentPlatform.Get() == Platforms.Guest && name.ToLower().Contains(PlayerPrefs.GetString("LootLockerGuestPlayerID").ToLower()))
1421+
if (CurrentPlatform.Get() == Platforms.Guest)
14201422
{
1421-
onComplete?.Invoke(LootLockerResponseFactory.Error<PlayerNameResponse>("Setting the Player name to the Identifier is not allowed"));
1422-
return;
1423-
}
1423+
if (name.ToLower().Contains("player"))
1424+
{
1425+
onComplete?.Invoke(LootLockerResponseFactory.Error<PlayerNameResponse>("Setting the Player name to 'Player' is not allowed"));
1426+
return;
14241427

1428+
} else if (name.ToLower().Contains(PlayerPrefs.GetString("LootLockerGuestPlayerID").ToLower()))
1429+
{
1430+
onComplete?.Invoke(LootLockerResponseFactory.Error<PlayerNameResponse>("Setting the Player name to the Identifier is not allowed"));
1431+
return;
1432+
}
1433+
}
14251434

14261435
PlayerNameRequest data = new PlayerNameRequest();
14271436
data.name = name;
@@ -1437,7 +1446,7 @@ public static void DeletePlayer(Action<LootLockerResponse> onComplete)
14371446
{
14381447
if (!CheckInitialized())
14391448
{
1440-
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerResponse> ());
1449+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerResponse>());
14411450
return;
14421451
}
14431452

@@ -1543,7 +1552,7 @@ public static void UploadPlayerFile(string pathToFile, string filePurpose, bool
15431552
LootLockerResponse.Deserialize(onComplete, serverResponse);
15441553
});
15451554
}
1546-
1555+
15471556
/// <summary>
15481557
/// Upload a file with the provided name and content. The file will be owned by the player with the provided playerID.
15491558
/// It will not be viewable by other players.
@@ -1634,7 +1643,7 @@ public static void UploadPlayerFile(byte[] fileBytes, string fileName, string fi
16341643
LootLockerResponse.Deserialize(onComplete, serverResponse);
16351644
});
16361645
}
1637-
1646+
16381647
/// <summary>
16391648
/// Upload a file using a byte array. Can be useful if you want to upload without storing anything on disk. The file will be owned by the currently active player.
16401649
/// </summary>
@@ -1646,9 +1655,9 @@ public static void UploadPlayerFile(byte[] fileBytes, string fileName, string fi
16461655
{
16471656
UploadPlayerFile(fileBytes, fileName, filePurpose, false, onComplete);
16481657
}
1649-
1658+
16501659
///////////////////////////////////////////////////////////////////////////////
1651-
1660+
16521661
/// <summary>
16531662
/// Update an existing player file with a new file.
16541663
/// </summary>
@@ -1662,7 +1671,7 @@ public static void UpdatePlayerFile(int fileId, string pathToFile, Action<LootLo
16621671
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerPlayerFile>());
16631672
return;
16641673
}
1665-
1674+
16661675
var fileBytes = new byte[] { };
16671676
try
16681677
{
@@ -1673,10 +1682,10 @@ public static void UpdatePlayerFile(int fileId, string pathToFile, Action<LootLo
16731682
LootLockerLogger.GetForLogLevel(LootLockerLogger.LogLevel.Error)($"File error: {e.Message}");
16741683
return;
16751684
}
1676-
1685+
16771686
var endpoint = string.Format(LootLockerEndPoints.updatePlayerFile.endPoint, fileId);
16781687

1679-
LootLockerServerRequest.UploadFile(endpoint, LootLockerEndPoints.updatePlayerFile.httpMethod, fileBytes, Path.GetFileName(pathToFile), "multipart/form-data", new Dictionary<string, string>(),
1688+
LootLockerServerRequest.UploadFile(endpoint, LootLockerEndPoints.updatePlayerFile.httpMethod, fileBytes, Path.GetFileName(pathToFile), "multipart/form-data", new Dictionary<string, string>(),
16801689
onComplete: (serverResponse) =>
16811690
{
16821691
LootLockerResponse.Deserialize(onComplete, serverResponse);
@@ -1710,7 +1719,7 @@ public static void UpdatePlayerFile(int fileId, FileStream fileStream, Action<Lo
17101719

17111720
var endpoint = string.Format(LootLockerEndPoints.updatePlayerFile.endPoint, fileId);
17121721

1713-
LootLockerServerRequest.UploadFile(endpoint, LootLockerEndPoints.updatePlayerFile.httpMethod, fileBytes, Path.GetFileName(fileStream.Name), "multipart/form-data", new Dictionary<string, string>(),
1722+
LootLockerServerRequest.UploadFile(endpoint, LootLockerEndPoints.updatePlayerFile.httpMethod, fileBytes, Path.GetFileName(fileStream.Name), "multipart/form-data", new Dictionary<string, string>(),
17141723
onComplete: (serverResponse) =>
17151724
{
17161725
LootLockerResponse.Deserialize(onComplete, serverResponse);
@@ -1733,7 +1742,7 @@ public static void UpdatePlayerFile(int fileId, byte[] fileBytes, Action<LootLoc
17331742

17341743
var endpoint = string.Format(LootLockerEndPoints.updatePlayerFile.endPoint, fileId);
17351744

1736-
LootLockerServerRequest.UploadFile(endpoint, LootLockerEndPoints.updatePlayerFile.httpMethod, fileBytes, null, "multipart/form-data", new Dictionary<string, string>(),
1745+
LootLockerServerRequest.UploadFile(endpoint, LootLockerEndPoints.updatePlayerFile.httpMethod, fileBytes, null, "multipart/form-data", new Dictionary<string, string>(),
17371746
onComplete: (serverResponse) =>
17381747
{
17391748
LootLockerResponse.Deserialize(onComplete, serverResponse);
@@ -1786,7 +1795,7 @@ public static void GetPlayerProgressions(int count, string after, Action<LootLoc
17861795

17871796
LootLockerServerRequest.CallAPI(endpoint, LootLockerHTTPMethod.GET, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
17881797
}
1789-
1798+
17901799
/// <summary>
17911800
/// Returns multiple progressions the player is currently on.
17921801
/// </summary>
@@ -1796,7 +1805,7 @@ public static void GetPlayerProgressions(int count, Action<LootLockerPaginatedPl
17961805
{
17971806
GetPlayerProgressions(count, null, onComplete);
17981807
}
1799-
1808+
18001809
/// <summary>
18011810
/// Returns multiple progressions the player is currently on.
18021811
/// </summary>
@@ -1805,7 +1814,7 @@ public static void GetPlayerProgressions(Action<LootLockerPaginatedPlayerProgres
18051814
{
18061815
GetPlayerProgressions(-1, null, onComplete);
18071816
}
1808-
1817+
18091818
/// <summary>
18101819
/// Returns a single progression the player is currently on.
18111820
/// </summary>
@@ -1823,7 +1832,7 @@ public static void GetPlayerProgression(string progressionKey, Action<LootLocker
18231832

18241833
LootLockerServerRequest.CallAPI(endpoint, LootLockerHTTPMethod.GET, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
18251834
}
1826-
1835+
18271836
/// <summary>
18281837
/// Adds points to a player progression.
18291838
/// </summary>
@@ -1840,11 +1849,11 @@ public static void AddPointsToPlayerProgression(string progressionKey, ulong amo
18401849

18411850
var endpoint = string.Format(LootLockerEndPoints.addPointsToPlayerProgression.endPoint, progressionKey);
18421851

1843-
var body = LootLockerJson.SerializeObject(new { amount });
1852+
var body = LootLockerJson.SerializeObject(new { amount });
18441853

18451854
LootLockerServerRequest.CallAPI(endpoint, LootLockerHTTPMethod.POST, body, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
18461855
}
1847-
1856+
18481857
/// <summary>
18491858
/// Subtracts points from a player progression.
18501859
/// </summary>
@@ -1860,12 +1869,12 @@ public static void SubtractPointsFromPlayerProgression(string progressionKey, ul
18601869
}
18611870

18621871
var endpoint = string.Format(LootLockerEndPoints.subtractPointsFromPlayerProgression.endPoint, progressionKey);
1863-
1872+
18641873
var body = LootLockerJson.SerializeObject(new { amount });
18651874

18661875
LootLockerServerRequest.CallAPI(endpoint, LootLockerHTTPMethod.POST, body, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
18671876
}
1868-
1877+
18691878
/// <summary>
18701879
/// Resets a player progression.
18711880
/// </summary>
@@ -1883,7 +1892,7 @@ public static void ResetPlayerProgression(string progressionKey, Action<LootLock
18831892

18841893
LootLockerServerRequest.CallAPI(endpoint, LootLockerHTTPMethod.POST, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
18851894
}
1886-
1895+
18871896
/// <summary>
18881897
/// Deletes a player progression.
18891898
/// </summary>
@@ -2309,7 +2318,7 @@ public static void AddPointsToCharacterProgression(int characterId, string progr
23092318

23102319
var endpoint = string.Format(LootLockerEndPoints.addPointsToCharacterProgression.endPoint, characterId, progressionKey);
23112320

2312-
var body = LootLockerJson.SerializeObject(new { amount });
2321+
var body = LootLockerJson.SerializeObject(new { amount });
23132322

23142323
LootLockerServerRequest.CallAPI(endpoint, LootLockerHTTPMethod.POST, body, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
23152324
}
@@ -2330,7 +2339,7 @@ public static void SubtractPointsFromCharacterProgression(int characterId, strin
23302339
}
23312340

23322341
var endpoint = string.Format(LootLockerEndPoints.subtractPointsFromCharacterProgression.endPoint, characterId, progressionKey);
2333-
2342+
23342343
var body = LootLockerJson.SerializeObject(new { amount });
23352344

23362345
LootLockerServerRequest.CallAPI(endpoint, LootLockerHTTPMethod.POST, body, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
@@ -2354,7 +2363,7 @@ public static void ResetCharacterProgression(int characterId, string progression
23542363

23552364
LootLockerServerRequest.CallAPI(endpoint, LootLockerHTTPMethod.POST, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
23562365
}
2357-
2366+
23582367
/// <summary>
23592368
/// Deletes a character progression.
23602369
/// </summary>
@@ -2373,9 +2382,9 @@ public static void DeleteCharacterProgression(int characterId, string progressio
23732382

23742383
LootLockerServerRequest.CallAPI(endpoint, LootLockerHTTPMethod.DELETE, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
23752384
}
2376-
2385+
23772386
#endregion
2378-
2387+
23792388
#region PlayerStorage
23802389
/// <summary>
23812390
/// Get the player storage for the currently active player (key/values).
@@ -2607,7 +2616,7 @@ public static void ResetAssetCalls()
26072616
{
26082617
LootLockerAssetRequest.lastId = 0;
26092618
}
2610-
2619+
26112620
[Obsolete("This function will soon be removed. Use GetAssetInformation(int assetId, Action<LootLockerCommonAsset> onComplete) with int parameter instead")]
26122621
public static void GetAssetInformation(string assetId, Action<LootLockerCommonAsset> onComplete)
26132622
{
@@ -3305,7 +3314,7 @@ public static void RemovingFilesFromAssetCandidates(int assetCandidateID, int fi
33053314
LootLockerAPIManager.RemovingFilesFromAssetCandidates(data, onComplete);
33063315
}
33073316
#endregion
3308-
3317+
33093318
#region Progressions
33103319

33113320
/// <summary>
@@ -3333,7 +3342,7 @@ public static void GetProgressions(int count, string after, Action<LootLockerPag
33333342

33343343
LootLockerServerRequest.CallAPI(endpoint, LootLockerHTTPMethod.GET, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
33353344
}
3336-
3345+
33373346
/// <summary>
33383347
/// Returns multiple progressions.
33393348
/// </summary>
@@ -3343,7 +3352,7 @@ public static void GetProgressions(int count, Action<LootLockerPaginatedProgress
33433352
{
33443353
GetProgressions(count, null, onComplete);
33453354
}
3346-
3355+
33473356
/// <summary>
33483357
/// Returns multiple progressions.
33493358
/// </summary>
@@ -3352,7 +3361,7 @@ public static void GetProgressions(Action<LootLockerPaginatedProgressionsRespons
33523361
{
33533362
GetProgressions(-1, null, onComplete);
33543363
}
3355-
3364+
33563365
/// <summary>
33573366
/// Returns a single progression.
33583367
/// </summary>
@@ -3367,7 +3376,7 @@ public static void GetProgression(string progressionKey, Action<LootLockerProgre
33673376
}
33683377

33693378
var endpoint = string.Format(LootLockerEndPoints.getSingleProgression.endPoint, progressionKey);
3370-
3379+
33713380
LootLockerServerRequest.CallAPI(endpoint, LootLockerHTTPMethod.GET, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
33723381
}
33733382

@@ -3387,7 +3396,7 @@ public static void GetProgressionTiers(string progressionKey, int count, ulong?
33873396
}
33883397

33893398
var endpoint = string.Format(LootLockerEndPoints.getProgressionTiers.endPoint, progressionKey);
3390-
3399+
33913400
endpoint += "?";
33923401
if (count > 0)
33933402
endpoint += $"count={count}&";
@@ -3406,9 +3415,9 @@ public static void GetProgressionTiers(string progressionKey, int count, ulong?
34063415
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerPaginatedProgressionTiers</param>
34073416
public static void GetProgressionTiers(string progressionKey, int count, Action<LootLockerPaginatedProgressionTiersResponse> onComplete)
34083417
{
3409-
GetProgressionTiers(progressionKey, count, null, onComplete);
3418+
GetProgressionTiers(progressionKey, count, null, onComplete);
34103419
}
3411-
3420+
34123421
/// <summary>
34133422
/// Returns multiple progression tiers for the specified progression.
34143423
/// </summary>

0 commit comments

Comments
 (0)