Save modification counter.
[Sone.git] / src / main / java / net / pterodactylus / sone / core / Core.java
index 6cd6135..16d4a2c 100644 (file)
@@ -599,6 +599,7 @@ public class Core implements IdentityListener {
                        /* save Sone into configuration. */
                        String sonePrefix = "Sone/" + sone.getId();
                        configuration.getLongValue(sonePrefix + "/Time").setValue(sone.getTime());
+                       configuration.getLongValue(sonePrefix + "/ModificationCounter").setValue(sone.getModificationCounter());
 
                        /* save profile. */
                        Profile profile = sone.getProfile();
@@ -644,6 +645,14 @@ public class Core implements IdentityListener {
                        }
                        configuration.getStringValue(sonePrefix + "/Likes/Reply/" + replyLikeCounter + "/ID").setValue(null);
 
+                       /* save friends. */
+                       int friendCounter = 0;
+                       for (Sone friend : sone.getFriends()) {
+                               configuration.getStringValue(sonePrefix + "/Friends/" + friendCounter + "/ID").setValue(friend.getId());
+                               configuration.getBooleanValue(sonePrefix + "/Friends/" + friendCounter++ + "/Local").setValue(friend.getInsertUri() != null);
+                       }
+                       configuration.getStringValue(sonePrefix + "/Friends/" + friendCounter + "/ID").setValue(null);
+
                        logger.log(Level.INFO, "Sone %s saved.", sone);
                } catch (ConfigurationException ce1) {
                        logger.log(Level.WARNING, "Could not save Sone: " + sone, ce1);