use of net.runelite.cache.fs.ArchiveFiles in project runelite by runelite.
the class SequenceDumper method extract.
@Test
public void extract() throws IOException {
File base = StoreLocation.LOCATION, outDir = folder.newFolder();
int count = 0;
try (Store store = new Store(base)) {
store.load();
Storage storage = store.getStorage();
Index index = store.getIndex(IndexType.CONFIGS);
Archive archive = index.getArchive(ConfigType.SEQUENCE.getId());
byte[] archiveData = storage.loadArchive(archive);
ArchiveFiles files = archive.getFiles(archiveData);
for (FSFile file : files.getFiles()) {
SequenceLoader loader = new SequenceLoader();
SequenceDefinition seq = loader.load(file.getFileId(), file.getContents());
Files.write(gson.toJson(seq), new File(outDir, file.getFileId() + ".json"), Charset.defaultCharset());
++count;
}
}
logger.info("Dumped {} sequences to {}", count, outDir);
}
use of net.runelite.cache.fs.ArchiveFiles in project runelite by runelite.
the class CacheController method getObject.
@RequestMapping("object/{objectId}")
public ObjectDefinition getObject(@PathVariable int objectId) throws IOException {
ArchiveEntry archiveEntry = findConfig(ConfigType.OBJECT);
ArchiveFiles archiveFiles = cacheService.getArchiveFiles(archiveEntry);
if (archiveFiles == null) {
throw new NotFoundException();
}
FSFile file = archiveFiles.findFile(objectId);
if (file == null) {
throw new NotFoundException();
}
ObjectDefinition objectdef = new ObjectLoader().load(objectId, file.getContents());
return objectdef;
}
use of net.runelite.cache.fs.ArchiveFiles in project runelite by runelite.
the class CacheController method getNpc.
@RequestMapping("npc/{npcId}")
public NpcDefinition getNpc(@PathVariable int npcId) throws IOException {
ArchiveEntry archiveEntry = findConfig(ConfigType.NPC);
ArchiveFiles archiveFiles = cacheService.getArchiveFiles(archiveEntry);
if (archiveFiles == null) {
throw new NotFoundException();
}
FSFile file = archiveFiles.findFile(npcId);
if (file == null) {
throw new NotFoundException();
}
NpcDefinition npcdef = new NpcLoader().load(npcId, file.getContents());
return npcdef;
}
use of net.runelite.cache.fs.ArchiveFiles in project runelite by runelite.
the class CacheController method getItem.
@RequestMapping("item/{itemId}")
public ItemDefinition getItem(@PathVariable int itemId) throws IOException {
ArchiveEntry archiveEntry = findConfig(ConfigType.ITEM);
ArchiveFiles archiveFiles = cacheService.getArchiveFiles(archiveEntry);
if (archiveFiles == null) {
throw new NotFoundException();
}
FSFile file = archiveFiles.findFile(itemId);
if (file == null) {
throw new NotFoundException();
}
ItemDefinition itemdef = new ItemLoader().load(itemId, file.getContents());
return itemdef;
}
use of net.runelite.cache.fs.ArchiveFiles in project runelite by runelite.
the class CacheService method getArchiveFiles.
public ArchiveFiles getArchiveFiles(ArchiveEntry archiveEntry) throws IOException {
CacheDAO cacheDao = new CacheDAO();
try (Connection con = sql2o.open();
ResultSetIterable<FileEntry> files = cacheDao.findFilesForArchive(con, archiveEntry)) {
byte[] archiveData = getArchive(archiveEntry);
if (archiveData == null) {
return null;
}
Container result = Container.decompress(archiveData, null);
if (result == null) {
return null;
}
byte[] decompressedData = result.data;
ArchiveFiles archiveFiles = new ArchiveFiles();
for (FileEntry fileEntry : files) {
FSFile file = new FSFile(fileEntry.getFileId());
archiveFiles.addFile(file);
file.setNameHash(fileEntry.getNameHash());
}
archiveFiles.loadContents(decompressedData);
return archiveFiles;
}
}
Aggregations