use of org.apollo.cache.decoder.ItemDefinitionDecoder in project apollo by apollo-rsps.
the class EquipmentUpdater method main.
/**
* The entry point of the application.
*
* @param args The command line arguments.
* @throws Exception If an error occurs.
*/
public static void main(String[] args) throws Exception {
Preconditions.checkArgument(args.length == 1, "Usage:\njava -cp ... org.apollo.tools.EquipmentUpdater [release].");
String release = args[0];
try (DataOutputStream os = new DataOutputStream(new BufferedOutputStream(new FileOutputStream("data/equipment-" + release + ".dat")));
IndexedFileSystem fs = new IndexedFileSystem(Paths.get("data/fs/", release), true)) {
ItemDefinitionDecoder decoder = new ItemDefinitionDecoder(fs);
decoder.run();
int count = ItemDefinition.count();
os.writeShort(count);
for (int id = 0; id < count; id++) {
ItemDefinition definition = ItemDefinition.lookup(id);
int type = getWeaponType(definition);
os.writeByte(type);
if (type != -1) {
os.writeBoolean(isTwoHanded(definition));
os.writeBoolean(isFullBody(definition));
os.writeBoolean(isFullHat(definition));
os.writeBoolean(isFullMask(definition));
os.writeByte(getAttackRequirement(definition));
os.writeByte(getStrengthRequirement(definition));
os.writeByte(getDefenceRequirement(definition));
os.writeByte(getRangedRequirement(definition));
os.writeByte(getPrayerRequirement(definition));
os.writeByte(getMagicRequirement(definition));
}
}
}
}
use of org.apollo.cache.decoder.ItemDefinitionDecoder in project apollo by apollo-rsps.
the class World method init.
/**
* Initialises the world by loading definitions from the specified file
* system.
*
* @param release The release number.
* @param fs The file system.
* @param manager The plugin manager. TODO move this.
* @throws Exception If there was a failure when loading plugins.
*/
public void init(int release, IndexedFileSystem fs, PluginManager manager) throws Exception {
releaseNumber = release;
SynchronousDecoder firstStageDecoder = new SynchronousDecoder(new NpcDefinitionDecoder(fs), new ItemDefinitionDecoder(fs), new ObjectDefinitionDecoder(fs), new MapIndexDecoder(fs), EquipmentDefinitionParser.fromFile("data/equipment-" + release + "" + ".dat"));
firstStageDecoder.block();
SynchronousDecoder secondStageDecoder = new SynchronousDecoder(new WorldObjectsDecoder(fs, this, regions), new WorldMapDecoder(fs, collisionManager));
secondStageDecoder.block();
// Build collision matrices for the first time
collisionManager.build(false);
regions.addRegionListener(new CollisionUpdateListener(collisionManager));
// Must be exactly here because of ordering issues.
npcMovement = new NpcMovementTask(collisionManager);
scheduler.schedule(npcMovement);
manager.start();
commandDispatcher.init(manager.getAuthors());
pluginManager = manager;
}
Aggregations