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

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

There is a newer version: 2.4.0
Show newest version
package walkmc.interfaces

import org.bukkit.*
import org.bukkit.entity.*
import walkmc.extensions.*
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 name of this ownerable object.
 */
val Ownerable.ownerName: String
	get() = offlineOwner.name

/**
 * Returns the owner as player of this ownerable object.
 */
var Ownerable.owner: Player
	get() = ownerId.toPlayer()
	set(value) {
		ownerId = value.uuid
	}

/**
 * Returns the owner as offline player of this ownerable object.
 */
var Ownerable.offlineOwner: OfflinePlayer
	get() = ownerId.toOfflinePlayer()
	set(value) {
		ownerId = value.uuid
	}

/**
 * Returns if the specified player is owner of this ownerable object instance.
 */
fun Ownerable.isOwner(player: OfflinePlayer): Boolean = ownerId == player.uuid

/**
 * 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