Search in sources :

Example 1 with NpcLoader

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

the class NpcManager method load.

public void load() throws IOException {
    NpcLoader loader = new NpcLoader();
    Storage storage = store.getStorage();
    Index index = store.getIndex(IndexType.CONFIGS);
    Archive archive = index.getArchive(ConfigType.NPC.getId());
    byte[] archiveData = storage.loadArchive(archive);
    ArchiveFiles files = archive.getFiles(archiveData);
    for (FSFile f : files.getFiles()) {
        NpcDefinition npc = loader.load(f.getFileId(), f.getContents());
        npcs.add(npc);
    }
}
Also used : Storage(net.runelite.cache.fs.Storage) Archive(net.runelite.cache.fs.Archive) ArchiveFiles(net.runelite.cache.fs.ArchiveFiles) NpcLoader(net.runelite.cache.definitions.loaders.NpcLoader) NpcDefinition(net.runelite.cache.definitions.NpcDefinition) Index(net.runelite.cache.fs.Index) FSFile(net.runelite.cache.fs.FSFile)

Example 2 with NpcLoader

use of net.runelite.cache.definitions.loaders.NpcLoader 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)

Aggregations

NpcDefinition (net.runelite.cache.definitions.NpcDefinition)2 NpcLoader (net.runelite.cache.definitions.loaders.NpcLoader)2 ArchiveFiles (net.runelite.cache.fs.ArchiveFiles)2 FSFile (net.runelite.cache.fs.FSFile)2 Archive (net.runelite.cache.fs.Archive)1 Index (net.runelite.cache.fs.Index)1 Storage (net.runelite.cache.fs.Storage)1 ArchiveEntry (net.runelite.http.service.cache.beans.ArchiveEntry)1 NotFoundException (net.runelite.http.service.util.exception.NotFoundException)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1