mirror of
https://github.com/Auxilor/EcoMobs.git
synced 2025-12-19 23:19:17 +00:00
Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7464133c74 | ||
|
|
1e00b28a8b | ||
|
|
b152313f87 | ||
|
|
ec6d7175b9 | ||
|
|
804a0e88b9 | ||
|
|
ff2de5aebe | ||
|
|
990ad363eb | ||
|
|
d958b94fb0 | ||
|
|
e4f2a91968 | ||
|
|
f1d50d6222 | ||
|
|
035550db06 | ||
|
|
f4bd64c192 | ||
|
|
4b8e1c0579 | ||
|
|
d8cf08eb25 | ||
|
|
a94c96e5d4 | ||
|
|
dddf2d8a20 | ||
|
|
7e67620c8c | ||
|
|
8c44303cdc | ||
|
|
97c1045243 | ||
|
|
c47019f3c5 | ||
|
|
1ffedfcb2e | ||
|
|
17705e9fdb | ||
|
|
7087feefbc |
@@ -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'
|
||||
|
||||
|
||||
@@ -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)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#
|
||||
|
||||
discover-recipes: true
|
||||
log-spawn-kill: true
|
||||
|
||||
cooldown:
|
||||
in-actionbar: true
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -14,6 +14,8 @@ softdepend:
|
||||
- Jobs
|
||||
- mcMMO
|
||||
- Vault
|
||||
- ShopGUIPlus
|
||||
- DeluxeSellwands
|
||||
|
||||
commands:
|
||||
ecobosses:
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version = 8.0.0
|
||||
version = 8.3.0
|
||||
plugin-name = EcoBosses
|
||||
Reference in New Issue
Block a user