9
0
mirror of https://github.com/Auxilor/EcoMobs.git synced 2025-12-19 23:19:17 +00:00

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	build.gradle
#	gradle.properties
This commit is contained in:
Auxilor
2022-03-28 19:05:11 +01:00
5 changed files with 49 additions and 4 deletions

View File

@@ -61,8 +61,8 @@ allprojects {
} }
dependencies { dependencies {
compileOnly 'com.willfp:eco:6.24.0' compileOnly 'com.willfp:eco:6.29.0'
implementation 'com.willfp:libreforge:3.26.1' implementation 'com.willfp:libreforge:3.28.0'
compileOnly 'org.jetbrains:annotations:23.0.0' compileOnly 'org.jetbrains:annotations:23.0.0'

View File

@@ -0,0 +1,8 @@
package com.willfp.ecobosses.bosses
import com.willfp.eco.core.entities.ai.Goal
data class ConfiguredGoal<T : Goal<*>>(
val priority: Int,
val goal: T
)

View File

@@ -5,12 +5,18 @@ import com.willfp.eco.core.config.interfaces.Config
import com.willfp.eco.core.entities.CustomEntity import com.willfp.eco.core.entities.CustomEntity
import com.willfp.eco.core.entities.Entities import com.willfp.eco.core.entities.Entities
import com.willfp.eco.core.entities.TestableEntity import com.willfp.eco.core.entities.TestableEntity
import com.willfp.eco.core.entities.ai.EntityController
import com.willfp.eco.core.entities.ai.EntityGoal
import com.willfp.eco.core.entities.ai.EntityGoals
import com.willfp.eco.core.entities.ai.TargetGoal
import com.willfp.eco.core.entities.ai.TargetGoals
import com.willfp.eco.core.items.CustomItem import com.willfp.eco.core.items.CustomItem
import com.willfp.eco.core.items.Items import com.willfp.eco.core.items.Items
import com.willfp.eco.core.items.builder.ItemStackBuilder import com.willfp.eco.core.items.builder.ItemStackBuilder
import com.willfp.eco.core.recipe.Recipes import com.willfp.eco.core.recipe.Recipes
import com.willfp.eco.core.recipe.parts.EmptyTestableItem import com.willfp.eco.core.recipe.parts.EmptyTestableItem
import com.willfp.eco.core.recipe.recipes.CraftingRecipe import com.willfp.eco.core.recipe.recipes.CraftingRecipe
import com.willfp.eco.util.NamespacedKeyUtils
import com.willfp.eco.util.toComponent import com.willfp.eco.util.toComponent
import com.willfp.ecobosses.events.BossKillEvent import com.willfp.ecobosses.events.BossKillEvent
import com.willfp.ecobosses.lifecycle.BossLifecycle import com.willfp.ecobosses.lifecycle.BossLifecycle
@@ -37,6 +43,7 @@ import org.bukkit.Bukkit
import org.bukkit.Location import org.bukkit.Location
import org.bukkit.Material import org.bukkit.Material
import org.bukkit.entity.LivingEntity import org.bukkit.entity.LivingEntity
import org.bukkit.entity.Mob
import org.bukkit.entity.Player import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack import org.bukkit.inventory.ItemStack
import org.bukkit.persistence.PersistentDataType import org.bukkit.persistence.PersistentDataType
@@ -172,6 +179,22 @@ class EcoBoss(
locations locations
} }
val hasCustomAI = config.getBool("customai.enabled")
val targetGoals = config.getSubsections("customai.target-goals").mapNotNull {
val key = NamespacedKeyUtils.fromStringOrNull(it.getString("key")) ?: return@mapNotNull null
val deserializer = TargetGoals.getByKey(key) ?: return@mapNotNull null
val goal = deserializer.deserialize(config.getSubsection("args")) ?: return@mapNotNull null
ConfiguredGoal(config.getInt("priority"), goal)
}
val entityGoals = config.getSubsections("customai.ai-goals").mapNotNull {
val key = NamespacedKeyUtils.fromStringOrNull(it.getString("key")) ?: return@mapNotNull null
val deserializer = EntityGoals.getByKey(key) ?: return@mapNotNull null
val goal = deserializer.deserialize(config.getSubsection("args")) ?: return@mapNotNull null
ConfiguredGoal(config.getInt("priority"), goal)
}
val spawnConditions = config.getSubsections("spawn.conditions").mapNotNull { val spawnConditions = config.getSubsections("spawn.conditions").mapNotNull {
Conditions.compile(it, "$id Spawn Conditions") Conditions.compile(it, "$id Spawn Conditions")
} }
@@ -305,7 +328,7 @@ class EcoBoss(
} }
fun spawn(location: Location): LivingEcoBoss { fun spawn(location: Location): LivingEcoBoss {
val mob = mob.spawn(location) as LivingEntity val mob = mob.spawn(location) as Mob
mob.isPersistent = true mob.isPersistent = true
mob.isCustomNameVisible = true mob.isCustomNameVisible = true
mob.removeWhenFarAway = false mob.removeWhenFarAway = false
@@ -315,6 +338,16 @@ class EcoBoss(
this.id this.id
) )
if (hasCustomAI) {
val controller = EntityController.getFor(mob)
.clearAllGoals()
@Suppress("UNCHECKED_CAST") // What could go wrong?
targetGoals.forEach { controller.addTargetGoal(it.priority, it.goal as TargetGoal<in Mob>) }
@Suppress("UNCHECKED_CAST")
entityGoals.forEach { controller.addEntityGoal(it.priority, it.goal as EntityGoal<in Mob>) }
}
val boss = LivingEcoBoss( val boss = LivingEcoBoss(
plugin, plugin,
mob.uniqueId, mob.uniqueId,

View File

@@ -26,6 +26,10 @@ bosses:
# Supported placeholders: %health%, %time% (formats as minutes:seconds, eg 1:56) # Supported placeholders: %health%, %time% (formats as minutes:seconds, eg 1:56)
displayName: "&8Steel Golem &7| &c%health%♥ &7| &e%time%" displayName: "&8Steel Golem &7| &c%health%♥ &7| &e%time%"
influence: 40 # The distance at which effects will be applied to players influence: 40 # The distance at which effects will be applied to players
customai: # Custom mob AI using the entity goal system.
enabled: false # If custom AI should be enabled, this will override the vanilla mob behaviour.
target-goals: [ ] # How the boss decides who to attack, if the target mode isn't being used.
ai-goals: [ ] # How the boss should behave.
effects: # Effects are done from the player's perspective: to treat the player as the victim, use the self_as_victim option in args effects: # Effects are done from the player's perspective: to treat the player as the victim, use the self_as_victim option in args
- id: run_chain - id: run_chain
args: args:

View File

@@ -1,2 +1,2 @@
version = 8.12.1 version = 8.15.0
plugin-name = EcoBosses plugin-name = EcoBosses