use of org.apollo.game.model.entity.attr.BooleanAttribute in project apollo by apollo-rsps.
the class BinaryPlayerSerializer method readAttributes.
/**
* Reads the player's {@link Attribute}s.
*
* @param in The input stream.
* @return The {@link Map} of attribute names to attributes.
* @throws IOException If there is an error reading from the stream.
*/
private Map<String, Attribute<?>> readAttributes(DataInputStream in) throws IOException {
int count = in.readInt();
Map<String, Attribute<?>> attributes = new HashMap<>(count);
for (int times = 0; times < count; times++) {
String name = StreamUtil.readString(in);
AttributeType type = AttributeType.valueOf(in.read());
Attribute<?> attribute;
switch(type) {
case BOOLEAN:
attribute = new BooleanAttribute(in.read() == 1);
break;
case DOUBLE:
attribute = new NumericalAttribute(in.readDouble());
break;
case LONG:
attribute = new NumericalAttribute(in.readLong());
break;
case STRING:
case SYMBOL:
attribute = new StringAttribute(StreamUtil.readString(in), type == AttributeType.SYMBOL);
break;
default:
throw new IllegalArgumentException("Undefined attribute type: " + type + ".");
}
attributes.put(name, attribute);
}
return attributes;
}
Aggregations