com.skillw.attsystem.api.compiled.CompiledData.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of AttributeSystem Show documentation
Show all versions of AttributeSystem Show documentation
Bukkit Attribute Engine Plugin.
The newest version!
package com.skillw.attsystem.api.compiled
import com.skillw.pouvoir.api.feature.condition.Condition
import com.skillw.pouvoir.api.feature.condition.ConditionData
import com.skillw.pouvoir.api.plugin.map.KeyMap
import org.bukkit.configuration.serialization.ConfigurationSerializable
import org.bukkit.entity.LivingEntity
/**
* @className CompiledData
*
* @author Glom
* @date 2023/8/2 18:51 Copyright 2023 user. All rights reserved.
*/
abstract class CompiledData : KeyMap(), Evalable, ConfigurationSerializable {
fun putAllCond(other: KeyMap) {
other.forEach { (condition, conditionData) ->
computeIfAbsent(condition) { ConditionData(condition) }.addAll(conditionData)
}
}
open fun putAll(other: CompiledData) {
putAllCond(other)
}
open fun condition(entity: LivingEntity?): Boolean {
return values.all { data ->
data.condition(entity)
}
}
override fun serialize(): MutableMap {
val total = LinkedHashMap()
values.forEach {
total.putAll(it.serialize())
}
return total
}
}