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

Last change on this file since 322 was 279, checked in by alloc, 8 years ago

Mod stuff

File size: 1.2 KB
RevLine 
[279]1using AllocsFixes.JSON;
2using AllocsFixes.PersistentData;
3using System;
4using System.Collections.Generic;
5using System.Net;
6
7namespace AllocsFixes.NetConnections.Servers.Web.API
8{
9 public class GetAllowedCommands : WebAPI {
10 public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, int permissionLevel) {
11 JSONObject result = new JSONObject ();
12 JSONArray entries = new JSONArray ();
13 foreach (IConsoleCommand cc in SdtdConsole.Instance.GetCommands ()) {
14 AdminToolsCommandPermissions atcp = GameManager.Instance.adminTools.GetAdminToolsCommandPermission (cc.GetCommands ());
15 if (permissionLevel <= atcp.PermissionLevel) {
16 string cmd = string.Empty;
17 foreach (string s in cc.GetCommands ()) {
18 if (s.Length > cmd.Length) {
19 cmd = s;
20 }
21 }
22 JSONObject cmdObj = new JSONObject ();
23 cmdObj.Add ("command", new JSONString (cmd));
24 cmdObj.Add ("description", new JSONString (cc.GetDescription ()));
25 cmdObj.Add ("help", new JSONString (cc.GetHelp ()));
26 entries.Add (cmdObj);
27 }
28 }
29
30 result.Add ("commands", entries);
31
32 WriteJSON (resp, result);
33 }
34
35 public override int DefaultPermissionLevel () {
36 return 2000;
37 }
38 }
39}
40
Note: See TracBrowser for help on using the repository browser.