Skip to content

Commit

Permalink
自然生成的实体基础属性
Browse files Browse the repository at this point in the history
  • Loading branch information
Glomzzz committed Dec 12, 2023
1 parent 5598d33 commit 31cdad2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@ package com.skillw.attsystem.internal.feature.realizer.attribute

import com.skillw.attsystem.AttributeSystem
import com.skillw.attsystem.api.AttrAPI.read
import com.skillw.attsystem.api.AttrAPI.update
import com.skillw.attsystem.api.compiled.CompiledAttrDataCompound
import com.skillw.attsystem.api.compiled.sub.ComplexCompiledData
import com.skillw.pouvoir.api.feature.realizer.BaseRealizer
import com.skillw.pouvoir.api.feature.realizer.BaseRealizerManager
import com.skillw.pouvoir.api.feature.realizer.component.Awakeable
import com.skillw.pouvoir.api.plugin.annotation.AutoRegister
import com.skillw.pouvoir.util.isAlive
import org.bukkit.entity.LivingEntity
import org.bukkit.event.entity.EntitySpawnEvent
import taboolib.common.platform.event.SubscribeEvent
import taboolib.common.util.asList
import taboolib.common.util.unsafeLazy
import taboolib.common5.cbool
import taboolib.module.configuration.util.asMap

/**
* @className BaseAttributePlayerRealizer
*
* Ó¦¸Ã½Ð×ö basic attributeµÄ¡£¡£
* Ӧ�ý��� basic attribute�ġ���
*
* @author Glom
* @date 2023/1/6 7:05 Copyright 2022 user. All rights reserved.
Expand All @@ -35,6 +41,8 @@ object BaseAttributeEntityRealizer : BaseRealizer("base-attribute-entity"), Awak
get() = config["attributes"]
val conditions
get() = config["conditions"]
val onSpawn
get() = config["on-spawn"]?.cbool ?: true

private const val KEY = "BASIC-ATTRIBUTE"

Expand Down Expand Up @@ -67,5 +75,13 @@ object BaseAttributeEntityRealizer : BaseRealizer("base-attribute-entity"), Awak
return this
}

@SubscribeEvent
fun entity(event: EntitySpawnEvent) {
if(!onSpawn) return
val entity = event.entity
if(entity.isAlive())
(entity as LivingEntity).update()
}


}
2 changes: 2 additions & 0 deletions src/main/resources/options.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ base-attribute-player:
- "攻击距离: 2.7"
- "暴击伤害: 150(%)"
base-attribute-entity:
#当实体生成的时候,是否自动添加这些属性
on-spawn: true
# strings / nbt
type: strings
attributes:
Expand Down

0 comments on commit 31cdad2

Please sign in to comment.