Set the maximum number of player on the server through the config.json (#1001)

* Show server status to three-party game launcher

* Set the maximum number of player on the server through the config.json

* modify the logical order and show the number of maxplayer to API /status/server

* Now even players who have token already cannot bypass the maxPlayer check
This commit is contained in:
ButterCookies
2022-05-20 20:47:47 +08:00
committed by GitHub
parent 2a467a48dc
commit 9125bacfce
8 changed files with 128 additions and 77 deletions

View File

@@ -9,6 +9,8 @@ import express.http.Request;
import express.http.Response;
import io.javalin.Javalin;
import static emu.grasscutter.Configuration.ACCOUNT;
/**
* Handles all generic, hard-coded responses.
*/
@@ -48,8 +50,9 @@ public final class GenericHandler implements Router {
private static void serverStatus(Request request, Response response) {
int playerCount = Grasscutter.getGameServer().getPlayers().size();
int maxPlayer = ACCOUNT.maxPlayer;
String version = GameConstants.VERSION;
response.send("{\"retcode\":0,\"status\":{\"playerCount\":" + playerCount + ",\"version\":\"" + version + "\"}}");
response.send("{\"retcode\":0,\"status\":{\"playerCount\":" + playerCount + ",\"maxPlayer\":" + maxPlayer + ",\"version\":\"" + version + "\"}}");
}
}