Last change
on this file since 457 was 425, checked in by alloc, 20 months ago |
- API "map" added, currently only supports GET with the ID "config"
- API "player" added, currently only supports getting online players with some of the info not supported yet (playtime, last online, level)
- Only logged in player's data is shown unless the user has the permission for "webapi.viewallplayers"
- Internal refactoring
- (Updated version to 21.0.258)
|
File size:
913 bytes
|
Line | |
---|
1 | using JetBrains.Annotations;
|
---|
2 | using Webserver;
|
---|
3 | using Webserver.UrlHandlers;
|
---|
4 |
|
---|
5 | namespace MapRendering {
|
---|
6 | [UsedImplicitly]
|
---|
7 | public class ModApi : IModApi {
|
---|
8 | public void InitMod (Mod _modInstance) {
|
---|
9 | ModEvents.GameStartDone.RegisterHandler (GameStartDone);
|
---|
10 |
|
---|
11 | Web.ServerInitialized += _web => {
|
---|
12 | if (!MapRenderer.Enabled) {
|
---|
13 | return;
|
---|
14 | }
|
---|
15 |
|
---|
16 | _web.RegisterPathHandler ("/map/", new StaticHandler (
|
---|
17 | $"{GameIO.GetSaveGameDir ()}/map",
|
---|
18 | MapRenderer.GetTileCache (),
|
---|
19 | false,
|
---|
20 | "web.map")
|
---|
21 | );
|
---|
22 | };
|
---|
23 | }
|
---|
24 |
|
---|
25 | private void GameStartDone () {
|
---|
26 | if (!MapRenderer.Enabled) {
|
---|
27 | return;
|
---|
28 | }
|
---|
29 |
|
---|
30 | ModEvents.GameShutdown.RegisterHandler (GameShutdown);
|
---|
31 | ModEvents.CalcChunkColorsDone.RegisterHandler (CalcChunkColorsDone);
|
---|
32 | }
|
---|
33 |
|
---|
34 | private void GameShutdown () {
|
---|
35 | MapRenderer.Shutdown ();
|
---|
36 | }
|
---|
37 |
|
---|
38 | private void CalcChunkColorsDone (Chunk _chunk) {
|
---|
39 | MapRenderer.RenderSingleChunk (_chunk);
|
---|
40 | }
|
---|
41 | }
|
---|
42 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.