Last change
on this file since 346 was 325, checked in by alloc, 6 years ago |
Code style cleanup (mostly whitespace changes, enforcing braces, using cleanup)
|
File size:
1.1 KB
|
Rev | Line | |
---|
[325] | 1 | using System.Net;
|
---|
[279] | 2 | using AllocsFixes.JSON;
|
---|
| 3 |
|
---|
[325] | 4 | namespace AllocsFixes.NetConnections.Servers.Web.API {
|
---|
[279] | 5 | public class GetAllowedCommands : WebAPI {
|
---|
[325] | 6 | public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user,
|
---|
| 7 | int permissionLevel) {
|
---|
[279] | 8 | JSONObject result = new JSONObject ();
|
---|
| 9 | JSONArray entries = new JSONArray ();
|
---|
| 10 | foreach (IConsoleCommand cc in SdtdConsole.Instance.GetCommands ()) {
|
---|
[325] | 11 | AdminToolsCommandPermissions atcp =
|
---|
| 12 | GameManager.Instance.adminTools.GetAdminToolsCommandPermission (cc.GetCommands ());
|
---|
[279] | 13 | if (permissionLevel <= atcp.PermissionLevel) {
|
---|
| 14 | string cmd = string.Empty;
|
---|
| 15 | foreach (string s in cc.GetCommands ()) {
|
---|
| 16 | if (s.Length > cmd.Length) {
|
---|
| 17 | cmd = s;
|
---|
| 18 | }
|
---|
| 19 | }
|
---|
[325] | 20 |
|
---|
[279] | 21 | JSONObject cmdObj = new JSONObject ();
|
---|
| 22 | cmdObj.Add ("command", new JSONString (cmd));
|
---|
| 23 | cmdObj.Add ("description", new JSONString (cc.GetDescription ()));
|
---|
| 24 | cmdObj.Add ("help", new JSONString (cc.GetHelp ()));
|
---|
| 25 | entries.Add (cmdObj);
|
---|
| 26 | }
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | result.Add ("commands", entries);
|
---|
| 30 |
|
---|
| 31 | WriteJSON (resp, result);
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | public override int DefaultPermissionLevel () {
|
---|
| 35 | return 2000;
|
---|
| 36 | }
|
---|
| 37 | }
|
---|
[325] | 38 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.