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
|
Rev | Line | |
---|
[279] | 1 | using AllocsFixes.JSON;
|
---|
| 2 |
|
---|
[325] | 3 | namespace AllocsFixes.NetConnections.Servers.Web.API {
|
---|
[387] | 4 | public class GetAllowedCommands : AbsWebAPI {
|
---|
| 5 | public override void HandleRequest (RequestContext _context) {
|
---|
[279] | 6 | JSONObject result = new JSONObject ();
|
---|
| 7 | JSONArray entries = new JSONArray ();
|
---|
| 8 | foreach (IConsoleCommand cc in SdtdConsole.Instance.GetCommands ()) {
|
---|
[360] | 9 | int commandPermissionLevel = GameManager.Instance.adminTools.GetCommandPermissionLevel (cc.GetCommands ());
|
---|
[387] | 10 | if (_context.PermissionLevel <= commandPermissionLevel) {
|
---|
[279] | 11 | string cmd = string.Empty;
|
---|
| 12 | foreach (string s in cc.GetCommands ()) {
|
---|
| 13 | if (s.Length > cmd.Length) {
|
---|
| 14 | cmd = s;
|
---|
| 15 | }
|
---|
| 16 | }
|
---|
[325] | 17 |
|
---|
[279] | 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 |
|
---|
[387] | 28 | WebUtils.WriteJson (_context.Response, result);
|
---|
[279] | 29 | }
|
---|
| 30 |
|
---|
| 31 | public override int DefaultPermissionLevel () {
|
---|
| 32 | return 2000;
|
---|
| 33 | }
|
---|
| 34 | }
|
---|
[325] | 35 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.