
net.chestmc.common.interfaces.Ownerable.kt Maven / Gradle / Ivy
package net.chestmc.common.interfaces
import net.chestmc.common.extensions.id
import net.chestmc.common.extensions.toPlayer
import org.bukkit.entity.Player
import java.util.*
/**
* A ownerable interface, representing a object that can have a owner.
*/
interface Ownerable {
/**
* The owner identifier of this ownerable object.
*/
var ownerId: UUID
}
/**
* Returns the owner as player of this ownerable object.
*/
inline var Ownerable.owner: Player
get() = ownerId.toPlayer()
set(value) {
ownerId = value.id
}
/**
* Returns the owner name of this ownerable object.
*/
inline val Ownerable.ownerName: String
get() = owner.name
/**
* Returns if the specified player is owner of this ownerable object instance.
*/
fun Ownerable.isOwner(player: Player): Boolean = ownerId == player.id
/**
* Returns if the specified UUID is owner of this ownerable object instance.
*/
fun Ownerable.isOwner(id: UUID): Boolean = ownerId == id
© 2015 - 2025 Weber Informatics LLC | Privacy Policy