Line | |
---|
1 | using AllocsFixes.JSON;
|
---|
2 | using AllocsFixes.PersistentData;
|
---|
3 | using System;
|
---|
4 | using System.Collections.Generic;
|
---|
5 | using System.Net;
|
---|
6 |
|
---|
7 | namespace 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.