Search in sources :

Example 1 with WorldMapLoader

use of net.runelite.cache.definitions.loaders.WorldMapLoader in project runelite by runelite.

the class WorldMapDumperTest 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.WORLDMAP);
        // there is also archive 1/2, but their data format is not this
        Archive archive = index.getArchive(0);
        byte[] archiveData = storage.loadArchive(archive);
        ArchiveFiles files = archive.getFiles(archiveData);
        for (FSFile file : files.getFiles()) {
            WorldMapLoader loader = new WorldMapLoader();
            WorldMapDefinition def = loader.load(file.getContents(), file.getFileId());
            Files.write(gson.toJson(def), new File(outDir, file.getFileId() + ".json"), Charset.defaultCharset());
            ++count;
        }
    }
    logger.info("Dumped {} world map data to {}", count, outDir);
}
Also used : Storage(net.runelite.cache.fs.Storage) Archive(net.runelite.cache.fs.Archive) ArchiveFiles(net.runelite.cache.fs.ArchiveFiles) WorldMapDefinition(net.runelite.cache.definitions.WorldMapDefinition) 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) WorldMapLoader(net.runelite.cache.definitions.loaders.WorldMapLoader) Test(org.junit.Test)

Aggregations

File (java.io.File)1 WorldMapDefinition (net.runelite.cache.definitions.WorldMapDefinition)1 WorldMapLoader (net.runelite.cache.definitions.loaders.WorldMapLoader)1 Archive (net.runelite.cache.fs.Archive)1 ArchiveFiles (net.runelite.cache.fs.ArchiveFiles)1 FSFile (net.runelite.cache.fs.FSFile)1 Index (net.runelite.cache.fs.Index)1 Storage (net.runelite.cache.fs.Storage)1 Store (net.runelite.cache.fs.Store)1 Test (org.junit.Test)1