public void decompress(int[] keys) throws IOException { Container res = Container.decompress(compressedData, keys); contents = res.data; revision = res.revision; crc = res.crc; compression = res.compression; }
@Override public void close() throws IOException { storage.close(); }
public Index findIndex(int id) { for (Index i : indexes) { if (i.getId() == id) { return i; } } return null; } }
public void load() throws IOException { Storage storage = store.getStorage(); Index index = store.getIndex(IndexType.TEXTURES); Archive archive = index.getArchive(0); byte[] archiveData = storage.loadArchive(archive); ArchiveFiles files = archive.getFiles(archiveData); TextureLoader loader = new TextureLoader(); for (FSFile file : files.getFiles()) { TextureDefinition texture = loader.load(file.getFileId(), file.getContents()); textures.add(texture); } }
@Override public ModelDefinition provide(int modelId) throws IOException { Index models = store.getIndex(IndexType.MODELS); Archive archive = models.getArchive(modelId); byte[] data = archive.decompress(store.getStorage().loadArchive(archive)); ModelDefinition inventoryModel = new ModelLoader().load(modelId, data); return inventoryModel; } };
@Override public void saveArchive(Archive archive, byte[] bytes) throws IOException { data.put((long) archive.getIndex().getId() << 32 | archive.getArchiveId(), bytes); } }
public ArchiveFiles getFiles(byte[] data, int[] keys) throws IOException { byte[] decompressedData = decompress(data, keys); ArchiveFiles files = new ArchiveFiles(); for (FileData fileEntry : fileData) { FSFile file = new FSFile(fileEntry.getId()); file.setNameHash(fileEntry.getNameHash()); files.addFile(file); } files.loadContents(decompressedData); return files; }
public Archive getArchive(int id) { for (Archive a : archives) { if (a.getArchiveId() == id) { return a; } } return null; }
public ArchiveFiles getFiles(byte[] data) throws IOException { return getFiles(data, null); }
public byte[] decompress(byte[] data) throws IOException { return decompress(data, null); }
public Store(Storage storage) throws IOException { this.storage = storage; storage.init(this); }
public void load() throws IOException { storage.load(this); }
public void save() throws IOException { storage.save(this); }
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.put(f.getFileId(), npc); } }
@Override public byte[] loadArchive(Archive archive) throws IOException { return data.get((long) archive.getIndex().getId() << 32 | archive.getArchiveId()); }
public void load() throws IOException { StructLoader loader = new StructLoader(); Storage storage = store.getStorage(); Index index = store.getIndex(IndexType.CONFIGS); Archive archive = index.getArchive(ConfigType.STRUCT.getId()); byte[] archiveData = storage.loadArchive(archive); ArchiveFiles files = archive.getFiles(archiveData); for (FSFile f : files.getFiles()) { StructDefinition def = loader.load(f.getFileId(), f.getContents()); structs.put(f.getFileId(), def); } }
public void load() throws IOException { ObjectLoader loader = new ObjectLoader(); Storage storage = store.getStorage(); Index index = store.getIndex(IndexType.CONFIGS); Archive archive = index.getArchive(ConfigType.OBJECT.getId()); byte[] archiveData = storage.loadArchive(archive); ArchiveFiles files = archive.getFiles(archiveData); for (FSFile f : files.getFiles()) { ObjectDefinition def = loader.load(f.getFileId(), f.getContents()); objects.put(f.getFileId(), def); } }
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); } }
public void load() throws IOException { InventoryLoader loader = new InventoryLoader(); 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()) { InventoryDefinition inv = loader.load(file.getFileId(), file.getContents()); inventories.add(inv); } }
public void load() throws IOException { Storage storage = store.getStorage(); Index index = store.getIndex(IndexType.CONFIGS); Archive archive = index.getArchive(ConfigType.AREA.getId()); byte[] archiveData = storage.loadArchive(archive); ArchiveFiles files = archive.getFiles(archiveData); for (FSFile file : files.getFiles()) { AreaLoader loader = new AreaLoader(); AreaDefinition area = loader.load(file.getContents(), file.getFileId()); areas.put(area.id, area); } }