mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-27 05:09:17 +00:00
Change avatar data to a CSV file
This commit is contained in:
parent
bb20d0fd80
commit
5fe304d2e8
@ -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";
|
||||
|
@ -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<Integer, ItemData>();
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user