use of delta.games.lotro.lore.items.ItemsManager in project lotro-tools by dmorcellet.
the class UpdateItemDefinitions method main.
/**
* @param args
*/
public static void main(String[] args) {
ItemsManager mgr = ItemsManager.getInstance();
File itemsDir = LotroCoreConfig.getInstance().getItemsDir();
FileFilter fileFilter = new ExtensionPredicate("xml");
File[] itemFiles = itemsDir.listFiles(fileFilter);
if (itemFiles != null) {
for (File itemFile : itemFiles) {
String name = itemFile.getName();
name = name.substring(0, name.length() - 4);
int id = NumericTools.parseInt(name, -1);
if (id != -1) {
itemFile.delete();
mgr.getItem(Integer.valueOf(id));
}
}
}
}
use of delta.games.lotro.lore.items.ItemsManager in project lotro-tools by dmorcellet.
the class ItemsAndIconsManager method loadItems.
private void loadItems(String key) {
System.out.println("Loading item [" + key + "]");
File itemsDir = LotroCoreConfig.getInstance().getItemsDir();
if (!itemsDir.exists()) {
itemsDir.mkdirs();
}
key = Escapes.escapeIdentifier(key);
String url = "http://lorebook.lotro.com/wiki/" + key;
ItemPageParser parser = new ItemPageParser();
List<Item> items = parser.parseItemPage(url);
if ((items != null) && (items.size() > 0)) {
ItemsManager itemsManager = ItemsManager.getInstance();
for (Item item : items) {
System.out.println(item.dump());
int id = item.getIdentifier();
if (id != 0) {
itemsManager.writeItemFile(item);
} else {
_logger.warn("Item [" + key + "]: identifier=0!");
}
}
} else {
_logger.error("Cannot parse item [" + key + "] at URL [" + url + "]!");
}
}
use of delta.games.lotro.lore.items.ItemsManager 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());
}
*/
}
}
use of delta.games.lotro.lore.items.ItemsManager in project lotro-tools by dmorcellet.
the class ItemNormalization method filterItems.
/**
* Filter items that are accessible within LotroCompanion.
* @param items List to filter.
* @return a list that contains the filtered items.
*/
private List<Item> filterItems(List<Item> items) {
ItemsManager manager = new ItemsManager(items);
Set<Integer> selectedIds = new HashSet<Integer>();
// Iterate on classes then on slots to find all reachable items
for (CharacterClass cClass : CharacterClass.ALL_CLASSES) {
CharacterData c = new CharacterData();
c.setCharacterClass(cClass);
c.setLevel(105);
for (EQUIMENT_SLOT slot : EQUIMENT_SLOT.values()) {
List<Item> selectedItems = manager.getItems(c, slot);
for (Item selectedItem : selectedItems) {
selectedIds.add(Integer.valueOf(selectedItem.getIdentifier()));
}
}
}
// Essences
List<Item> essences = manager.getEssences();
for (Item essence : essences) {
selectedIds.add(Integer.valueOf(essence.getIdentifier()));
}
// Build final list
List<Item> selectedItems = new ArrayList<Item>();
for (Item item : items) {
if (selectedIds.contains(Integer.valueOf(item.getIdentifier()))) {
selectedItems.add(item);
}
}
return selectedItems;
}
use of delta.games.lotro.lore.items.ItemsManager in project lotro-companion by dmorcellet.
the class EquipmentPanelController method chooseItem.
private Item chooseItem(EQUIMENT_SLOT slot, List<Item> items) {
ItemsManager itemsManager = new ItemsManager(items);
List<Item> selectedItems = itemsManager.getItems(_toonData, slot);
ItemFilterConfiguration cfg = new ItemFilterConfiguration();
cfg.initFromItems(selectedItems);
ItemFilterController filterController = new ItemFilterController(cfg);
Filter<Item> filter = filterController.getFilter();
String id = ItemChoiceWindowController.ITEM_CHOOSER_PROPERTIES_ID + "#" + slot.name();
TypedProperties props = _parentWindow.getUserProperties(id);
ItemChoiceWindowController choiceCtrl = new ItemChoiceWindowController(_parentWindow, props, selectedItems, filter, filterController);
Item ret = choiceCtrl.editModal();
return ret;
}
Aggregations