X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FSone.java;h=dbe1b359938ab9a84612d76a80ce4381ed0f5b61;hb=f637fce46e6468595c70daee9a02f36bb37c57e3;hp=27c78527e8a7ee021f1e68c3fb3e86256ce626cf;hpb=dcf921e95da3881c75f57323733273c96027822e;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/data/Sone.java b/src/main/java/net/pterodactylus/sone/data/Sone.java index 27c7852..dbe1b35 100644 --- a/src/main/java/net/pterodactylus/sone/data/Sone.java +++ b/src/main/java/net/pterodactylus/sone/data/Sone.java @@ -217,14 +217,14 @@ public class Sone { } /** - * Adds a post with the given text to this Sone. + * Adds the given post to this Sone. The post will not be added if its + * {@link Post#getSone() Sone} is not this Sone. * - * @param text - * The text to post + * @param post + * The post to add */ - public synchronized void addPost(String text) { - Post post = new Post(this, System.currentTimeMillis(), text); - if (posts.add(post)) { + public synchronized void addPost(Post post) { + if (post.getSone().equals(this) && posts.add(post)) { modificationCounter++; } } @@ -236,7 +236,7 @@ public class Sone { * The post to remove */ public synchronized void removePost(Post post) { - if (posts.remove(post)) { + if (post.getSone().equals(this) && posts.remove(post)) { modificationCounter++; } }