Search in sources :

Example 1 with ItemLoader

use of net.runelite.cache.definitions.loaders.ItemLoader 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 2 with ItemLoader

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

the class ItemManager method load.

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

Aggregations

ItemDefinition (net.runelite.cache.definitions.ItemDefinition)2 ItemLoader (net.runelite.cache.definitions.loaders.ItemLoader)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