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

walkmc.block.OwnerableBlock.kt Maven / Gradle / Ivy

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
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy