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 commands from "@data/commands.json";
|
||||||
|
import avatars from "@data/avatars.csv";
|
||||||
import items from "@data/items.csv";
|
import items from "@data/items.csv";
|
||||||
|
|
||||||
import type { Command, Avatar, Item } from "@backend/types";
|
import type { Command, Avatar, Item } from "@backend/types";
|
||||||
|
@ -108,21 +108,20 @@ public interface Dumpers {
|
|||||||
var langHash = avatar.getNameTextMapHash();
|
var langHash = avatar.getNameTextMapHash();
|
||||||
dump.put(id, new AvatarInfo(
|
dump.put(id, new AvatarInfo(
|
||||||
langHash == 0 ? avatar.getName() : Language.getTextMapKey(langHash).get(locale),
|
langHash == 0 ? avatar.getName() : Language.getTextMapKey(langHash).get(locale),
|
||||||
avatar.getQualityType().equals("QUALITY_PURPLE") ? Quality.EPIC : Quality.LEGENDARY,
|
avatar.getQualityType().equals("QUALITY_PURPLE") ? Quality.EPIC : Quality.LEGENDARY
|
||||||
avatar.getId()
|
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Create a file for the dump.
|
// Create a file for the dump.
|
||||||
var file = new File("avatars.json");
|
var file = new File("avatars.csv");
|
||||||
if (file.exists() && !file.delete())
|
if (file.exists() && !file.delete())
|
||||||
throw new RuntimeException("Failed to delete file.");
|
throw new RuntimeException("Failed to delete file.");
|
||||||
if (!file.exists() && !file.createNewFile())
|
if (!file.exists() && !file.createNewFile())
|
||||||
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(), JsonUtils.encode(dump));
|
Files.writeString(file.toPath(), Dumpers.miniEncode(dump));
|
||||||
} catch (IOException ignored) {
|
} catch (IOException ignored) {
|
||||||
throw new RuntimeException("Failed to write to file.");
|
throw new RuntimeException("Failed to write to file.");
|
||||||
}
|
}
|
||||||
@ -141,7 +140,7 @@ public interface Dumpers {
|
|||||||
// Convert all known items to an item map.
|
// Convert all known items to an item map.
|
||||||
var dump = new HashMap<Integer, ItemData>();
|
var dump = new HashMap<Integer, ItemData>();
|
||||||
GameData.getItemDataMap().forEach((id, item) -> dump.put(id, new 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()
|
Quality.from(item.getRankLevel()), item.getItemType()
|
||||||
)));
|
)));
|
||||||
|
|
||||||
@ -173,20 +172,23 @@ public interface Dumpers {
|
|||||||
class AvatarInfo {
|
class AvatarInfo {
|
||||||
public String name;
|
public String name;
|
||||||
public Quality quality;
|
public Quality quality;
|
||||||
public int id;
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.name + ","
|
||||||
|
+ this.quality;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
class ItemData {
|
class ItemData {
|
||||||
public int id;
|
|
||||||
public String name;
|
public String name;
|
||||||
public Quality quality;
|
public Quality quality;
|
||||||
public ItemType type;
|
public ItemType type;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.id + ","
|
return this.name + ","
|
||||||
+ this.name + ","
|
|
||||||
+ this.quality + ","
|
+ this.quality + ","
|
||||||
+ this.type;
|
+ this.type;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user