Show server status to three-party game launcher

This commit is contained in:
coooookies 2022-05-11 16:54:31 +08:00 committed by Melledy
parent 6be39eafd2
commit ffd0212f94

View File

@ -4,6 +4,7 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.protobuf.ByteString;
import emu.grasscutter.GameConstants;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.Grasscutter.ServerDebugMode;
import emu.grasscutter.Grasscutter.ServerRunMode;
@ -258,6 +259,15 @@ public final class DispatchServer {
httpServer.post("/authentication/register", (req, res) -> this.getAuthHandler().handleRegister(req, res));
httpServer.post("/authentication/change_password", (req, res) -> this.getAuthHandler().handleChangePassword(req, res));
// Server Status
httpServer.get("/status/server", (req, res) -> {
int playerCount = Grasscutter.getGameServer().getPlayers().size();
String version = GameConstants.VERSION;
res.send("{\"retcode\":0,\"status\":{\"playerCount\":" + playerCount + ",\"version\":\"" + version + "\"}}");
});
// Dispatch
httpServer.get("/query_region_list", (req, res) -> {
// Log