Skip to content

Commit 5674bb3

Browse files
committed
Fix: Friends not saving
1 parent 5290e4c commit 5674bb3

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,18 @@ package com.lambda.friend
33
import com.lambda.config.Configurable
44
import com.lambda.config.configurations.FriendConfig
55
import com.lambda.core.Loadable
6-
import com.lambda.event.events.TickEvent
7-
import com.lambda.event.listener.SafeListener.Companion.listener
8-
import com.lambda.util.world.EntityUtils.getEntities
96
import com.mojang.authlib.GameProfile
10-
import net.minecraft.entity.player.PlayerEntity
117
import net.minecraft.server.network.ServerPlayerEntity
12-
import net.minecraft.world.event.listener.EntityGameEventHandler
13-
import java.util.Arrays
148
import java.util.UUID
159

1610
object FriendManager : Configurable(FriendConfig), Loadable {
1711
override val name = "FriendManager"
1812

19-
private val friends by setting("friends", arrayListOf<GameProfile>())
13+
private var friends by setting("friends", listOf<GameProfile>())
2014

21-
fun add(vararg profile: GameProfile) =
22-
friends.addAll(profile)
15+
fun add(profile: GameProfile) = friends.add(profile)
2316

24-
fun remove(vararg profile: GameProfile) =
25-
friends.removeAll(profile.toSet())
17+
fun remove(profile: GameProfile) = friends.remove(profile)
2618

2719
fun get(name: String) = friends.firstOrNull { it.name == name }
2820
fun get(uuid: UUID) = friends.firstOrNull { it.id == uuid }
@@ -36,6 +28,9 @@ object FriendManager : Configurable(FriendConfig), Loadable {
3628
val ServerPlayerEntity.isFriend: Boolean
3729
get() = contains(gameProfile)
3830

31+
fun ServerPlayerEntity.befriend() = add(gameProfile)
32+
fun ServerPlayerEntity.unfriend() = remove(gameProfile)
33+
3934
override fun load(): String {
4035
if (friends.isEmpty()) return "No friends loaded, damn bro you don't have to be antisocial online too,"
4136
val word = if (friends.size == 1) "friend" else "friends"

0 commit comments

Comments
 (0)