From 9118f9c14a8c71b66828be07a54d334f59e927d0 Mon Sep 17 00:00:00 2001 From: Major- Date: Sat, 19 Jul 2014 04:43:13 +0100 Subject: [PATCH] Actually add saving support. --- .../io/player/impl/BinaryPlayerSaver.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/org/apollo/io/player/impl/BinaryPlayerSaver.java b/src/org/apollo/io/player/impl/BinaryPlayerSaver.java index 6e9644c4..b530c0ad 100644 --- a/src/org/apollo/io/player/impl/BinaryPlayerSaver.java +++ b/src/org/apollo/io/player/impl/BinaryPlayerSaver.java @@ -15,6 +15,8 @@ import org.apollo.game.model.entity.Player; import org.apollo.game.model.entity.Skill; import org.apollo.game.model.entity.SkillSet; import org.apollo.game.model.entity.attr.Attribute; +import org.apollo.game.model.entity.attr.AttributeDefinition; +import org.apollo.game.model.entity.attr.AttributeMap; import org.apollo.game.model.entity.attr.AttributeType; import org.apollo.game.model.inv.Inventory; import org.apollo.io.player.PlayerSaver; @@ -94,8 +96,15 @@ public final class BinaryPlayerSaver implements PlayerSaver { Map> attributes = player.getAttributes(); out.writeInt(attributes.size()); - for (Entry> attribute : player.getAttributes().entrySet()) { - saveAttribute(out, attribute); + + for (Entry> entry : attributes.entrySet()) { + String name = entry.getKey(); + AttributeDefinition definition = AttributeMap.getDefinition(name); + + if (definition.getPersistence() == AttributeDefinition.Persistence.SERIALIZED) { + StreamUtil.writeString(out, name); + saveAttribute(out, entry.getValue()); + } } } } @@ -107,9 +116,7 @@ public final class BinaryPlayerSaver implements PlayerSaver { * @param entry The map entry. * @throws IOException If an I/O error occurs. */ - private void saveAttribute(DataOutputStream out, Entry> entry) throws IOException { - StreamUtil.writeString(out, entry.getKey()); - Attribute attribute = entry.getValue(); + private void saveAttribute(DataOutputStream out, Attribute attribute) throws IOException { AttributeType type = attribute.getType(); out.writeByte(type.getValue());