2022-04-17 12:43:07 +00:00
|
|
|
package emu.grasscutter.tools;
|
|
|
|
|
2022-04-22 15:11:29 +00:00
|
|
|
import java.io.FileInputStream;
|
2022-04-22 18:28:34 +00:00
|
|
|
import java.io.FileOutputStream;
|
2022-04-17 12:43:07 +00:00
|
|
|
import java.io.FileReader;
|
|
|
|
import java.io.FileWriter;
|
2022-04-22 15:11:29 +00:00
|
|
|
import java.io.InputStreamReader;
|
2022-04-22 18:28:34 +00:00
|
|
|
import java.io.OutputStreamWriter;
|
2022-04-17 12:43:07 +00:00
|
|
|
import java.io.PrintWriter;
|
2022-04-22 15:11:29 +00:00
|
|
|
import java.nio.charset.StandardCharsets;
|
2022-04-17 12:43:07 +00:00
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.format.DateTimeFormatter;
|
2022-04-18 05:11:27 +00:00
|
|
|
import java.util.ArrayList;
|
2022-04-17 12:43:07 +00:00
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
import com.google.gson.reflect.TypeToken;
|
|
|
|
|
2022-04-27 04:21:57 +00:00
|
|
|
import emu.grasscutter.GameConstants;
|
2022-04-17 12:43:07 +00:00
|
|
|
import emu.grasscutter.Grasscutter;
|
2022-04-27 04:21:57 +00:00
|
|
|
import emu.grasscutter.data.GameData;
|
2022-04-17 12:43:07 +00:00
|
|
|
import emu.grasscutter.data.ResourceLoader;
|
|
|
|
import emu.grasscutter.data.def.AvatarData;
|
|
|
|
import emu.grasscutter.data.def.ItemData;
|
|
|
|
import emu.grasscutter.data.def.MonsterData;
|
2022-04-18 17:14:45 +00:00
|
|
|
import emu.grasscutter.data.def.SceneData;
|
2022-04-19 18:11:48 +00:00
|
|
|
import emu.grasscutter.utils.Utils;
|
2022-04-17 12:43:07 +00:00
|
|
|
|
2022-04-18 05:11:27 +00:00
|
|
|
public final class Tools {
|
2022-04-17 12:43:07 +00:00
|
|
|
|
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
public static void createGmHandbook() throws Exception {
|
|
|
|
ResourceLoader.loadResources();
|
|
|
|
|
|
|
|
Map<Long, String> map;
|
2022-04-22 15:11:29 +00:00
|
|
|
try (InputStreamReader fileReader = new InputStreamReader(new FileInputStream(Utils.toFilePath(Grasscutter.getConfig().RESOURCE_FOLDER + "TextMap/TextMapEN.json")), StandardCharsets.UTF_8)) {
|
2022-04-17 12:43:07 +00:00
|
|
|
map = Grasscutter.getGsonFactory().fromJson(fileReader, new TypeToken<Map<Long, String>>() {}.getType());
|
|
|
|
}
|
|
|
|
|
|
|
|
List<Integer> list;
|
|
|
|
String fileName = "./GM Handbook.txt";
|
2022-04-22 18:28:34 +00:00
|
|
|
try (PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(fileName), StandardCharsets.UTF_8), false)) {
|
2022-04-17 12:43:07 +00:00
|
|
|
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
|
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
2022-04-27 04:21:57 +00:00
|
|
|
writer.println("// Grasscutter " + GameConstants.VERSION + " GM Handbook");
|
2022-04-17 12:43:07 +00:00
|
|
|
writer.println("// Created " + dtf.format(now) + System.lineSeparator() + System.lineSeparator());
|
|
|
|
|
2022-04-27 04:21:57 +00:00
|
|
|
list = new ArrayList<>(GameData.getAvatarDataMap().keySet());
|
2022-04-17 12:43:07 +00:00
|
|
|
Collections.sort(list);
|
|
|
|
|
|
|
|
writer.println("// Avatars");
|
|
|
|
for (Integer id : list) {
|
2022-04-27 04:21:57 +00:00
|
|
|
AvatarData data = GameData.getAvatarDataMap().get(id);
|
2022-04-17 12:43:07 +00:00
|
|
|
writer.println(data.getId() + " : " + map.get(data.getNameTextMapHash()));
|
|
|
|
}
|
|
|
|
|
|
|
|
writer.println();
|
|
|
|
|
2022-04-27 04:21:57 +00:00
|
|
|
list = new ArrayList<>(GameData.getItemDataMap().keySet());
|
2022-04-17 12:43:07 +00:00
|
|
|
Collections.sort(list);
|
|
|
|
|
|
|
|
writer.println("// Items");
|
|
|
|
for (Integer id : list) {
|
2022-04-27 04:21:57 +00:00
|
|
|
ItemData data = GameData.getItemDataMap().get(id);
|
2022-04-17 12:43:07 +00:00
|
|
|
writer.println(data.getId() + " : " + map.get(data.getNameTextMapHash()));
|
|
|
|
}
|
|
|
|
|
|
|
|
writer.println();
|
|
|
|
|
2022-04-18 17:14:45 +00:00
|
|
|
writer.println("// Scenes");
|
2022-04-27 04:21:57 +00:00
|
|
|
list = new ArrayList<>(GameData.getSceneDataMap().keySet());
|
2022-04-18 17:14:45 +00:00
|
|
|
Collections.sort(list);
|
|
|
|
|
|
|
|
for (Integer id : list) {
|
2022-04-27 04:21:57 +00:00
|
|
|
SceneData data = GameData.getSceneDataMap().get(id);
|
2022-04-18 17:14:45 +00:00
|
|
|
writer.println(data.getId() + " : " + data.getScriptData());
|
|
|
|
}
|
|
|
|
|
|
|
|
writer.println();
|
|
|
|
|
2022-04-17 12:43:07 +00:00
|
|
|
writer.println("// Monsters");
|
2022-04-27 04:21:57 +00:00
|
|
|
list = new ArrayList<>(GameData.getMonsterDataMap().keySet());
|
2022-04-17 12:43:07 +00:00
|
|
|
Collections.sort(list);
|
|
|
|
|
|
|
|
for (Integer id : list) {
|
2022-04-27 04:21:57 +00:00
|
|
|
MonsterData data = GameData.getMonsterDataMap().get(id);
|
2022-04-17 12:43:07 +00:00
|
|
|
writer.println(data.getId() + " : " + map.get(data.getNameTextMapHash()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Grasscutter.getLogger().info("GM Handbook generated!");
|
|
|
|
}
|
|
|
|
}
|