From 735ed009a8b5ff96cae5dc8b01e24cd679638875 Mon Sep 17 00:00:00 2001 From: Will FP Date: Sat, 6 Jan 2024 11:52:32 +0000 Subject: [PATCH] Added EntityProvidedHolder --- .../kotlin/com/willfp/libreforge/Holder.kt | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/core/src/main/kotlin/com/willfp/libreforge/Holder.kt b/core/src/main/kotlin/com/willfp/libreforge/Holder.kt index e3e6d0ff..1c15074b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/Holder.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/Holder.kt @@ -4,6 +4,8 @@ import com.willfp.eco.util.NamespacedKeyUtils import com.willfp.libreforge.conditions.ConditionList import com.willfp.libreforge.effects.EffectList import org.bukkit.NamespacedKey +import org.bukkit.entity.Entity +import org.bukkit.entity.LivingEntity import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack import java.util.Objects @@ -186,6 +188,27 @@ open class ItemProvidedHolder( } } +/** + * A provided holder for an entity. + */ +open class EntityProvidedHolder( + override val holder: Holder, + override val provider: Entity +) : ProvidedHolder { + override fun hashCode(): Int { + return Objects.hash(holder, provider) + } + + override fun equals(other: Any?): Boolean { + if (other !is EntityProvidedHolder) { + return false + } + + return other.holder == this.holder + && other.provider == this.provider + } +} + // The current template ID, incremented every time a holder is created from a template. private val currentTemplateID = AtomicInteger(0)