use of org.apollo.cache.def.ItemDefinition in project apollo by apollo-rsps.
the class ItemDefinitionDecoder method decode.
/**
* Decodes a single definition.
*
* @param id The item's id.
* @param buffer The buffer.
* @return The {@link ItemDefinition}.
*/
private ItemDefinition decode(int id, ByteBuffer buffer) {
ItemDefinition definition = new ItemDefinition(id);
while (true) {
int opcode = buffer.get() & 0xFF;
if (opcode == 0) {
return definition;
} else if (opcode == 1) {
buffer.getShort();
} else if (opcode == 2) {
definition.setName(BufferUtil.readString(buffer));
} else if (opcode == 3) {
definition.setDescription(BufferUtil.readString(buffer));
} else if (opcode >= 4 && opcode <= 8 || opcode == 10) {
buffer.getShort();
} else if (opcode == 11) {
definition.setStackable(true);
} else if (opcode == 12) {
definition.setValue(buffer.getInt());
} else if (opcode == 16) {
definition.setMembersOnly(true);
} else if (opcode == 23) {
buffer.getShort();
buffer.get();
} else if (opcode == 24) {
buffer.getShort();
} else if (opcode == 25) {
buffer.getShort();
buffer.get();
} else if (opcode == 26) {
buffer.getShort();
} else if (opcode >= 30 && opcode < 35) {
String str = BufferUtil.readString(buffer);
if (str.equalsIgnoreCase("hidden")) {
str = null;
}
definition.setGroundAction(opcode - 30, str);
} else if (opcode >= 35 && opcode < 40) {
definition.setInventoryAction(opcode - 35, BufferUtil.readString(buffer));
} else if (opcode == 40) {
int colourCount = buffer.get() & 0xFF;
for (int i = 0; i < colourCount; i++) {
buffer.getShort();
buffer.getShort();
}
} else if (opcode == 78 || opcode == 79 || (opcode >= 90 && opcode <= 93) || opcode == 95) {
buffer.getShort();
} else if (opcode == 97) {
definition.setNoteInfoId(buffer.getShort() & 0xFFFF);
} else if (opcode == 98) {
definition.setNoteGraphicId(buffer.getShort() & 0xFFFF);
} else if (opcode >= 100 && opcode < 110) {
buffer.getShort();
buffer.getShort();
} else if (opcode >= 110 && opcode <= 112) {
buffer.getShort();
} else if (opcode == 113 || opcode == 114) {
buffer.get();
} else if (opcode == 115) {
definition.setTeam(buffer.get() & 0xFF);
}
}
}
Aggregations