Overview
TheFriendManager (features/misc/FriendManager.kt:32) maintains a list of friends and automatically handles friend-related events throughout the client.
Configuration
CancelAttack Option
Prevents attacking friends when enabled:AttackEntityEvent is cancelled if the target is a friend (FriendManager.kt:46-50).
Managing Friends
Friend Data Structure
Each friend consists of:- name: Player’s Minecraft username (unique identifier)
- alias: Custom display name (optional)
TreeSet for automatic sorting and duplicate prevention (FriendManager.kt:34).
Using the Friend Command
The.friend command provides full friend management:
Checking Friend Status
The manager provides utility methods to check if a player is a friend:Player before checking the name (FriendManager.kt:78).
Event Integration
TagEntityEvent
Automatically tags friend entities for visual identification:AttackEntityEvent
Prevents attacking friends whenCancelAttack is enabled:
Storage and Persistence
Friends are stored in the config system withValueType.FRIEND:
- Loaded on client startup
- Saved when modified
- Sorted alphabetically by username
Use Cases
Combat Protection
EnableCancelAttack to prevent your combat modules from targeting friends during PvP scenarios.
Visual Identification
ESP and nametag modules can use the friend status to:- Display friends in different colors
- Show friend indicators
- Hide or prioritize friend information
Team Gameplay
Mark teammates as friends to:- Avoid friendly fire in team modes
- Coordinate with the same players across servers
- Maintain persistent friend relationships
Command Examples
Interactive friend list display (CommandFriend.kt:84-127):- Username (clickable to copy)
- Alias in parentheses
- Red [X] button to remove (click to suggest remove command)
Implementation Notes
TheFriend class implements Comparable<Friend> for automatic sorting (FriendManager.kt:71) and overrides equals() and hashCode() to compare by name only (FriendManager.kt:58-69).
Default aliases use the format “Friend ” when no custom alias is set (FriendManager.kt:73).