Last change
on this file since 422 was 420, checked in by alloc, 20 months ago |
A21 preparations.
NOT COMPATIBLE WITH A20 ANYMORE!
|
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 | int commandPermissionLevel = GameManager.Instance.adminTools.Commands.GetCommandPermissionLevel (cc.GetCommands ());
|
---|
12 | if (_permissionLevel <= commandPermissionLevel) {
|
---|
13 | string cmd = string.Empty;
|
---|
14 | foreach (string s in cc.GetCommands ()) {
|
---|
15 | if (s.Length > cmd.Length) {
|
---|
16 | cmd = s;
|
---|
17 | }
|
---|
18 | }
|
---|
19 |
|
---|
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 |
|
---|
30 | WriteJSON (_resp, result);
|
---|
31 | }
|
---|
32 |
|
---|
33 | public override int DefaultPermissionLevel () {
|
---|
34 | return 2000;
|
---|
35 | }
|
---|
36 | }
|
---|
37 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.