All Downloads are FREE. Search and download functionalities are using the official Maven repository.

walkmc.interfaces.Friendship.kt Maven / Gradle / Ivy

package walkmc.interfaces

import org.bukkit.entity.*
import walkmc.extensions.*
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.uuid)
}

/**
 * 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.uuid 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.uuid)

/**
 * 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.uuid)




© 2015 - 2025 Weber Informatics LLC | Privacy Policy