use of com.ostracker.cache.dumpers.ItemDefinitionSerializer in project ostracker by OSTracker.
the class OSTracker method main.
/**
* -s [version] = load a cache from the cache store.
* If this argument isn't provided, it loads it from user.home/jagexcache/oldschool/LIVE
*
* -o = dump a file even if it has already been dumped
*/
public static void main(String[] args) {
try {
String sourceVersion = null;
boolean overwriteFiles = false;
for (int i = 0; i < args.length; i++) {
switch(args[i]) {
case "-s":
sourceVersion = args[i + 1];
break;
case "-o":
overwriteFiles = true;
break;
}
}
if (sourceVersion == null) {
putHomeCacheInLiveStore();
} else {
putCacheInLiveStore(sourceVersion);
}
Store cacheStore = new Store(LIVE_CACHE_STORE);
cacheStore.load();
String worldHost = GameConnectionUtil.getBestWorldHost();
RemoteCache remoteCache = new RemoteCache();
remoteCache.connect(worldHost, GameConnectionUtil.GAME_PORT);
remoteCache.shakeHands(GameConnectionUtil.getRevision(worldHost));
remoteCache.download(cacheStore);
remoteCache.close();
cacheStore.save();
cacheStore.close();
// Reload cache to update file contents
cacheStore = new Store(LIVE_CACHE_STORE);
cacheStore.load();
// Dump item definitions
ItemFileLoader itemFileLoader = new ItemFileLoader(cacheStore);
ItemDefinitionSerializer itemDefinitionSerializer = new ItemDefinitionSerializer(itemFileLoader);
for (Integer itemId : itemFileLoader.getItemIds()) {
itemDefinitionSerializer.dump(itemId, overwriteFiles);
}
// Dump NPC definitions
NpcFileLoader npcFileLoader = new NpcFileLoader(cacheStore);
NpcDefinitionSerializer npcDefinitionSerializer = new NpcDefinitionSerializer(npcFileLoader);
for (Integer npcId : npcFileLoader.getNpcIds()) {
npcDefinitionSerializer.dump(npcId, overwriteFiles);
}
// Dump models
ModelFileLoader modelFileLoader = new ModelFileLoader(cacheStore);
ModelConverter modelConverter = new ModelConverter(modelFileLoader);
for (Integer modelId : modelFileLoader.getModelFiles().keySet()) {
modelConverter.convert(modelId, overwriteFiles);
}
// Dump sprites
SpriteDumper spriteDumper = new SpriteDumper(modelFileLoader);
for (Integer spriteId : modelFileLoader.getSpriteFiles().keySet()) {
spriteDumper.dump(spriteId, overwriteFiles);
}
int cacheVersion = CacheStoreUtil.getCacheVersion(cacheStore);
cacheStore.close();
putLiveCacheInCacheStore(cacheVersion);
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations