source: binary-improvements2/WebServer/src/WebAPI/GetPlayerInventories.cs@ 391

Last change on this file since 391 was 391, checked in by alloc, 2 years ago

Major refactoring/cleanup

File size: 842 bytes
Line 
1using System.Collections.Generic;
2using AllocsFixes.JSON;
3using AllocsFixes.PersistentData;
4using JetBrains.Annotations;
5
6namespace Webserver.WebAPI {
7 [UsedImplicitly]
8 public class GetPlayerInventories : AbsWebAPI {
9 public override void HandleRequest (RequestContext _context) {
10 GetPlayerInventory.GetInventoryArguments (_context.Request, out bool showIconColor, out bool showIconName);
11
12 JsonArray allInventoriesResult = new JsonArray ();
13
14 foreach ((PlatformUserIdentifierAbs userId, Player player) in PersistentContainer.Instance.Players.Dict) {
15 if (player == null) {
16 continue;
17 }
18
19 if (player.IsOnline) {
20 allInventoriesResult.Add (GetPlayerInventory.DoPlayer (userId.CombinedString, player, showIconColor, showIconName));
21 }
22 }
23
24 WebUtils.WriteJson (_context.Response, allInventoriesResult);
25 }
26 }
27}
Note: See TracBrowser for help on using the repository browser.