Search in sources :

Example 16 with ArchiveFiles

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);
}
Also used : Storage(net.runelite.cache.fs.Storage) Archive(net.runelite.cache.fs.Archive) ArchiveFiles(net.runelite.cache.fs.ArchiveFiles) SequenceDefinition(net.runelite.cache.definitions.SequenceDefinition) Store(net.runelite.cache.fs.Store) Index(net.runelite.cache.fs.Index) SequenceLoader(net.runelite.cache.definitions.loaders.SequenceLoader) File(java.io.File) FSFile(net.runelite.cache.fs.FSFile) FSFile(net.runelite.cache.fs.FSFile) Test(org.junit.Test)

Example 17 with ArchiveFiles

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;
}
Also used : ArchiveFiles(net.runelite.cache.fs.ArchiveFiles) NotFoundException(net.runelite.http.service.util.exception.NotFoundException) ArchiveEntry(net.runelite.http.service.cache.beans.ArchiveEntry) ObjectDefinition(net.runelite.cache.definitions.ObjectDefinition) ObjectLoader(net.runelite.cache.definitions.loaders.ObjectLoader) FSFile(net.runelite.cache.fs.FSFile) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 18 with ArchiveFiles

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;
}
Also used : ArchiveFiles(net.runelite.cache.fs.ArchiveFiles) NpcDefinition(net.runelite.cache.definitions.NpcDefinition) NpcLoader(net.runelite.cache.definitions.loaders.NpcLoader) NotFoundException(net.runelite.http.service.util.exception.NotFoundException) ArchiveEntry(net.runelite.http.service.cache.beans.ArchiveEntry) FSFile(net.runelite.cache.fs.FSFile) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 19 with ArchiveFiles

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;
}
Also used : ArchiveFiles(net.runelite.cache.fs.ArchiveFiles) ItemDefinition(net.runelite.cache.definitions.ItemDefinition) NotFoundException(net.runelite.http.service.util.exception.NotFoundException) ArchiveEntry(net.runelite.http.service.cache.beans.ArchiveEntry) ItemLoader(net.runelite.cache.definitions.loaders.ItemLoader) FSFile(net.runelite.cache.fs.FSFile) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 20 with ArchiveFiles

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;
    }
}
Also used : Container(net.runelite.cache.fs.Container) ArchiveFiles(net.runelite.cache.fs.ArchiveFiles) Connection(org.sql2o.Connection) FileEntry(net.runelite.http.service.cache.beans.FileEntry) FSFile(net.runelite.cache.fs.FSFile)

Aggregations

ArchiveFiles (net.runelite.cache.fs.ArchiveFiles)24 FSFile (net.runelite.cache.fs.FSFile)24 Archive (net.runelite.cache.fs.Archive)18 Index (net.runelite.cache.fs.Index)18 Storage (net.runelite.cache.fs.Storage)18 File (java.io.File)9 Store (net.runelite.cache.fs.Store)9 Test (org.junit.Test)9 ArchiveEntry (net.runelite.http.service.cache.beans.ArchiveEntry)5 NotFoundException (net.runelite.http.service.util.exception.NotFoundException)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 InterfaceDefinition (net.runelite.cache.definitions.InterfaceDefinition)2 InventoryDefinition (net.runelite.cache.definitions.InventoryDefinition)2 ItemDefinition (net.runelite.cache.definitions.ItemDefinition)2 NpcDefinition (net.runelite.cache.definitions.NpcDefinition)2 ObjectDefinition (net.runelite.cache.definitions.ObjectDefinition)2 OverlayDefinition (net.runelite.cache.definitions.OverlayDefinition)2 SpriteDefinition (net.runelite.cache.definitions.SpriteDefinition)2 TextureDefinition (net.runelite.cache.definitions.TextureDefinition)2 UnderlayDefinition (net.runelite.cache.definitions.UnderlayDefinition)2