source: binary-improvements/MapRendering/API/GetAllowedCommands.cs@ 454

Last change on this file since 454 was 454, checked in by alloc, 16 months ago

24_29_43
Switched over to vanilla Web infrastructure

File size: 1.1 KB
RevLine 
[279]1using AllocsFixes.JSON;
[454]2using Webserver;
3using Webserver.WebAPI;
[279]4
[454]5namespace AllocsFixes.WebAPIs {
6 public class GetAllowedCommands : AbsWebAPI {
7 public override void HandleRequest (RequestContext _context) {
[279]8 JSONObject result = new JSONObject ();
9 JSONArray entries = new JSONArray ();
10 foreach (IConsoleCommand cc in SdtdConsole.Instance.GetCommands ()) {
[420]11 int commandPermissionLevel = GameManager.Instance.adminTools.Commands.GetCommandPermissionLevel (cc.GetCommands ());
[454]12 if (_context.PermissionLevel <= commandPermissionLevel) {
[279]13 string cmd = string.Empty;
14 foreach (string s in cc.GetCommands ()) {
15 if (s.Length > cmd.Length) {
16 cmd = s;
17 }
18 }
[325]19
[279]20 JSONObject cmdObj = new JSONObject ();
21 cmdObj.Add ("command", new JSONString (cmd));
22 cmdObj.Add ("description", new JSONString (cc.GetDescription ()));
23 cmdObj.Add ("help", new JSONString (cc.GetHelp ()));
24 entries.Add (cmdObj);
25 }
26 }
27
28 result.Add ("commands", entries);
29
[454]30 LegacyApiHelper.WriteJSON (_context.Response, result);
[279]31 }
32
33 public override int DefaultPermissionLevel () {
34 return 2000;
35 }
36 }
[325]37}
Note: See TracBrowser for help on using the repository browser.