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

tech.carcadex.kotlinbukkitkit.extensions.ExBlock.kt Maven / Gradle / Ivy

The newest version!
/*
ORIGINAL PACKAGE: package br.com.devsrsouza.kotlinbukkitapi.extensions
ORIGINAL REPOSITORY: https://github.com/DevSrSouza/KotlinBukkitAPI
AUTHOR: https://github.com/DevSrSouza

Thanks DevSrSouza for KotlinBukkitAPI
 */

package tech.carcadex.kotlinbukkitkit.extensions

import org.bukkit.Material
import org.bukkit.block.Block
import org.bukkit.entity.Player
import org.bukkit.material.MaterialData

public infix fun Block.eqType(block: Block): Boolean = type == block.type && data == block.data
public infix fun Block.eqType(data: MaterialData): Boolean = type == data.itemType && this.data == data.data
public infix fun Block.eqType(material: Material): Boolean = type == material

public fun Block.sendBlockChange(
    materialData: MaterialData,
    players: List,
): Unit = sendBlockChange(materialData.itemType, materialData.data, players)

public fun Block.sendBlockChange(
    material: Material,
    data: Byte = 0,
    players: List,
) {
    players.filter { it.world.name == world.name }.forEach {
        it.sendBlockChange(location, material, data)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy