From 5fe304d2e877aa9ee6a32d47a8d4446467abe326 Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Thu, 6 Apr 2023 18:45:47 -0400 Subject: [PATCH] Change avatar data to a CSV file --- src/handbook/src/backend/data.ts | 2 +- .../java/emu/grasscutter/tools/Dumpers.java | 20 ++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/handbook/src/backend/data.ts b/src/handbook/src/backend/data.ts index 159ba7d95..97a7e80fa 100644 --- a/src/handbook/src/backend/data.ts +++ b/src/handbook/src/backend/data.ts @@ -1,5 +1,5 @@ -import avatars from "@data/avatars.json"; import commands from "@data/commands.json"; +import avatars from "@data/avatars.csv"; import items from "@data/items.csv"; import type { Command, Avatar, Item } from "@backend/types"; diff --git a/src/main/java/emu/grasscutter/tools/Dumpers.java b/src/main/java/emu/grasscutter/tools/Dumpers.java index 268a6ec33..130d9ab3f 100644 --- a/src/main/java/emu/grasscutter/tools/Dumpers.java +++ b/src/main/java/emu/grasscutter/tools/Dumpers.java @@ -108,21 +108,20 @@ public interface Dumpers { var langHash = avatar.getNameTextMapHash(); dump.put(id, new AvatarInfo( langHash == 0 ? avatar.getName() : Language.getTextMapKey(langHash).get(locale), - avatar.getQualityType().equals("QUALITY_PURPLE") ? Quality.EPIC : Quality.LEGENDARY, - avatar.getId() + avatar.getQualityType().equals("QUALITY_PURPLE") ? Quality.EPIC : Quality.LEGENDARY )); }); try { // Create a file for the dump. - var file = new File("avatars.json"); + var file = new File("avatars.csv"); if (file.exists() && !file.delete()) throw new RuntimeException("Failed to delete file."); if (!file.exists() && !file.createNewFile()) throw new RuntimeException("Failed to create file."); // Write the dump to the file. - Files.writeString(file.toPath(), JsonUtils.encode(dump)); + Files.writeString(file.toPath(), Dumpers.miniEncode(dump)); } catch (IOException ignored) { throw new RuntimeException("Failed to write to file."); } @@ -141,7 +140,7 @@ public interface Dumpers { // Convert all known items to an item map. var dump = new HashMap(); GameData.getItemDataMap().forEach((id, item) -> dump.put(id, new ItemData( - item.getId(), Language.getTextMapKey(item.getNameTextMapHash()).get(locale), + Language.getTextMapKey(item.getNameTextMapHash()).get(locale), Quality.from(item.getRankLevel()), item.getItemType() ))); @@ -173,20 +172,23 @@ public interface Dumpers { class AvatarInfo { public String name; public Quality quality; - public int id; + + @Override + public String toString() { + return this.name + "," + + this.quality; + } } @AllArgsConstructor class ItemData { - public int id; public String name; public Quality quality; public ItemType type; @Override public String toString() { - return this.id + "," - + this.name + "," + return this.name + "," + this.quality + "," + this.type; }