mirror of
https://github.com/Auxilor/EcoMobs.git
synced 2025-12-19 23:19:17 +00:00
Compare commits
134 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec9d4c0dd6 | ||
|
|
b3a0c1fa67 | ||
|
|
88294a17cd | ||
|
|
1ac6a350ec | ||
|
|
a9333cb8b5 | ||
|
|
23085e74e2 | ||
|
|
80f02a07a4 | ||
|
|
a63625593d | ||
|
|
1dfd7bac1f | ||
|
|
34b983b185 | ||
|
|
33b2fd9e13 | ||
|
|
85cfb542dc | ||
|
|
197f9e91aa | ||
|
|
9d4a91805a | ||
|
|
87b91c46d1 | ||
|
|
4a7e6e9ff1 | ||
|
|
b59e54be01 | ||
|
|
d26f0294cc | ||
|
|
150433d46b | ||
|
|
7de4d75c93 | ||
|
|
9790459a26 | ||
|
|
666a80b401 | ||
|
|
59810059aa | ||
|
|
7b604c7812 | ||
|
|
81eab18e42 | ||
|
|
fa54c7022b | ||
|
|
26f976a7ca | ||
|
|
4fa070dabe | ||
|
|
f73327b204 | ||
|
|
d9b702f2f1 | ||
|
|
7692e84a60 | ||
|
|
ffd6037e73 | ||
|
|
7c959d7221 | ||
|
|
91ad33334d | ||
|
|
c1b8ed5b48 | ||
|
|
2f3c5f60a4 | ||
|
|
f3387668e6 | ||
|
|
b62e79d904 | ||
|
|
d7afeecc27 | ||
|
|
72e61940c5 | ||
|
|
245445473b | ||
|
|
46772ac97a | ||
|
|
29a1e541a2 | ||
|
|
89a6bc97b7 | ||
|
|
c59707e6ac | ||
|
|
99bc2a04ab | ||
|
|
b4e90d9bda | ||
|
|
72c3722429 | ||
|
|
c14b2f0a80 | ||
|
|
0b6c7152e8 | ||
|
|
6e551eeaeb | ||
|
|
d5610ae804 | ||
|
|
79c8ed4992 | ||
|
|
947a0f3c6d | ||
|
|
ce8b0af155 | ||
|
|
a41e5b702d | ||
|
|
f04bf3aeea | ||
|
|
08941461c9 | ||
|
|
743dbac656 | ||
|
|
2e8d1ea4cc | ||
|
|
d31a98fd99 | ||
|
|
f7244a7d7f | ||
|
|
268ed76951 | ||
|
|
d0ccb78c17 | ||
|
|
34de040849 | ||
|
|
6b01f8e64a | ||
|
|
2a4d5a8fd2 | ||
|
|
f9d7315fd3 | ||
|
|
497f42ccc6 | ||
|
|
d149eb7907 | ||
|
|
47277d0dd8 | ||
|
|
f307f13d1e | ||
|
|
ac3370c0be | ||
|
|
4f616ac8c8 | ||
|
|
24256e9789 | ||
|
|
bbf20e77d0 | ||
|
|
8a506c015b | ||
|
|
744883630d | ||
|
|
8519f4fc23 | ||
|
|
d1cb11ef79 | ||
|
|
edcc185b58 | ||
|
|
ab6d297222 | ||
|
|
9626588c66 | ||
|
|
c4eda19d78 | ||
|
|
691326577a | ||
|
|
e2086387e7 | ||
|
|
13a72f849d | ||
|
|
6346975e77 | ||
|
|
0d846d9dff | ||
|
|
31610383c4 | ||
|
|
d7c16ad3cc | ||
|
|
afe9095276 | ||
|
|
31a782581f | ||
|
|
8aad221450 | ||
|
|
b0bff24263 | ||
|
|
04b00fa01b | ||
|
|
276ba4616a | ||
|
|
d8e5fb9cd0 | ||
|
|
9f05a6504a | ||
|
|
322a6bb41b | ||
|
|
4dbc8afdf4 | ||
|
|
7ffa6ff4f4 | ||
|
|
3769684bb0 | ||
|
|
7bb931e027 | ||
|
|
879d6dd72d | ||
|
|
0a4aff45ad | ||
|
|
5929da1f48 | ||
|
|
6db5de581b | ||
|
|
9ce1bb7ddf | ||
|
|
351d34de9f | ||
|
|
4d2b726aa0 | ||
|
|
ff20b70784 | ||
|
|
f31cd20200 | ||
|
|
0ad2d3cfc7 | ||
|
|
ccc7c5797a | ||
|
|
a218fa96c0 | ||
|
|
13c0a4d83a | ||
|
|
62e7177b1b | ||
|
|
752b30b4a2 | ||
|
|
be4d6156e3 | ||
|
|
fed6dcafd7 | ||
|
|
36f944c58c | ||
|
|
1bc35656fe | ||
|
|
1216e83a39 | ||
|
|
4723c7982c | ||
|
|
8ba3c7834c | ||
|
|
76530a1617 | ||
|
|
bf41554846 | ||
|
|
a741c78b6b | ||
|
|
0f8dce74da | ||
|
|
0d31556b84 | ||
|
|
f8544c284e | ||
|
|
512a477fc6 | ||
|
|
8a1b473837 |
@@ -1,6 +1,6 @@
|
||||
<h1 align="center">
|
||||
<br>
|
||||
<img src="https://i.imgur.com/A2qieC3.png" alt="EcoBosses logo" width="256">
|
||||
<img src="https://i.imgur.com/3n3ssb4.png" alt="EcoBosses logo" width="256">
|
||||
<br>
|
||||
</h1>
|
||||
|
||||
|
||||
22
build.gradle
22
build.gradle
@@ -4,7 +4,7 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0"
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,15 +58,17 @@ allprojects {
|
||||
|
||||
shadowJar {
|
||||
relocate('com.willfp.libreforge', 'com.willfp.ecobosses.libreforge')
|
||||
relocate('org.joml', 'com.willfp.ecobosses.libreforge.joml')
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly 'com.willfp:eco:6.24.0'
|
||||
implementation 'com.willfp:libreforge:3.17.0'
|
||||
compileOnly 'com.willfp:eco:6.35.1'
|
||||
implementation 'com.willfp:libreforge:3.77.0'
|
||||
implementation 'org.joml:joml:1.10.4'
|
||||
|
||||
compileOnly 'org.jetbrains:annotations:23.0.0'
|
||||
|
||||
compileOnly 'org.jetbrains.kotlin:kotlin-stdlib:1.6.0'
|
||||
compileOnly 'org.jetbrains.kotlin:kotlin-stdlib:1.7.10'
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
@@ -119,3 +121,15 @@ compileJava.options.encoding = 'UTF-8'
|
||||
|
||||
build.dependsOn shadowJar
|
||||
build.dependsOn publishToMavenLocal
|
||||
|
||||
task buyThePlugins {
|
||||
dependsOn subprojects.build
|
||||
|
||||
doLast {
|
||||
println 'If you like the plugin, please consider buying it on Spigot or Polymart!'
|
||||
println 'Spigot: https://www.spigotmc.org/resources/authors/auxilor.507394/'
|
||||
println 'Polymart: https://polymart.org/user/auxilor.1107/'
|
||||
println 'Buying gives you access to support and the plugin auto-updater, and it allows me to keep developing plugins.'
|
||||
}
|
||||
}
|
||||
build.finalizedBy buyThePlugins
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.willfp.ecobosses
|
||||
|
||||
import com.willfp.eco.core.command.impl.PluginCommand
|
||||
import com.willfp.eco.core.display.DisplayModule
|
||||
import com.willfp.eco.core.integrations.IntegrationLoader
|
||||
import com.willfp.ecobosses.bosses.Bosses
|
||||
import com.willfp.ecobosses.bosses.EggDisplay
|
||||
import com.willfp.ecobosses.bosses.bossHolders
|
||||
import com.willfp.ecobosses.commands.CommandEcobosses
|
||||
import com.willfp.ecobosses.config.EcoBossesYml
|
||||
@@ -23,7 +25,7 @@ import com.willfp.ecobosses.util.TopDamagerListener
|
||||
import com.willfp.libreforge.LibReforgePlugin
|
||||
import org.bukkit.event.Listener
|
||||
|
||||
class EcoBossesPlugin : LibReforgePlugin(525, 10635, "&9") {
|
||||
class EcoBossesPlugin : LibReforgePlugin() {
|
||||
val ecoBossesYml: EcoBossesYml
|
||||
|
||||
init {
|
||||
@@ -44,6 +46,10 @@ class EcoBossesPlugin : LibReforgePlugin(525, 10635, "&9") {
|
||||
Bosses.getAllAlive().forEach { it.remove() }
|
||||
}
|
||||
|
||||
override fun createDisplayModule(): DisplayModule {
|
||||
return EggDisplay(this)
|
||||
}
|
||||
|
||||
override fun loadPluginCommands(): List<PluginCommand> {
|
||||
return listOf(
|
||||
CommandEcobosses(this)
|
||||
@@ -74,7 +80,7 @@ class EcoBossesPlugin : LibReforgePlugin(525, 10635, "&9") {
|
||||
}
|
||||
|
||||
override fun getMinimumEcoVersion(): String {
|
||||
return "6.24.0"
|
||||
return "6.35.1"
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.willfp.ecobosses.bosses
|
||||
|
||||
import com.willfp.eco.core.fast.fast
|
||||
import com.willfp.ecobosses.EcoBossesPlugin
|
||||
import com.willfp.libreforge.Holder
|
||||
import org.bukkit.entity.Player
|
||||
@@ -13,7 +14,7 @@ val Player.bossHolders: Iterable<Holder>
|
||||
|
||||
for (boss in Bosses.values()) {
|
||||
for (livingBoss in boss.getAllAlive()) {
|
||||
val entity = livingBoss.entity ?: continue
|
||||
val entity = livingBoss.entity
|
||||
|
||||
if (entity.world != this.world) {
|
||||
continue
|
||||
@@ -42,8 +43,7 @@ var ItemStack.bossEgg: EcoBoss?
|
||||
this.itemMeta = meta
|
||||
}
|
||||
get() {
|
||||
val meta = this.itemMeta ?: return null
|
||||
val pdc = meta.persistentDataContainer
|
||||
val pdc = this.fast().persistentDataContainer
|
||||
val id = pdc.get(spawnEggKey, PersistentDataType.STRING) ?: return null
|
||||
return Bosses.getByID(id)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
)
|
||||
@@ -5,12 +5,14 @@ import com.willfp.eco.core.config.interfaces.Config
|
||||
import com.willfp.eco.core.entities.CustomEntity
|
||||
import com.willfp.eco.core.entities.Entities
|
||||
import com.willfp.eco.core.entities.TestableEntity
|
||||
import com.willfp.eco.core.entities.ai.*
|
||||
import com.willfp.eco.core.items.CustomItem
|
||||
import com.willfp.eco.core.items.Items
|
||||
import com.willfp.eco.core.items.builder.ItemStackBuilder
|
||||
import com.willfp.eco.core.recipe.Recipes
|
||||
import com.willfp.eco.core.recipe.parts.EmptyTestableItem
|
||||
import com.willfp.eco.core.recipe.recipes.CraftingRecipe
|
||||
import com.willfp.eco.util.NamespacedKeyUtils
|
||||
import com.willfp.eco.util.toComponent
|
||||
import com.willfp.ecobosses.events.BossKillEvent
|
||||
import com.willfp.ecobosses.lifecycle.BossLifecycle
|
||||
@@ -24,15 +26,17 @@ import org.bukkit.Bukkit
|
||||
import org.bukkit.Location
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.entity.LivingEntity
|
||||
import org.bukkit.entity.Mob
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.inventory.ItemStack
|
||||
import org.bukkit.persistence.PersistentDataType
|
||||
import java.util.*
|
||||
|
||||
class EcoBoss(
|
||||
val config: Config,
|
||||
private val plugin: EcoPlugin
|
||||
) : Holder {
|
||||
val id: String = config.getString("id")
|
||||
override val id: String = config.getString("id")
|
||||
|
||||
val displayName: String = config.getString("displayName")
|
||||
|
||||
@@ -157,6 +161,22 @@ class EcoBoss(
|
||||
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(it.getSubsection("args")) ?: return@mapNotNull null
|
||||
ConfiguredGoal(it.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(it.getSubsection("args")) ?: return@mapNotNull null
|
||||
ConfiguredGoal(it.getInt("priority"), goal)
|
||||
}
|
||||
|
||||
val spawnConditions = config.getSubsections("spawn.conditions").mapNotNull {
|
||||
Conditions.compile(it, "$id Spawn Conditions")
|
||||
}
|
||||
@@ -189,6 +209,16 @@ class EcoBoss(
|
||||
map
|
||||
}
|
||||
|
||||
private val commands: Map<BossLifecycle, LocalCommands> = run {
|
||||
val map = mutableMapOf<BossLifecycle, LocalCommands>()
|
||||
|
||||
for (value in BossLifecycle.values()) {
|
||||
map[value] = LocalCommands(config.getStrings("commands.${value.name.lowercase()}"))
|
||||
}
|
||||
|
||||
map
|
||||
}
|
||||
|
||||
private val commandRewards: Map<Int, Iterable<CommandReward>> = run {
|
||||
val map = mutableMapOf<Int, Iterable<CommandReward>>()
|
||||
|
||||
@@ -280,14 +310,29 @@ class EcoBoss(
|
||||
}
|
||||
|
||||
fun spawn(location: Location): LivingEcoBoss {
|
||||
val mob = mob.spawn(location) as LivingEntity
|
||||
val mob = mob.spawn(location) as Mob
|
||||
mob.isPersistent = true
|
||||
mob.isCustomNameVisible = true
|
||||
mob.removeWhenFarAway = false
|
||||
mob.persistentDataContainer.set(
|
||||
plugin.namespacedKeyFactory.create("boss"),
|
||||
PersistentDataType.STRING,
|
||||
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(
|
||||
plugin,
|
||||
mob.uniqueId,
|
||||
mob,
|
||||
this,
|
||||
createTickers()
|
||||
)
|
||||
@@ -300,7 +345,8 @@ class EcoBoss(
|
||||
LifespanTicker(),
|
||||
DisplayNameTicker(),
|
||||
TargetTicker(),
|
||||
TeleportHandler()
|
||||
TeleportHandler(),
|
||||
ChunkTicker()
|
||||
)
|
||||
|
||||
if (isBossBarEnabled) {
|
||||
@@ -322,10 +368,11 @@ class EcoBoss(
|
||||
fun handleLifecycle(lifecycle: BossLifecycle, location: Location, entity: LivingEntity?) {
|
||||
sounds[lifecycle]?.play(location)
|
||||
messages[lifecycle]?.forEach { it.broadcast(location, entity?.topDamagers ?: emptyList()) }
|
||||
commands[lifecycle]?.dispatch(location, entity?.topDamagers ?: emptyList())
|
||||
}
|
||||
|
||||
fun processRewards(event: BossKillEvent) {
|
||||
val entity = event.boss.entity ?: return
|
||||
val entity = event.boss.entity
|
||||
val location = entity.location
|
||||
val player = event.killer
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.willfp.ecobosses.bosses
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.display.Display
|
||||
import com.willfp.eco.core.display.DisplayModule
|
||||
import com.willfp.eco.core.display.DisplayPriority
|
||||
import com.willfp.eco.core.fast.fast
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
class EggDisplay(
|
||||
plugin: EcoPlugin
|
||||
) : DisplayModule(
|
||||
plugin,
|
||||
DisplayPriority.LOW
|
||||
) {
|
||||
override fun display(itemStack: ItemStack, player: Player?, vararg args: Any) {
|
||||
if (player == null) {
|
||||
return
|
||||
}
|
||||
|
||||
val fis = itemStack.fast()
|
||||
|
||||
val lore = fis.lore.toMutableList()
|
||||
|
||||
val egg = itemStack.bossEgg ?: return
|
||||
|
||||
val lines = egg.spawnConditions
|
||||
.filterNot { it.isMet(player) }
|
||||
.mapNotNull { it.notMetLines?.map { line -> Display.PREFIX + line } }
|
||||
.flatten()
|
||||
|
||||
|
||||
if (lines.isNotEmpty()) {
|
||||
lore.add(Display.PREFIX)
|
||||
lore.addAll(lines)
|
||||
}
|
||||
|
||||
fis.lore = lore
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,12 @@ package com.willfp.ecobosses.bosses
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.ecobosses.tick.BossTicker
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.Chunk
|
||||
import org.bukkit.entity.Mob
|
||||
import java.util.UUID
|
||||
|
||||
class LivingEcoBoss(
|
||||
plugin: EcoPlugin,
|
||||
private val uuid: UUID,
|
||||
private val mob: Mob,
|
||||
val boss: EcoBoss,
|
||||
private val tickers: Set<BossTicker>
|
||||
) {
|
||||
@@ -18,15 +17,20 @@ class LivingEcoBoss(
|
||||
}
|
||||
}.apply { runTaskTimer(1, 1) }
|
||||
|
||||
val entity: Mob?
|
||||
get() = Bukkit.getEntity(uuid) as? Mob
|
||||
val entity: Mob
|
||||
get() = mob
|
||||
|
||||
val chunk: Chunk
|
||||
get() = entity.location.chunk
|
||||
|
||||
val forceLoadedChunks = mutableListOf<Chunk>()
|
||||
|
||||
val deathTime = System.currentTimeMillis() + (boss.lifespan * 1000)
|
||||
|
||||
private var currentTick = 1 // Start at 1 as 0 is divisible by everything
|
||||
|
||||
private fun tick(): Boolean {
|
||||
if (entity == null || entity?.isDead == true) {
|
||||
if (entity.isDead) {
|
||||
remove()
|
||||
return true
|
||||
}
|
||||
@@ -40,13 +44,15 @@ class LivingEcoBoss(
|
||||
|
||||
fun remove() {
|
||||
ticker.cancel()
|
||||
entity?.remove()
|
||||
entity.remove()
|
||||
tickers.forEach { it.onDeath(this, currentTick) }
|
||||
forceLoadedChunks.forEach { it.isForceLoaded = false }
|
||||
forceLoadedChunks.clear()
|
||||
|
||||
boss.markDead(uuid)
|
||||
boss.markDead(mob.uniqueId)
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "LivingEcoBoss{boss=${boss}, uuid=${uuid}}"
|
||||
return "LivingEcoBoss{boss=${boss}, uuid=${mob.uniqueId}}"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.willfp.ecobosses.bosses
|
||||
import com.google.common.collect.BiMap
|
||||
import com.google.common.collect.HashBiMap
|
||||
import com.google.common.collect.ImmutableList
|
||||
import org.bukkit.GameMode
|
||||
import org.bukkit.entity.Entity
|
||||
import org.bukkit.entity.LivingEntity
|
||||
import org.bukkit.entity.Player
|
||||
@@ -16,14 +17,16 @@ class TargetMode(
|
||||
}
|
||||
|
||||
fun getTarget(boss: LivingEcoBoss): LivingEntity? {
|
||||
val entity = boss.entity ?: return null
|
||||
val entity = boss.entity
|
||||
|
||||
return function(
|
||||
entity.getNearbyEntities(
|
||||
boss.boss.targetRange,
|
||||
boss.boss.targetRange,
|
||||
boss.boss.targetRange
|
||||
).filterIsInstance<Player>(),
|
||||
).filterIsInstance<Player>()
|
||||
.filter { listOf(GameMode.SURVIVAL, GameMode.ADVENTURE).contains(it.gameMode) }
|
||||
.ifEmpty { return null },
|
||||
entity
|
||||
)
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ class BossSpawnEvent(
|
||||
TOTEM,
|
||||
EGG,
|
||||
COMMAND,
|
||||
AUTOSPAWN,
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
|
||||
@@ -34,8 +34,8 @@ class ConsoleLoggers(
|
||||
return
|
||||
}
|
||||
|
||||
val loc = event.boss.entity?.location
|
||||
val location = "${loc?.world?.name}: ${loc?.x}, ${loc?.y}, ${loc?.z}"
|
||||
val loc = event.boss.entity.location
|
||||
val location = "${loc.world?.name}: ${loc.x}, ${loc.y}, ${loc.z}"
|
||||
|
||||
plugin.logger.info("&a${event.boss.boss.id}&r was killed by &a${event.killer?.name}&r at &a$location")
|
||||
}
|
||||
@@ -48,8 +48,8 @@ class ConsoleLoggers(
|
||||
if (!plugin.configYml.getBool("log-spawn-kill")) {
|
||||
return
|
||||
}
|
||||
val loc = event.boss.entity?.location
|
||||
val location = "${loc?.world?.name}: ${loc?.x}, ${loc?.y}, ${loc?.z}"
|
||||
val loc = event.boss.entity.location
|
||||
val location = "${loc.world?.name}: ${loc.x}, ${loc.y}, ${loc.z}"
|
||||
|
||||
plugin.logger.info("&a${event.boss.boss.id}&r despawned at &a$location")
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.willfp.ecobosses.lifecycle
|
||||
|
||||
import com.willfp.eco.core.events.EntityDeathByEntityEvent
|
||||
import com.willfp.eco.util.tryAsPlayer
|
||||
import com.willfp.ecobosses.bosses.Bosses
|
||||
import com.willfp.ecobosses.events.BossKillEvent
|
||||
import com.willfp.libreforge.tryAsPlayer
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.Listener
|
||||
|
||||
@@ -28,7 +28,7 @@ class LifecycleHandlers : Listener {
|
||||
priority = EventPriority.MONITOR
|
||||
)
|
||||
fun handle(event: BossKillEvent) {
|
||||
val entity = event.boss.entity ?: return
|
||||
val entity = event.boss.entity
|
||||
|
||||
event.boss.boss.handleLifecycle(BossLifecycle.KILL, entity.location, entity)
|
||||
}
|
||||
@@ -38,7 +38,7 @@ class LifecycleHandlers : Listener {
|
||||
priority = EventPriority.MONITOR
|
||||
)
|
||||
fun handle(event: BossDespawnEvent) {
|
||||
val entity = event.boss.entity ?: return
|
||||
val entity = event.boss.entity
|
||||
|
||||
event.boss.boss.handleLifecycle(BossLifecycle.DESPAWN, entity.location, entity)
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.willfp.ecobosses.spawn
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.ecobosses.bosses.Bosses
|
||||
import com.willfp.ecobosses.events.BossSpawnEvent
|
||||
import org.bukkit.Bukkit
|
||||
|
||||
object AutospawnHandler {
|
||||
private var tick = 1
|
||||
@@ -20,12 +22,20 @@ object AutospawnHandler {
|
||||
val location = boss.autoSpawnLocations.randomOrNull() ?: continue
|
||||
val world = location.world ?: continue
|
||||
|
||||
if (plugin.configYml.getBool("autospawn.one-boss-per-world")) {
|
||||
if (Bosses.getAllAlive().mapNotNull { it.entity }.any { it.world == world }) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
val spawnEvent = BossSpawnEvent(boss, location, BossSpawnEvent.SpawnReason.AUTOSPAWN, null)
|
||||
|
||||
Bukkit.getPluginManager().callEvent(spawnEvent)
|
||||
|
||||
if (!spawnEvent.isCancelled) {
|
||||
boss.spawn(location)
|
||||
}
|
||||
}
|
||||
|
||||
tick++
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.willfp.eco.util.containsIgnoreCase
|
||||
import com.willfp.ecobosses.bosses.Bosses
|
||||
import com.willfp.ecobosses.events.BossSpawnEvent
|
||||
import com.willfp.ecobosses.util.SpawnTotem
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.block.Block
|
||||
import org.bukkit.event.EventHandler
|
||||
@@ -16,36 +17,36 @@ class SpawnTotemHandler : Listener {
|
||||
)
|
||||
fun handle(event: BlockPlaceEvent) {
|
||||
for (i in 0..2) {
|
||||
lateinit var block1: Block
|
||||
lateinit var block2: Block
|
||||
lateinit var block3: Block
|
||||
lateinit var top: Block
|
||||
lateinit var middle: Block
|
||||
lateinit var bottom: Block
|
||||
|
||||
// I know this code sucks ass, but I can't be arsed to write it nicely
|
||||
when (i) {
|
||||
0 -> {
|
||||
block3 = event.block
|
||||
block2 = event.block.getRelative(0, -1, 0)
|
||||
block1 = event.block.getRelative(0, -2, 0)
|
||||
top = event.block
|
||||
middle = event.block.getRelative(0, -1, 0)
|
||||
bottom = event.block.getRelative(0, -2, 0)
|
||||
}
|
||||
1 -> {
|
||||
block1 = event.block
|
||||
block2 = event.block.getRelative(0, 1, 0)
|
||||
block3 = event.block.getRelative(0, 2, 0)
|
||||
top = event.block.getRelative(0, 2, 0)
|
||||
middle = event.block.getRelative(0, 1, 0)
|
||||
bottom = event.block
|
||||
}
|
||||
2 -> {
|
||||
block2 = event.block
|
||||
block1 = event.block.getRelative(0, -1, 0)
|
||||
block3 = event.block.getRelative(0, 1, 0)
|
||||
top = event.block.getRelative(0, 1, 0)
|
||||
middle = event.block
|
||||
bottom = event.block.getRelative(0, -1, 0)
|
||||
}
|
||||
}
|
||||
|
||||
val placedTotem = SpawnTotem(block1.type, block2.type, block3.type)
|
||||
val placedTotem = SpawnTotem(top.type, middle.type, bottom.type)
|
||||
for (boss in Bosses.values()) {
|
||||
if (boss.totem == null || boss.disabledTotemWorlds.containsIgnoreCase(event.block.world.name)) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (boss.totem != placedTotem) {
|
||||
if (!boss.totem.matches(placedTotem)) {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -57,10 +58,12 @@ class SpawnTotemHandler : Listener {
|
||||
|
||||
val spawnEvent = BossSpawnEvent(boss, event.block.location, BossSpawnEvent.SpawnReason.TOTEM, player)
|
||||
|
||||
Bukkit.getPluginManager().callEvent(spawnEvent)
|
||||
|
||||
if (!spawnEvent.isCancelled) {
|
||||
block1.type = Material.AIR
|
||||
block2.type = Material.AIR
|
||||
block3.type = Material.AIR
|
||||
top.type = Material.AIR
|
||||
middle.type = Material.AIR
|
||||
bottom.type = Material.AIR
|
||||
|
||||
boss.spawn(event.block.location.add(0.0, 1.5, 0.0))
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ class BossBarTicker(
|
||||
private val bar: BossBar
|
||||
) : BossTicker {
|
||||
override fun tick(boss: LivingEcoBoss, tick: Int) {
|
||||
val entity = boss.entity ?: return
|
||||
val entity = boss.entity
|
||||
|
||||
bar.name(entity.customName!!.toComponent())
|
||||
bar.progress((entity.health / entity.getAttribute(Attribute.GENERIC_MAX_HEALTH)!!.value).toFloat())
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.willfp.ecobosses.tick
|
||||
|
||||
import com.willfp.ecobosses.bosses.LivingEcoBoss
|
||||
|
||||
class ChunkTicker : BossTicker {
|
||||
override fun tick(boss: LivingEcoBoss, tick: Int) {
|
||||
val currentChunk = boss.chunk
|
||||
|
||||
if (tick % 10 != 0) {
|
||||
return
|
||||
}
|
||||
|
||||
if (currentChunk.isLoaded && currentChunk.isForceLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
currentChunk.load()
|
||||
currentChunk.isForceLoaded = true
|
||||
boss.forceLoadedChunks.add(currentChunk)
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import kotlin.math.ceil
|
||||
|
||||
class DisplayNameTicker : BossTicker {
|
||||
override fun tick(boss: LivingEcoBoss, tick: Int) {
|
||||
val entity = boss.entity ?: return
|
||||
val entity = boss.entity
|
||||
|
||||
val timeLeft = ceil(
|
||||
(boss.deathTime - System.currentTimeMillis()) / 1000.0
|
||||
|
||||
@@ -16,7 +16,7 @@ class LifespanTicker : BossTicker {
|
||||
boss.remove()
|
||||
boss.boss.handleLifecycle(
|
||||
BossLifecycle.DESPAWN,
|
||||
boss.entity?.location ?: return,
|
||||
boss.entity.location,
|
||||
boss.entity
|
||||
)
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.willfp.ecobosses.bosses.LivingEcoBoss
|
||||
|
||||
class TargetTicker : BossTicker {
|
||||
override fun tick(boss: LivingEcoBoss, tick: Int) {
|
||||
val entity = boss.entity ?: return
|
||||
val entity = boss.entity
|
||||
|
||||
if (tick % 10 != 0) {
|
||||
return
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.bukkit.block.BlockFace
|
||||
|
||||
class TeleportHandler : BossTicker {
|
||||
override fun tick(boss: LivingEcoBoss, tick: Int) {
|
||||
val entity = boss.entity ?: return
|
||||
val entity = boss.entity
|
||||
if (!boss.boss.canTeleport) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.willfp.ecobosses.util
|
||||
|
||||
import com.willfp.eco.util.tryAsPlayer
|
||||
import com.willfp.ecobosses.EcoBossesPlugin
|
||||
import com.willfp.libreforge.tryAsPlayer
|
||||
import org.bukkit.entity.LivingEntity
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.EventPriority
|
||||
import org.bukkit.event.Listener
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent
|
||||
import java.util.UUID
|
||||
import java.util.*
|
||||
|
||||
data class Damager(
|
||||
val uuid: UUID,
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.willfp.ecobosses.util
|
||||
|
||||
import com.willfp.eco.core.config.interfaces.Config
|
||||
import com.willfp.eco.util.NumberUtils
|
||||
import com.willfp.eco.util.savedDisplayName
|
||||
import com.willfp.ecobosses.EcoBossesPlugin
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.Location
|
||||
|
||||
data class LocalCommands(
|
||||
val commands: Iterable<String>,
|
||||
) {
|
||||
fun dispatch(location: Location, topDamagers: List<Damager>) {
|
||||
val toDispatch = commands.toMutableList()
|
||||
toDispatch.replaceAll {
|
||||
var command = it
|
||||
|
||||
for (i in 1..20) {
|
||||
val damager = topDamagers.getOrNull(i - 1)
|
||||
val damage = if (damager?.damage != null) NumberUtils.format(damager.damage) else
|
||||
EcoBossesPlugin.instance.langYml.getFormattedString("na")
|
||||
val player = if (damager?.uuid != null) Bukkit.getOfflinePlayer(damager.uuid).savedDisplayName else
|
||||
EcoBossesPlugin.instance.langYml.getFormattedString("na")
|
||||
|
||||
command = command.replace("%damage_${i}%", damage)
|
||||
.replace("%damage_${i}_player%", player)
|
||||
}
|
||||
|
||||
command.replace("%x%", location.blockX.toString())
|
||||
.replace("%y%", location.blockY.toString())
|
||||
.replace("%z%", location.blockZ.toString())
|
||||
}
|
||||
|
||||
for (s in toDispatch) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), s);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,4 +6,10 @@ data class SpawnTotem(
|
||||
val top: Material,
|
||||
val middle: Material,
|
||||
val bottom: Material
|
||||
)
|
||||
) {
|
||||
fun matches(totem: SpawnTotem): Boolean {
|
||||
return this.top == totem.top
|
||||
&& this.middle == totem.middle
|
||||
&& this.bottom == totem.bottom
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
discover-recipes: true
|
||||
log-spawn-kill: true
|
||||
|
||||
autospawn:
|
||||
one-boss-per-world: true # If only one boss can auto-spawn per world at once.
|
||||
|
||||
cooldown:
|
||||
in-actionbar: true
|
||||
sound:
|
||||
@@ -33,3 +36,14 @@ point-names: # If you have point names that look ugly (eg g_souls) then you can
|
||||
use-faster-move-trigger: true # Disable if you want move trigger to detect sub-1-block movements
|
||||
raytrace-distance: 80 # The distance that alt_click should check for a location
|
||||
block-item-drop-place-check: true # If the block_item_drop trigger should only fire on naturally placed blocks (prevents dupes)
|
||||
|
||||
potions:
|
||||
icon:
|
||||
permanent: true
|
||||
triggered: true
|
||||
ambient:
|
||||
permanent: false
|
||||
triggered: true
|
||||
particles:
|
||||
permanent: false
|
||||
triggered: true
|
||||
3
eco-core/core-plugin/src/main/resources/eco.yml
Normal file
3
eco-core/core-plugin/src/main/resources/eco.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
resource-id: 525
|
||||
bstats-id: 10635
|
||||
color: "&9"
|
||||
@@ -26,6 +26,10 @@ bosses:
|
||||
# Supported placeholders: %health%, %time% (formats as minutes:seconds, eg 1:56)
|
||||
displayName: "&8Steel Golem &7| &c%health%♥ &7| &e%time%"
|
||||
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
|
||||
- id: run_chain
|
||||
args:
|
||||
@@ -123,6 +127,13 @@ bosses:
|
||||
- iron_block
|
||||
- netherite_block
|
||||
- iron_block
|
||||
commands:
|
||||
# For each category, you can add as many commands as you want, which will be executed by
|
||||
# console. Supported placeholders are the same as for messages (see below)
|
||||
spawn: [ ]
|
||||
kill: [ ]
|
||||
despawn: [ ]
|
||||
injure: [ ]
|
||||
messages:
|
||||
# For each category, you can add as many messages as you want, each with their own radius.
|
||||
# Radius is the distance from the boss where the player will be sent the message
|
||||
|
||||
@@ -18,5 +18,6 @@ messages:
|
||||
on-cooldown: "&cThis effect is on cooldown! &fTime left: &a%seconds% seconds"
|
||||
cannot-afford: "&cYou can't afford to do this! &fCost: &a$$%cost%"
|
||||
cannot-afford-type: "&cYou can't afford to do this! &fCost: &a%cost% %type%"
|
||||
cannot-transmit: "&cYou can't transmit here!"
|
||||
|
||||
na: "N/A"
|
||||
@@ -1,7 +1,7 @@
|
||||
name: EcoBosses
|
||||
version: ${projectVersion}
|
||||
main: com.willfp.ecobosses.EcoBossesPlugin
|
||||
api-version: 1.16
|
||||
api-version: 1.17
|
||||
authors: [Auxilor]
|
||||
website: willfp.com
|
||||
load: STARTUP
|
||||
@@ -9,13 +9,17 @@ depend:
|
||||
- eco
|
||||
softdepend:
|
||||
- LevelledMobs
|
||||
- EcoSkills
|
||||
- AureliumSkills
|
||||
- Jobs
|
||||
- mcMMO
|
||||
- Vault
|
||||
- ShopGUIPlus
|
||||
- DeluxeSellwands
|
||||
- TMMobcoins
|
||||
- EcoEnchants
|
||||
- Talismans
|
||||
- EcoArmor
|
||||
- EcoItems
|
||||
- EcoSkills
|
||||
- Boosters
|
||||
|
||||
commands:
|
||||
ecobosses:
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
version = 8.3.0
|
||||
#libreforge-updater
|
||||
#Sun Jul 24 22:49:25 BST 2022
|
||||
version=8.62.0
|
||||
plugin-name=EcoBosses
|
||||
Reference in New Issue
Block a user