Format code [skip actions]

This commit is contained in:
github-actions 2023-05-17 00:08:26 +00:00
parent 38b7c2d0d3
commit e63a94bf19
2 changed files with 29 additions and 27 deletions

View File

@ -9,8 +9,6 @@ import emu.grasscutter.game.inventory.ItemType;
import emu.grasscutter.game.props.SceneType; import emu.grasscutter.game.props.SceneType;
import emu.grasscutter.utils.JsonUtils; import emu.grasscutter.utils.JsonUtils;
import emu.grasscutter.utils.Language; import emu.grasscutter.utils.Language;
import lombok.AllArgsConstructor;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
@ -19,6 +17,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import lombok.AllArgsConstructor;
public interface Dumpers { public interface Dumpers {
// See `src/handbook/data/README.md` for attributions. // See `src/handbook/data/README.md` for attributions.
@ -284,26 +283,32 @@ public interface Dumpers {
// Convert all known quests to a quest map. // Convert all known quests to a quest map.
var dump = new HashMap<Integer, QuestInfo>(); var dump = new HashMap<Integer, QuestInfo>();
GameData.getQuestDataMap().forEach((id, quest) -> { GameData.getQuestDataMap()
var langHash = quest.getDescTextMapHash(); .forEach(
dump.put(id, new QuestInfo( (id, quest) -> {
langHash == 0 ? "Unknown" : var langHash = quest.getDescTextMapHash();
Language.getTextMapKey(langHash).get(locale) dump.put(
.replaceAll(",", "\\\\"), id,
quest.getMainId() new QuestInfo(
)); langHash == 0
}); ? "Unknown"
: Language.getTextMapKey(langHash).get(locale).replaceAll(",", "\\\\"),
quest.getMainId()));
});
// Convert all known main quests into a quest map. // Convert all known main quests into a quest map.
var mainDump = new HashMap<Integer, MainQuestInfo>(); var mainDump = new HashMap<Integer, MainQuestInfo>();
GameData.getMainQuestDataMap().forEach((id, mainQuest) -> { GameData.getMainQuestDataMap()
var langHash = mainQuest.getTitleTextMapHash(); .forEach(
mainDump.put(id, new MainQuestInfo( (id, mainQuest) -> {
langHash == 0 ? "Unknown" : var langHash = mainQuest.getTitleTextMapHash();
Language.getTextMapKey(langHash).get(locale) mainDump.put(
.replaceAll(",", "\\\\") id,
)); new MainQuestInfo(
}); langHash == 0
? "Unknown"
: Language.getTextMapKey(langHash).get(locale).replaceAll(",", "\\\\")));
});
try { try {
// Create a file for the dump. // Create a file for the dump.
@ -313,8 +318,7 @@ public interface Dumpers {
throw new RuntimeException("Failed to create file."); throw new RuntimeException("Failed to create file.");
// Write the dump to the file. // Write the dump to the file.
Files.writeString(file.toPath(), Dumpers.miniEncode(dump, Files.writeString(file.toPath(), Dumpers.miniEncode(dump, "id", "description", "mainId"));
"id", "description", "mainId"));
} catch (IOException ignored) { } catch (IOException ignored) {
throw new RuntimeException("Failed to write to file."); throw new RuntimeException("Failed to write to file.");
} }
@ -327,8 +331,7 @@ public interface Dumpers {
throw new RuntimeException("Failed to create file."); throw new RuntimeException("Failed to create file.");
// Write the dump to the file. // Write the dump to the file.
Files.writeString(file.toPath(), Dumpers.miniEncode(mainDump, Files.writeString(file.toPath(), Dumpers.miniEncode(mainDump, "id", "title"));
"id", "title"));
} catch (IOException ignored) { } catch (IOException ignored) {
throw new RuntimeException("Failed to write to file."); throw new RuntimeException("Failed to write to file.");
} }

View File

@ -1,18 +1,17 @@
package emu.grasscutter.utils; package emu.grasscutter.utils;
import static emu.grasscutter.config.Configuration.*;
import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.Logger;
import emu.grasscutter.BuildConfig; import emu.grasscutter.BuildConfig;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.net.packet.PacketOpcodesUtils; import emu.grasscutter.net.packet.PacketOpcodesUtils;
import emu.grasscutter.tools.Dumpers; import emu.grasscutter.tools.Dumpers;
import org.slf4j.LoggerFactory;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
import org.slf4j.LoggerFactory;
import static emu.grasscutter.config.Configuration.*;
/** A parser for start-up arguments. */ /** A parser for start-up arguments. */
public final class StartupArguments { public final class StartupArguments {