Remove duplicate item entries

This filters items by name and ID.
This commit is contained in:
KingRainbow44 2023-04-08 23:46:54 -04:00
parent 32f11e29b1
commit f483fb6ea8
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE

View File

@ -140,13 +140,25 @@ public interface Dumpers {
Language.loadTextMaps();
// Convert all known items to an item map.
var dump = new HashMap<Integer, ItemData>();
GameData.getItemDataMap().forEach((id, item) -> dump.put(id, new ItemData(
var originalDump = new ArrayList<ItemData>();
GameData.getItemDataMap().forEach((id, item) -> originalDump.add(new ItemData(id,
Language.getTextMapKey(item.getNameTextMapHash()).get(locale),
Quality.from(item.getRankLevel()), item.getItemType(),
item.getIcon().length() > 0 ? item.getIcon().substring(3) : ""
)));
// Create a new dump with filtered duplicates.
var names = new ArrayList<String>();
var dump = new HashMap<Integer, ItemData>();
originalDump.forEach(item -> {
// Validate the item.
if (names.contains(item.name)) return;
if (dump.containsKey(item.id)) return;
// Add the item to the dump.
names.add(item.name);
dump.put(item.id, item);
});
try {
// Create a file for the dump.
var file = new File("items.csv");
@ -185,6 +197,7 @@ public interface Dumpers {
@AllArgsConstructor
class ItemData {
public Integer id;
public String name;
public Quality quality;
public ItemType type;