Skip to content

Commit

Permalink
Merge pull request #10 from Glomzzz/main
Browse files Browse the repository at this point in the history
feat: VanillaAttributeUpdateEvent
  • Loading branch information
Glomzzz authored Jun 13, 2024
2 parents 77eae41 + 550f1c6 commit 10254ab
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.skillw.attsystem.api.event

import com.skillw.pouvoir.util.attribute.BukkitAttribute
import org.bukkit.entity.Entity
import taboolib.platform.type.BukkitProxyEvent

/**
* 原版属性更新后
*
* @property entity 实体
* @property attr 属性
* @property value 属性值
*/
class VanillaAttributeUpdateEvent (
val entity: Entity,
val attr: BukkitAttribute,
val value: Double,
) : BukkitProxyEvent() {
override val allowCancelled = false

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.skillw.attsystem.internal.feature.realizer.vanilla

import com.skillw.attsystem.api.event.VanillaAttributeUpdateEvent
import com.skillw.attsystem.internal.manager.ASConfig
import com.skillw.pouvoir.util.attribute.BukkitAttribute
import com.skillw.pouvoir.util.attribute.clear
Expand Down Expand Up @@ -45,6 +46,7 @@ internal object MaxHealthTaskBuilder : VanillaAttTaskBuilder("max-health", Bukki
if (!isEnableVanilla()) clear()
else removeModifier(modifier)
addModifier(modifier)
VanillaAttributeUpdateEvent(entity, BukkitAttribute.MAX_HEALTH, if(isEnableVanilla()) value + 20 else value).call()
}
}
} else {
Expand All @@ -57,6 +59,7 @@ internal object MaxHealthTaskBuilder : VanillaAttTaskBuilder("max-health", Bukki
getAttribute(BukkitAttribute.MAX_HEALTH)?.apply {
clear()
}
VanillaAttributeUpdateEvent(entity, BukkitAttribute.MAX_HEALTH, value).call()
maxHealth = value
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.skillw.attsystem.internal.feature.realizer.vanilla

import com.skillw.attsystem.AttributeSystem
import com.skillw.attsystem.AttributeSystem.realizerManager
import com.skillw.attsystem.api.event.VanillaAttributeUpdateEvent
import com.skillw.pouvoir.api.feature.realizer.BaseRealizer
import com.skillw.pouvoir.api.feature.realizer.BaseRealizerManager
import com.skillw.pouvoir.api.feature.realizer.component.*
Expand Down Expand Up @@ -55,6 +56,7 @@ internal open class VanillaAttTaskBuilder(key: String, val attribute: BukkitAttr
if (!isEnableVanilla()) clear()
else removeModifier(modifier)
addModifier(modifier)
VanillaAttributeUpdateEvent(entity,this@VanillaAttTaskBuilder.attribute, if(isEnableVanilla()) value + 20 else value).call()
}
}
}
Expand Down

0 comments on commit 10254ab

Please sign in to comment.