
net.chestmc.common.interfaces.Friendship.kt Maven / Gradle / Ivy
package net.chestmc.common.interfaces
import net.chestmc.common.extensions.id
import org.bukkit.entity.Player
import java.util.*
/**
* A friendship interface, representing a object that can have any friends.
*/
interface Friendship {
/**
* The friends of this friendship.
*/
var friends: MutableSet
/**
* Verifies if the player id is accessible in any part. By default
* this just verifies if the player is friends of this friendship object.
* If you also implements the [Ownerable] interface, you must override this function.
*/
fun isAccessible(id: UUID): Boolean = id in friends
}
/**
* Verifies if the player is accessible in any part.
*/
fun Friendship.isAccessible(player: Player): Boolean = isAccessible(player.id)
/**
* Returns if this id of player is friend of this friendship object.
*/
fun Friendship.isFriend(id: UUID): Boolean = id in friends
/**
* Returns if this player is friend of this friendship object.
*/
fun Friendship.isFriend(player: Player): Boolean = player.id in friends
/**
* Adds a new specified friend in this friendship object.
*/
fun Friendship.addFriend(id: UUID) = friends.add(id)
/**
* Adds a new specified friend in this friendship object.
*/
fun Friendship.addFriend(player: Player) = friends.add(player.id)
/**
* Removes a specified friend in this friendship object.
*/
fun Friendship.removeFriend(id: UUID) = friends.remove(id)
/**
* Removes a specified friend in this friendship object.
*/
fun Friendship.removeFriend(player: Player) = friends.remove(player.id)
© 2015 - 2025 Weber Informatics LLC | Privacy Policy