Last change
on this file since 341 was 325, checked in by alloc, 6 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 | using AllocsFixes.LiveData;
|
---|
4 |
|
---|
5 | namespace AllocsFixes.NetConnections.Servers.Web.API {
|
---|
6 | public class GetStats : WebAPI {
|
---|
7 | public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user,
|
---|
8 | int permissionLevel) {
|
---|
9 | JSONObject result = new JSONObject ();
|
---|
10 |
|
---|
11 | JSONObject time = new JSONObject ();
|
---|
12 | time.Add ("days", new JSONNumber (GameUtils.WorldTimeToDays (GameManager.Instance.World.worldTime)));
|
---|
13 | time.Add ("hours", new JSONNumber (GameUtils.WorldTimeToHours (GameManager.Instance.World.worldTime)));
|
---|
14 | time.Add ("minutes", new JSONNumber (GameUtils.WorldTimeToMinutes (GameManager.Instance.World.worldTime)));
|
---|
15 | result.Add ("gametime", time);
|
---|
16 |
|
---|
17 | result.Add ("players", new JSONNumber (GameManager.Instance.World.Players.Count));
|
---|
18 | result.Add ("hostiles", new JSONNumber (Hostiles.Instance.GetCount ()));
|
---|
19 | result.Add ("animals", new JSONNumber (Animals.Instance.GetCount ()));
|
---|
20 |
|
---|
21 | WriteJSON (resp, result);
|
---|
22 | }
|
---|
23 |
|
---|
24 | public override int DefaultPermissionLevel () {
|
---|
25 | return 2000;
|
---|
26 | }
|
---|
27 | }
|
---|
28 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.