use of delta.games.lotro.lore.items.bonus.BonusManager in project lotro-tools by dmorcellet.
the class ItemsDbLoader method main.
/**
* Main method.
* @param args Not used.
*/
public static void main(String[] args) {
LotroDataSource ds = LotroDataSource.getInstance("lotro");
ObjectsManager<Item> itemsSource = ds.getManager(Item.class);
ItemsManager mgr = ItemsManager.getInstance();
File itemsDir = LotroCoreConfig.getInstance().getItemsDir();
FileFilter fileFilter = new ExtensionPredicate("xml");
File[] itemFiles = itemsDir.listFiles(fileFilter);
if (itemFiles != null) {
HashMap<String, IntegerHolder> other = new HashMap<String, IntegerHolder>();
// HashMap<String,List<String>> itemsByCategory=new HashMap<String,List<String>>();
for (File itemFile : itemFiles) {
// if (nb==10000) break;
String idStr = itemFile.getName();
idStr = idStr.substring(0, idStr.length() - 4);
int id = NumericTools.parseInt(idStr, -1);
if (id != -1) {
System.out.println(id);
Item item = mgr.getItem(Integer.valueOf(id));
// System.out.println(item.dump());
BonusManager bonusMgr = item.getBonusManager();
if (bonusMgr != null) {
// System.out.println(bonusMgr.dump());
int nbBonus = bonusMgr.getNumberOfBonus();
for (int i = 0; i < nbBonus; i++) {
Bonus bonus = bonusMgr.getBonusAt(i);
if (bonus.getBonusType() == BonusType.OTHER) {
String value = (String) bonus.getValue();
IntegerHolder holder = other.get(value);
if (holder == null) {
holder = new IntegerHolder();
other.put(value, holder);
}
holder.setInt(holder.getInt() + 1);
}
}
}
itemsSource.create(item);
}
// nb++;
}
List<String> others = new ArrayList<String>(other.keySet());
Collections.sort(others);
for (String value : others) {
IntegerHolder counter = other.get(value);
System.out.println(value + " -> " + counter);
}
/*
for(Map.Entry<String,IntegerHolder> entry : other.entrySet())
{
System.out.println(entry.getKey()+" -> "+entry.getValue());
}
*/
}
}
Aggregations