use of delta.common.utils.files.filter.ExtensionPredicate in project lotro-tools by dmorcellet.
the class QuestsIndexBuilder method doIt.
/**
* Do build quests index.
* @return <code>true</code> if it was done, <code>false</code> otherwise.
*/
public boolean doIt() {
boolean ret = false;
if (_questsDir.exists()) {
QuestsIndex index = new QuestsIndex();
ExtensionPredicate extFilter = new ExtensionPredicate(".xml");
File[] questFiles = _questsDir.listFiles(extFilter);
if (questFiles != null) {
QuestXMLParser parser = new QuestXMLParser();
for (File questFile : questFiles) {
QuestDescription q = parser.parseXML(questFile);
String category = q.getCategory();
String key = q.getKey();
String title = q.getTitle();
int id = q.getIdentifier();
index.addQuest(category, id, key, title);
}
QuestsIndexWriter writer = new QuestsIndexWriter();
ret = writer.write(_indexFile, index, EncodingNames.UTF_8);
}
}
return ret;
}
use of delta.common.utils.files.filter.ExtensionPredicate in project lotro-tools by dmorcellet.
the class RecipesIndexBuilder method doIt.
/**
* Do build recipes index.
* @return <code>true</code> if it was done, <code>false</code> otherwise.
*/
public boolean doIt() {
boolean ret = false;
if (_recipesDir.exists()) {
RecipesIndex index = new RecipesIndex();
ExtensionPredicate extFilter = new ExtensionPredicate(".xml");
File[] recipeFiles = _recipesDir.listFiles(extFilter);
if (recipeFiles != null) {
RecipeXMLParser parser = new RecipeXMLParser();
for (File recipeFile : recipeFiles) {
Recipe recipe = parser.parseXML(recipeFile);
String profession = recipe.getProfession();
String key = recipe.getKey();
String name = recipe.getName();
// int id=recipe.getIdentifier();
int tier = recipe.getTier();
index.addRecipe(key, name, profession, tier);
}
RecipesIndexXMLWriter writer = new RecipesIndexXMLWriter();
ret = writer.write(_indexFile, index, EncodingNames.UTF_8);
}
}
return ret;
}
use of delta.common.utils.files.filter.ExtensionPredicate 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.common.utils.files.filter.ExtensionPredicate 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.common.utils.files.filter.ExtensionPredicate in project lotro-tools by dmorcellet.
the class ItemsConcat method main.
/**
* Main method.
* @param args Not used.
*/
public static void main(String[] args) {
System.out.println("Concatenation of legacy items into one file...");
File itemsDir = new File("d:\\dam\\tmp\\items");
FileFilter fileFilter = new ExtensionPredicate("xml");
File[] itemFiles = itemsDir.listFiles(fileFilter);
if (itemFiles != null) {
// BonusConverter converter=new BonusConverter();
ItemXMLParser parser = new ItemXMLParser();
List<Item> itemsList = new ArrayList<Item>();
for (File itemFile : itemFiles) {
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 = parser.parseXML(itemFile);
/*
List<String> bonuses=item.getBonus();
if (bonuses.size()>0)
{
RawBonusParser bonusParser=new RawBonusParser();
BonusManager bonusMgr=bonusParser.build(bonuses);
if (bonusParser.hasWarn())
{
String name=item.getName();
System.out.println("Item: "+id+", name="+name);
for(String bonus : bonuses)
{
System.out.println("\t"+bonus);
}
}
if (bonusMgr!=null)
{
BasicStatsSet stats=converter.getStats(bonusMgr);
item.getStats().setStats(stats);
}
}
*/
item.setIdentifier(id);
itemsList.add(item);
}
}
File toFile = new File("itemsLegacy.xml").getAbsoluteFile();
ItemXMLWriter.writeItemsFile(toFile, itemsList);
}
}
Aggregations