mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-26 05:04:20 +00:00
Autogenerate document files
This commit is contained in:
parent
e3ed396889
commit
7fb26c3843
@ -26,6 +26,7 @@ public final class Configuration extends ConfigContainer {
|
||||
|
||||
public static final Locale LANGUAGE = config.language.language;
|
||||
public static final Locale FALLBACK_LANGUAGE = config.language.fallback;
|
||||
public static final String DOCUMENT_LANGUAGE = config.language.document;
|
||||
private static final String DATA_FOLDER = config.folderStructure.data;
|
||||
private static final String RESOURCES_FOLDER = config.folderStructure.resources;
|
||||
private static final String PLUGINS_FOLDER = config.folderStructure.plugins;
|
||||
|
@ -5,11 +5,10 @@ import static emu.grasscutter.Configuration.RESOURCE;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.ResourceLoader;
|
||||
import emu.grasscutter.data.def.AvatarData;
|
||||
import emu.grasscutter.data.def.ItemData;
|
||||
import emu.grasscutter.tools.Tools;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
import static emu.grasscutter.Configuration.DOCUMENT_LANGUAGE;
|
||||
import express.http.Request;
|
||||
import express.http.Response;
|
||||
import java.io.FileInputStream;
|
||||
@ -27,8 +26,7 @@ final class GachaMappingRequestHandler implements DocumentationHandler {
|
||||
private Map<Long, String> map;
|
||||
|
||||
GachaMappingRequestHandler() {
|
||||
ResourceLoader.loadResources();
|
||||
final String textMapFile = "TextMap/TextMap" + Tools.getLanguageOption() + ".json";
|
||||
final String textMapFile = "TextMap/TextMap" + DOCUMENT_LANGUAGE + ".json";
|
||||
try (InputStreamReader fileReader = new InputStreamReader(new FileInputStream(
|
||||
Utils.toFilePath(RESOURCE(textMapFile))), StandardCharsets.UTF_8)) {
|
||||
map = Grasscutter.getGsonFactory().fromJson(fileReader,
|
||||
|
@ -1,19 +1,16 @@
|
||||
package emu.grasscutter.server.http.documentation;
|
||||
|
||||
import static emu.grasscutter.Configuration.DATA;
|
||||
import static emu.grasscutter.Configuration.RESOURCE;
|
||||
import static emu.grasscutter.Configuration.*;
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.command.CommandMap;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.ResourceLoader;
|
||||
import emu.grasscutter.data.def.AvatarData;
|
||||
import emu.grasscutter.data.def.ItemData;
|
||||
import emu.grasscutter.data.def.MonsterData;
|
||||
import emu.grasscutter.data.def.SceneData;
|
||||
import emu.grasscutter.tools.Tools;
|
||||
import emu.grasscutter.utils.FileUtils;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
import express.http.Request;
|
||||
@ -35,7 +32,6 @@ final class HandbookRequestHandler implements DocumentationHandler {
|
||||
|
||||
|
||||
public HandbookRequestHandler() {
|
||||
ResourceLoader.loadResources();
|
||||
final File templateFile = new File(Utils.toFilePath(DATA("documentation/handbook.html")));
|
||||
if (templateFile.exists()) {
|
||||
template = new String(FileUtils.read(templateFile), StandardCharsets.UTF_8);
|
||||
@ -44,7 +40,7 @@ final class HandbookRequestHandler implements DocumentationHandler {
|
||||
template = null;
|
||||
}
|
||||
|
||||
final String textMapFile = "TextMap/TextMap" + Tools.getLanguageOption() + ".json";
|
||||
final String textMapFile = "TextMap/TextMap" + DOCUMENT_LANGUAGE + ".json";
|
||||
try (InputStreamReader fileReader = new InputStreamReader(new FileInputStream(
|
||||
Utils.toFilePath(RESOURCE(textMapFile))), StandardCharsets.UTF_8)) {
|
||||
map = Grasscutter.getGsonFactory()
|
||||
|
@ -17,7 +17,6 @@ final class RootRequestHandler implements DocumentationHandler {
|
||||
private final String template;
|
||||
|
||||
public RootRequestHandler() {
|
||||
ResourceLoader.loadResources();
|
||||
final File templateFile = new File(Utils.toFilePath(DATA("documentation/index.html")));
|
||||
if (templateFile.exists()) {
|
||||
template = new String(FileUtils.read(templateFile), StandardCharsets.UTF_8);
|
||||
|
@ -104,6 +104,7 @@ public class ConfigContainer {
|
||||
public static class Language {
|
||||
public Locale language = Locale.getDefault();
|
||||
public Locale fallback = Locale.US;
|
||||
public String document = "EN";
|
||||
}
|
||||
|
||||
public static class Account {
|
||||
|
Loading…
Reference in New Issue
Block a user