The Friend System in LiquidBounce allows you to mark players as friends, preventing accidental attacks and identifying them with special markers. The FriendManager handles all friend-related operations.
object FriendManager : Config("Friends"), EventListener { val friends by list(name, TreeSet<Friend>(), valueType = ValueType.FRIEND) private val cancelAttack by boolean("CancelAttack", false)}
Friends are stored in a TreeSet which keeps them sorted alphabetically by name.
class Friend(val name: String, var alias: String?) : Comparable<Friend> { override fun equals(other: Any?): Boolean { if (this === other) return true if (javaClass != other?.javaClass) return false other as Friend return name == other.name } override fun hashCode(): Int = name.hashCode() override fun compareTo(other: Friend): Int = this.name.compareTo(other.name) fun getDefaultName(id: Int): String = "Friend $id"}
private val cancelAttack by boolean("CancelAttack", false)private val onAttack = handler<AttackEntityEvent> { if (cancelAttack && isFriend(it.entity)) { it.cancelEvent() }}
Add teammates as friends to prevent combat modules from targeting them:
// Add all team membersteamMembers.forEach { username -> FriendManager.friends.add( FriendManager.Friend(username, alias = null) )}ConfigSystem.store(FriendManager)
Safe Zones
Combine with attack prevention to create safe interactions:
Modules can check friend status to modify behavior:
// In a combat moduleval targetHandler = handler<EntityTargetEvent> { if (FriendManager.isFriend(it.entity)) { it.excludeFromTargeting() }}// In an ESP moduleval renderHandler = handler<EntityRenderEvent> { val color = if (FriendManager.isFriend(it.entity)) { Color.GREEN // Friends in green } else { Color.RED // Others in red } renderBox(it.entity, color)}