Search in sources :

Example 11 with ArchiveFiles

use of net.runelite.cache.fs.ArchiveFiles in project runelite by runelite.

the class InterfaceSaverTest method testSave.

@Test
public void testSave() throws Exception {
    File base = StoreLocation.LOCATION;
    try (Store store = new Store(base)) {
        store.load();
        Storage storage = store.getStorage();
        Index index = store.getIndex(IndexType.INTERFACES);
        Archive archive = index.getArchive(149);
        byte[] archiveData = storage.loadArchive(archive);
        ArchiveFiles files = archive.getFiles(archiveData);
        FSFile file = files.findFile(0);
        byte[] contents = file.getContents();
        InterfaceDefinition def = new InterfaceLoader().load(0, contents);
        byte[] b = new InterfaceSaver().save(def);
        assertArrayEquals(contents, b);
    }
}
Also used : Storage(net.runelite.cache.fs.Storage) Archive(net.runelite.cache.fs.Archive) ArchiveFiles(net.runelite.cache.fs.ArchiveFiles) InterfaceLoader(net.runelite.cache.definitions.loaders.InterfaceLoader) InterfaceDefinition(net.runelite.cache.definitions.InterfaceDefinition) Store(net.runelite.cache.fs.Store) Index(net.runelite.cache.fs.Index) File(java.io.File) FSFile(net.runelite.cache.fs.FSFile) FSFile(net.runelite.cache.fs.FSFile) Test(org.junit.Test)

Example 12 with ArchiveFiles

use of net.runelite.cache.fs.ArchiveFiles in project runelite by runelite.

the class EnumDumperTest method test.

@Test
public void test() throws IOException {
    File dumpDir = folder.newFolder();
    int count = 0;
    try (Store store = new Store(StoreLocation.LOCATION)) {
        store.load();
        Storage storage = store.getStorage();
        Index index = store.getIndex(IndexType.CONFIGS);
        Archive archive = index.getArchive(ConfigType.ENUM.getId());
        byte[] archiveData = storage.loadArchive(archive);
        ArchiveFiles files = archive.getFiles(archiveData);
        EnumLoader loader = new EnumLoader();
        for (FSFile file : files.getFiles()) {
            byte[] b = file.getContents();
            EnumDefinition def = loader.load(file.getFileId(), b);
            Files.write(gson.toJson(def), new File(dumpDir, file.getFileId() + ".json"), Charset.defaultCharset());
            ++count;
        }
    }
    logger.info("Dumped {} enums to {}", count, dumpDir);
}
Also used : Storage(net.runelite.cache.fs.Storage) Archive(net.runelite.cache.fs.Archive) ArchiveFiles(net.runelite.cache.fs.ArchiveFiles) Store(net.runelite.cache.fs.Store) Index(net.runelite.cache.fs.Index) EnumLoader(net.runelite.cache.definitions.loaders.EnumLoader) EnumDefinition(net.runelite.cache.definitions.EnumDefinition) File(java.io.File) FSFile(net.runelite.cache.fs.FSFile) FSFile(net.runelite.cache.fs.FSFile) Test(org.junit.Test)

Example 13 with ArchiveFiles

use of net.runelite.cache.fs.ArchiveFiles in project runelite by runelite.

the class InventoryDumper 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.INV.getId());
        byte[] archiveData = storage.loadArchive(archive);
        ArchiveFiles files = archive.getFiles(archiveData);
        for (FSFile file : files.getFiles()) {
            InventoryLoader loader = new InventoryLoader();
            InventoryDefinition inv = loader.load(file.getFileId(), file.getContents());
            Files.write(gson.toJson(inv), new File(outDir, inv.id + ".json"), Charset.defaultCharset());
            ++count;
        }
    }
    logger.info("Dumped {} inventories to {}", count, outDir);
}
Also used : Storage(net.runelite.cache.fs.Storage) Archive(net.runelite.cache.fs.Archive) ArchiveFiles(net.runelite.cache.fs.ArchiveFiles) Store(net.runelite.cache.fs.Store) Index(net.runelite.cache.fs.Index) InventoryLoader(net.runelite.cache.definitions.loaders.InventoryLoader) InventoryDefinition(net.runelite.cache.definitions.InventoryDefinition) File(java.io.File) FSFile(net.runelite.cache.fs.FSFile) FSFile(net.runelite.cache.fs.FSFile) Test(org.junit.Test)

Example 14 with ArchiveFiles

use of net.runelite.cache.fs.ArchiveFiles in project runelite by runelite.

the class KitDumperTest method test.

@Test
public void test() throws IOException {
    File dumpDir = folder.newFolder();
    int count = 0;
    try (Store store = new Store(StoreLocation.LOCATION)) {
        store.load();
        Storage storage = store.getStorage();
        Index index = store.getIndex(IndexType.CONFIGS);
        Archive archive = index.getArchive(ConfigType.IDENTKIT.getId());
        KitLoader loader = new KitLoader();
        byte[] archiveData = storage.loadArchive(archive);
        ArchiveFiles files = archive.getFiles(archiveData);
        for (FSFile file : files.getFiles()) {
            byte[] b = file.getContents();
            KitDefinition def = loader.load(file.getFileId(), b);
            Files.write(gson.toJson(def), new File(dumpDir, file.getFileId() + ".json"), Charset.defaultCharset());
            ++count;
        }
    }
    logger.info("Dumped {} kits to {}", count, dumpDir);
}
Also used : KitDefinition(net.runelite.cache.definitions.KitDefinition) Storage(net.runelite.cache.fs.Storage) Archive(net.runelite.cache.fs.Archive) ArchiveFiles(net.runelite.cache.fs.ArchiveFiles) Store(net.runelite.cache.fs.Store) Index(net.runelite.cache.fs.Index) File(java.io.File) FSFile(net.runelite.cache.fs.FSFile) KitLoader(net.runelite.cache.definitions.loaders.KitLoader) FSFile(net.runelite.cache.fs.FSFile) Test(org.junit.Test)

Example 15 with ArchiveFiles

use of net.runelite.cache.fs.ArchiveFiles in project runelite by runelite.

the class OverlayDumper 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.OVERLAY.getId());
        byte[] archiveData = storage.loadArchive(archive);
        ArchiveFiles files = archive.getFiles(archiveData);
        for (FSFile file : files.getFiles()) {
            OverlayLoader loader = new OverlayLoader();
            OverlayDefinition overlay = loader.load(file.getFileId(), file.getContents());
            Files.write(gson.toJson(overlay), new File(outDir, file.getFileId() + ".json"), Charset.defaultCharset());
            ++count;
        }
    }
    logger.info("Dumped {} overlays to {}", count, outDir);
}
Also used : Storage(net.runelite.cache.fs.Storage) Archive(net.runelite.cache.fs.Archive) ArchiveFiles(net.runelite.cache.fs.ArchiveFiles) OverlayDefinition(net.runelite.cache.definitions.OverlayDefinition) Store(net.runelite.cache.fs.Store) Index(net.runelite.cache.fs.Index) File(java.io.File) FSFile(net.runelite.cache.fs.FSFile) OverlayLoader(net.runelite.cache.definitions.loaders.OverlayLoader) FSFile(net.runelite.cache.fs.FSFile) Test(org.junit.Test)

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