walkmc.block.OwnerableBlock.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of resources-addon Show documentation
Show all versions of resources-addon Show documentation
A resources API/Addon with compatibility with others plugins
The newest version!
package walkmc.block
import org.bukkit.*
import walkmc.interfaces.*
import walkmc.serializer.tag.impl.*
import java.util.*
/**
* A implementation of [IBlock] that can have a owner.
*/
open class OwnerableBlock : AbstractBlock, Ownerable {
override lateinit var ownerId: UUID
val hasOwner get() = this::ownerId.isInitialized
constructor()
constructor(player: OfflinePlayer) : this(player.uniqueId)
constructor(owner: UUID) {
ownerId = owner
}
override fun load(tag: CompoundTag) {
if ("Owner" in tag)
ownerId = tag.getUuid("Owner")
}
override fun save(tag: CompoundTag) {
if (hasOwner)
tag["Owner"] = ownerId
}
}