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

Compare commits

...

23 Commits
8.0.0 ... 8.3.0

Author SHA1 Message Date
Auxilor
7464133c74 Updated to 8.3.0 2022-02-10 12:07:23 +00:00
Auxilor
1e00b28a8b Added BossTryDropItemEvent 2022-02-10 12:07:09 +00:00
Auxilor
b152313f87 Updated to 8.2.1 2022-02-10 11:57:40 +00:00
Auxilor
ec6d7175b9 Updated loggers 2022-02-10 11:57:32 +00:00
Auxilor
804a0e88b9 Updated libreforge 2022-02-10 10:57:25 +00:00
Auxilor
ff2de5aebe Updated to 8.1.8 2022-02-09 21:10:18 +00:00
Auxilor
990ad363eb Improved logging readability 2022-02-09 21:10:07 +00:00
Auxilor
d958b94fb0 Updated libreforge 2022-02-09 20:21:57 +00:00
Auxilor
e4f2a91968 Updated to 8.1.6 2022-02-09 13:10:57 +00:00
Auxilor
f1d50d6222 Added logging 2022-02-09 13:10:50 +00:00
Auxilor
035550db06 Added player to boss spawn event 2022-02-09 13:07:47 +00:00
Auxilor
f4bd64c192 Removed empty drops 2022-02-08 20:21:32 +00:00
Auxilor
4b8e1c0579 Updated to 8.1.5 2022-02-08 20:19:11 +00:00
Auxilor
d8cf08eb25 Fixed mob properties not being set 2022-02-08 20:19:05 +00:00
Auxilor
a94c96e5d4 Updated libreforge 2022-02-08 20:12:30 +00:00
Auxilor
dddf2d8a20 Added support for names without lookup string 2022-02-08 20:07:04 +00:00
Auxilor
7e67620c8c Updated libreforge 2022-02-08 20:03:01 +00:00
Auxilor
8c44303cdc Updated libreforge 2022-02-08 13:53:48 +00:00
Auxilor
97c1045243 Updated to 8.1.2 2022-02-08 13:53:31 +00:00
Auxilor
c47019f3c5 Updated to 8.1.1 2022-02-07 16:04:34 +00:00
Auxilor
1ffedfcb2e Fixed spawn totems 2022-02-07 16:04:25 +00:00
Auxilor
17705e9fdb Updated libreforge 2022-02-07 11:29:13 +00:00
Auxilor
7087feefbc Updated libreforge 2022-02-06 17:40:31 +00:00
14 changed files with 133 additions and 33 deletions

View File

@@ -62,7 +62,7 @@ allprojects {
dependencies {
compileOnly 'com.willfp:eco:6.24.0'
implementation 'com.willfp:libreforge:3.15.1'
implementation 'com.willfp:libreforge:3.17.0'
compileOnly 'org.jetbrains:annotations:23.0.0'

View File

@@ -12,6 +12,7 @@ import com.willfp.ecobosses.defence.MountHandler
import com.willfp.ecobosses.defence.PickupHandler
import com.willfp.ecobosses.integrations.levelledmobs.IntegrationLevelledMobs
import com.willfp.ecobosses.lifecycle.CompatibilityListeners
import com.willfp.ecobosses.lifecycle.ConsoleLoggers
import com.willfp.ecobosses.lifecycle.DeathListeners
import com.willfp.ecobosses.lifecycle.LifecycleHandlers
import com.willfp.ecobosses.spawn.AutospawnHandler
@@ -61,7 +62,8 @@ class EcoBossesPlugin : LibReforgePlugin(525, 10635, "&9") {
ImmunitiesHandler(),
CompatibilityListeners(),
SpawnTotemHandler(),
DeathListeners()
DeathListeners(),
ConsoleLoggers(this)
)
}

View File

@@ -14,20 +14,8 @@ import com.willfp.eco.core.recipe.recipes.CraftingRecipe
import com.willfp.eco.util.toComponent
import com.willfp.ecobosses.events.BossKillEvent
import com.willfp.ecobosses.lifecycle.BossLifecycle
import com.willfp.ecobosses.tick.BossBarTicker
import com.willfp.ecobosses.tick.BossTicker
import com.willfp.ecobosses.tick.DisplayNameTicker
import com.willfp.ecobosses.tick.LifespanTicker
import com.willfp.ecobosses.tick.TargetTicker
import com.willfp.ecobosses.tick.TeleportHandler
import com.willfp.ecobosses.util.BossDrop
import com.willfp.ecobosses.util.CommandReward
import com.willfp.ecobosses.util.ConfiguredSound
import com.willfp.ecobosses.util.LocalBroadcast
import com.willfp.ecobosses.util.PlayableSound
import com.willfp.ecobosses.util.SpawnTotem
import com.willfp.ecobosses.util.XpReward
import com.willfp.ecobosses.util.topDamagers
import com.willfp.ecobosses.tick.*
import com.willfp.ecobosses.util.*
import com.willfp.libreforge.Holder
import com.willfp.libreforge.conditions.Conditions
import com.willfp.libreforge.effects.Effects
@@ -38,8 +26,7 @@ import org.bukkit.Material
import org.bukkit.entity.LivingEntity
import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack
import java.util.Objects
import java.util.UUID
import java.util.*
class EcoBoss(
val config: Config,
@@ -93,8 +80,15 @@ class EcoBoss(
return@run null
}
val name = config.getFormattedStringOrNull("spawn.egg.name")
val item = ItemStackBuilder(lookup)
.addLoreLines(config.getFormattedStrings("spawn.egg.lore"))
.apply {
if (name != null) {
setDisplayName(name)
}
}
.build().apply { bossEgg = this@EcoBoss }
val key = plugin.namespacedKeyFactory.create("${this.id}_spawn_egg")
@@ -135,9 +129,9 @@ class EcoBoss(
}
SpawnTotem(
Material.getMaterial(config.getString("spawn.totem.top")) ?: return@run null,
Material.getMaterial(config.getString("spawn.totem.middle")) ?: return@run null,
Material.getMaterial(config.getString("spawn.totem.bottom")) ?: return@run null
Material.getMaterial(config.getString("spawn.totem.top").uppercase()) ?: return@run null,
Material.getMaterial(config.getString("spawn.totem.middle").uppercase()) ?: return@run null,
Material.getMaterial(config.getString("spawn.totem.bottom").uppercase()) ?: return@run null
)
}
@@ -248,6 +242,7 @@ class EcoBoss(
config.getDouble("chance"),
config.getStrings("items")
.map { Items.lookup(it) }
.filter { it !is EmptyTestableItem }
.map { it.item }
)
)
@@ -286,6 +281,10 @@ class EcoBoss(
fun spawn(location: Location): LivingEcoBoss {
val mob = mob.spawn(location) as LivingEntity
mob.isPersistent = true
mob.isCustomNameVisible = true
mob.removeWhenFarAway = false
val boss = LivingEcoBoss(
plugin,
mob.uniqueId,
@@ -331,7 +330,7 @@ class EcoBoss(
val player = event.killer
for (drop in drops) {
drop.drop(location, player)
drop.drop(this, location, player)
}
xp.modify(event.event)

View File

@@ -110,7 +110,8 @@ class CommandSpawn(plugin: EcoBossesPlugin) : Subcommand(
val event = BossSpawnEvent(
boss,
location,
BossSpawnEvent.SpawnReason.COMMAND
BossSpawnEvent.SpawnReason.COMMAND,
null
)
Bukkit.getPluginManager().callEvent(event)

View File

@@ -2,6 +2,7 @@ package com.willfp.ecobosses.events
import com.willfp.ecobosses.bosses.EcoBoss
import org.bukkit.Location
import org.bukkit.entity.Player
import org.bukkit.event.Cancellable
import org.bukkit.event.Event
import org.bukkit.event.HandlerList
@@ -9,7 +10,8 @@ import org.bukkit.event.HandlerList
class BossSpawnEvent(
val boss: EcoBoss,
val location: Location,
val reason: SpawnReason
val reason: SpawnReason,
val spawner: Player?
) : Event(), Cancellable {
private var isCancelled: Boolean = false

View File

@@ -0,0 +1,30 @@
package com.willfp.ecobosses.events
import com.willfp.ecobosses.bosses.EcoBoss
import com.willfp.ecobosses.bosses.LivingEcoBoss
import org.bukkit.Location
import org.bukkit.entity.Player
import org.bukkit.event.Event
import org.bukkit.event.HandlerList
import org.bukkit.inventory.ItemStack
class BossTryDropItemEvent(
val boss: EcoBoss,
val location: Location,
var items: MutableCollection<ItemStack>,
var chance: Double,
val player: Player?
): Event() {
override fun getHandlers(): HandlerList {
return HANDLERS
}
companion object {
private val HANDLERS = HandlerList()
@JvmStatic
fun getHandlerList(): HandlerList {
return HANDLERS
}
}
}

View File

@@ -0,0 +1,56 @@
package com.willfp.ecobosses.lifecycle
import com.willfp.ecobosses.events.BossDespawnEvent
import com.willfp.ecobosses.events.BossKillEvent
import com.willfp.ecobosses.events.BossSpawnEvent
import com.willfp.libreforge.LibReforgePlugin
import org.bukkit.event.EventHandler
import org.bukkit.event.EventPriority
import org.bukkit.event.Listener
class ConsoleLoggers(
private val plugin: LibReforgePlugin
) : Listener {
@EventHandler(
ignoreCancelled = true,
priority = EventPriority.MONITOR
)
fun handle(event: BossSpawnEvent) {
if (!plugin.configYml.getBool("log-spawn-kill")) {
return
}
val location = "${event.location.world?.name}: ${event.location.x}, ${event.location.y}, ${event.location.z}"
plugin.logger.info("&a${event.boss.id}&r was spawned by &a${event.spawner?.name}&r at &a$location")
}
@EventHandler(
ignoreCancelled = true,
priority = EventPriority.MONITOR
)
fun handle(event: BossKillEvent) {
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}"
plugin.logger.info("&a${event.boss.boss.id}&r was killed by &a${event.killer?.name}&r at &a$location")
}
@EventHandler(
ignoreCancelled = true,
priority = EventPriority.MONITOR
)
fun handle(event: BossDespawnEvent) {
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}"
plugin.logger.info("&a${event.boss.boss.id}&r despawned at &a$location")
}
}

View File

@@ -33,7 +33,7 @@ class SpawnEggHandler : Listener {
return
}
val spawnEvent = BossSpawnEvent(boss, location, BossSpawnEvent.SpawnReason.EGG)
val spawnEvent = BossSpawnEvent(boss, location, BossSpawnEvent.SpawnReason.EGG, player)
Bukkit.getPluginManager().callEvent(spawnEvent)

View File

@@ -55,7 +55,7 @@ class SpawnTotemHandler : Listener {
return
}
val spawnEvent = BossSpawnEvent(boss, event.block.location, BossSpawnEvent.SpawnReason.TOTEM)
val spawnEvent = BossSpawnEvent(boss, event.block.location, BossSpawnEvent.SpawnReason.TOTEM, player)
if (!spawnEvent.isCancelled) {
block1.type = Material.AIR

View File

@@ -2,6 +2,8 @@ package com.willfp.ecobosses.util
import com.willfp.eco.core.drops.DropQueue
import com.willfp.eco.util.NumberUtils
import com.willfp.ecobosses.bosses.EcoBoss
import com.willfp.ecobosses.events.BossTryDropItemEvent
import org.bukkit.Bukkit
import org.bukkit.Location
import org.bukkit.entity.Player
@@ -12,15 +14,19 @@ data class BossDrop(
val chance: Double,
val drops: Collection<ItemStack>
) {
fun drop(location: Location, player: Player?) {
if (NumberUtils.randFloat(0.0, 100.0) < chance) {
fun drop(boss: EcoBoss, location: Location, player: Player?) {
val event = BossTryDropItemEvent(boss, location, drops.toMutableList(), chance, player)
Bukkit.getPluginManager().callEvent(event)
if (NumberUtils.randFloat(0.0, 100.0) < event.chance) {
if (player != null) {
DropQueue(player)
.setLocation(location)
.addItems(drops)
.setLocation(event.location)
.addItems(event.items)
.push()
} else {
for (drop in drops) {
for (drop in event.items) {
location.world?.dropItemNaturally(location, drop)
}
}

View File

@@ -4,6 +4,7 @@
#
discover-recipes: true
log-spawn-kill: true
cooldown:
in-actionbar: true

View File

@@ -106,7 +106,8 @@ bosses:
notInWorlds: [ ] # If spawn totems should be disallowed in certain worlds, specify them here
egg:
enabled: true # If the boss should have a spawn egg
item: evoker_spawn_egg unbreaking:1 hide_enchants name:"&8Steel Golem&f Spawn Egg"
item: evoker_spawn_egg unbreaking:1 hide_enchants
name: "&8Steel Golem&f Spawn Egg"
lore:
- ""
- "&8&oPlace on the ground to"

View File

@@ -14,6 +14,8 @@ softdepend:
- Jobs
- mcMMO
- Vault
- ShopGUIPlus
- DeluxeSellwands
commands:
ecobosses:

View File

@@ -1,2 +1,2 @@
version = 8.0.0
version = 8.3.0
plugin-name = EcoBosses