Last change
on this file since 387 was 387, checked in by alloc, 2 years ago |
Big refactoring in Web to pass around a Context instead of a bunch of individual arguments all the time
|
File size:
1.1 KB
|
Line | |
---|
1 | using AllocsFixes.JSON;
|
---|
2 |
|
---|
3 | namespace AllocsFixes.NetConnections.Servers.Web.API {
|
---|
4 | public class GetAllowedCommands : AbsWebAPI {
|
---|
5 | public override void HandleRequest (RequestContext _context) {
|
---|
6 | JSONObject result = new JSONObject ();
|
---|
7 | JSONArray entries = new JSONArray ();
|
---|
8 | foreach (IConsoleCommand cc in SdtdConsole.Instance.GetCommands ()) {
|
---|
9 | int commandPermissionLevel = GameManager.Instance.adminTools.GetCommandPermissionLevel (cc.GetCommands ());
|
---|
10 | if (_context.PermissionLevel <= commandPermissionLevel) {
|
---|
11 | string cmd = string.Empty;
|
---|
12 | foreach (string s in cc.GetCommands ()) {
|
---|
13 | if (s.Length > cmd.Length) {
|
---|
14 | cmd = s;
|
---|
15 | }
|
---|
16 | }
|
---|
17 |
|
---|
18 | JSONObject cmdObj = new JSONObject ();
|
---|
19 | cmdObj.Add ("command", new JSONString (cmd));
|
---|
20 | cmdObj.Add ("description", new JSONString (cc.GetDescription ()));
|
---|
21 | cmdObj.Add ("help", new JSONString (cc.GetHelp ()));
|
---|
22 | entries.Add (cmdObj);
|
---|
23 | }
|
---|
24 | }
|
---|
25 |
|
---|
26 | result.Add ("commands", entries);
|
---|
27 |
|
---|
28 | WebUtils.WriteJson (_context.Response, result);
|
---|
29 | }
|
---|
30 |
|
---|
31 | public override int DefaultPermissionLevel () {
|
---|
32 | return 2000;
|
---|
33 | }
|
---|
34 | }
|
---|
35 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.