mirror of
https://github.com/Anime-Game-Servers/Grasscutter-Quests.git
synced 2025-01-30 17:55:13 +00:00
[Fix] Fixed hang on fresh server install ( thx @jie65535 )
This commit is contained in:
parent
906f15c5a3
commit
27b6c7f8e3
@ -121,6 +121,9 @@ public final class Grasscutter {
|
||||
// Generate handbooks.
|
||||
Tools.createGmHandbooks();
|
||||
|
||||
// Generate gacha mappings.
|
||||
Tools.generateGachaMappings();
|
||||
|
||||
// Initialize database.
|
||||
DatabaseManager.initialize();
|
||||
|
||||
|
@ -118,8 +118,6 @@ public class DataLoader {
|
||||
} catch (Exception e) {
|
||||
logger.error("An error occurred while trying to check the data folder.", e);
|
||||
}
|
||||
|
||||
generateGachaMappings();
|
||||
}
|
||||
|
||||
private static void checkAndCopyData(String name) {
|
||||
@ -136,15 +134,4 @@ public class DataLoader {
|
||||
}
|
||||
}
|
||||
|
||||
private static void generateGachaMappings() {
|
||||
var path = GachaHandler.getGachaMappingsPath();
|
||||
if (!Files.exists(path)) {
|
||||
try {
|
||||
logger.info("Creating default '" + path.toString() + "' data");
|
||||
Tools.createGachaMappings(path);
|
||||
} catch (Exception exception) {
|
||||
logger.warn("Failed to create gacha mappings. \n" + exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.ResourceLoader;
|
||||
import emu.grasscutter.data.excels.AvatarData;
|
||||
import emu.grasscutter.data.excels.ItemData;
|
||||
import emu.grasscutter.server.http.handlers.GachaHandler;
|
||||
import emu.grasscutter.utils.Language;
|
||||
import emu.grasscutter.utils.Language.TextStrings;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntRBTreeMap;
|
||||
@ -232,8 +233,19 @@ public final class Tools {
|
||||
return sbs.stream().map(StringBuilder::toString).toList();
|
||||
}
|
||||
|
||||
public static void generateGachaMappings() {
|
||||
var path = GachaHandler.getGachaMappingsPath();
|
||||
if (!Files.exists(path)) {
|
||||
try {
|
||||
Grasscutter.getLogger().info("Creating default '{}' data", path.toString());
|
||||
Tools.createGachaMappings(path);
|
||||
} catch (Exception exception) {
|
||||
Grasscutter.getLogger().warn("Failed to create gacha mappings. \n", exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void createGachaMappings(Path location) throws IOException {
|
||||
ResourceLoader.loadResources();
|
||||
List<String> jsons = createGachaMappingJsons();
|
||||
var usedLocales = new HashSet<String>();
|
||||
StringBuilder sb = new StringBuilder("mappings = {\n");
|
||||
@ -249,14 +261,18 @@ public final class Tools {
|
||||
|
||||
Files.createDirectories(location.getParent());
|
||||
Files.writeString(location, sb);
|
||||
Grasscutter.getLogger().info("Mappings generated to " + location);
|
||||
Grasscutter.getLogger().info("Mappings generated to {}", location);
|
||||
}
|
||||
|
||||
public static List<String> getAvailableLanguage() {
|
||||
List<String> availableLangList = new ArrayList<>();
|
||||
try {
|
||||
Files.newDirectoryStream(getResourcePath("TextMap"), "TextMap*.json").forEach(path -> {
|
||||
availableLangList.add(path.getFileName().toString().replace("TextMap", "").replace(".json", "").toLowerCase());
|
||||
try(val stream = Files.newDirectoryStream(getResourcePath("TextMap"), "TextMap*.json")) {
|
||||
stream.forEach(path -> {
|
||||
val lang = path.getFileName().toString()
|
||||
.replace("TextMap", "")
|
||||
.replace(".json", "")
|
||||
.toLowerCase();
|
||||
availableLangList.add(lang);
|
||||
});
|
||||
} catch (IOException e) {
|
||||
Grasscutter.getLogger().error("Failed to get available languages:", e);
|
||||
|
Loading…
x
Reference in New Issue
Block a user