Skip to content

Commit 75cc176

Browse files
committed
prevent duplicate friends
1 parent 7fc18b3 commit 75cc176

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/main/kotlin/com/lambda/friend/FriendManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ object FriendManager : Configurable(FriendConfig), Loadable {
4343
override val name = "friends"
4444
val friends by setting("friends", emptySet<GameProfile>(), serialize = true)
4545

46-
fun befriend(profile: GameProfile) = friends.add(profile)
46+
fun befriend(profile: GameProfile) = if (!isFriend(profile)) friends.add(profile) else false
4747
fun unfriend(profile: GameProfile): Boolean = friends.remove(profile)
4848

4949
fun gameProfile(name: String) = friends.firstOrNull { it.name == name }

0 commit comments

Comments
 (0)