mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-16 08:56:04 +01:00
Fix announcement display
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package emu.grasscutter.server.dispatch;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import express.http.HttpContextHandler;
|
||||
import express.http.Request;
|
||||
import express.http.Response;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
public final class AnnouncementHandler implements HttpContextHandler {
|
||||
@Override
|
||||
public void handle(Request request, Response response) throws IOException {//event
|
||||
if (Objects.equals(request.baseUrl(), "/common/hk4e_global/announcement/api/getAnnContent")) {
|
||||
response.send("{\"retcode\":0,\"message\":\"OK\",\"data\":" + readToString(new File(Grasscutter.getConfig().DATA_FOLDER + "GameAnnouncement.json")) +"}");
|
||||
} else if (Objects.equals(request.baseUrl(), "/common/hk4e_global/announcement/api/getAnnList")) {
|
||||
String data = readToString(new File(Grasscutter.getConfig().DATA_FOLDER + "GameAnnouncementList.json")).replace("System.currentTimeMillis()",String.valueOf(System.currentTimeMillis()));
|
||||
response.send("{\"retcode\":0,\"message\":\"OK\",\"data\": "+data +"}");
|
||||
}
|
||||
}
|
||||
private static String readToString(File file) {
|
||||
Long filelength = file.length();
|
||||
byte[] filecontent = new byte[filelength.intValue()];
|
||||
try {
|
||||
FileInputStream in = new FileInputStream(file);
|
||||
in.read(filecontent);
|
||||
in.close();
|
||||
} catch (IOException fileNotFoundException) {
|
||||
fileNotFoundException.printStackTrace();
|
||||
}
|
||||
return new String(filecontent);
|
||||
}
|
||||
}
|
||||
@@ -408,9 +408,9 @@ public final class DispatchServer {
|
||||
// hk4e-api-os.hoyoverse.com
|
||||
httpServer.all("/common/hk4e_global/announcement/api/getAlertAnn", new DispatchHttpJsonHandler("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"alert\":false,\"alert_id\":0,\"remind\":true}}"));
|
||||
// hk4e-api-os.hoyoverse.com
|
||||
httpServer.all("/common/hk4e_global/announcement/api/getAnnList", new DispatchHttpJsonHandler("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"list\":[],\"total\":0,\"type_list\":[],\"alert\":false,\"alert_id\":0,\"timezone\":0,\"t\":\"" + System.currentTimeMillis() + "\"}}"));
|
||||
httpServer.all("/common/hk4e_global/announcement/api/getAnnList", new AnnouncementHandler());
|
||||
// hk4e-api-os-static.hoyoverse.com
|
||||
httpServer.all("/common/hk4e_global/announcement/api/getAnnContent", new DispatchHttpJsonHandler("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"list\":[],\"total\":0}}"));
|
||||
httpServer.all("/common/hk4e_global/announcement/api/getAnnContent", new AnnouncementHandler());
|
||||
// hk4e-sdk-os.hoyoverse.com
|
||||
httpServer.all("/hk4e_global/mdk/shopwindow/shopwindow/listPriceTier", new DispatchHttpJsonHandler("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"suggest_currency\":\"USD\",\"tiers\":[]}}"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user