|
Last change
on this file since 334 was 325, checked in by alloc, 7 years ago |
|
Code style cleanup (mostly whitespace changes, enforcing braces, using cleanup)
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | using System.Net;
|
|---|
| 2 | using AllocsFixes.JSON;
|
|---|
| 3 |
|
|---|
| 4 | namespace AllocsFixes.NetConnections.Servers.Web.API {
|
|---|
| 5 | public class GetAllowedCommands : WebAPI {
|
|---|
| 6 | public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user,
|
|---|
| 7 | int permissionLevel) {
|
|---|
| 8 | JSONObject result = new JSONObject ();
|
|---|
| 9 | JSONArray entries = new JSONArray ();
|
|---|
| 10 | foreach (IConsoleCommand cc in SdtdConsole.Instance.GetCommands ()) {
|
|---|
| 11 | AdminToolsCommandPermissions atcp =
|
|---|
| 12 | GameManager.Instance.adminTools.GetAdminToolsCommandPermission (cc.GetCommands ());
|
|---|
| 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 | }
|
|---|
| 20 |
|
|---|
| 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 | }
|
|---|
| 38 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.