9
0
mirror of https://github.com/Auxilor/EcoMobs.git synced 2025-12-20 07:29:21 +00:00

Boss eggs now display not met lore

This commit is contained in:
Auxilor
2022-05-18 17:21:35 +01:00
parent f7244a7d7f
commit d31a98fd99
3 changed files with 45 additions and 2 deletions

View File

@@ -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
@@ -44,6 +46,10 @@ class EcoBossesPlugin : LibReforgePlugin() {
Bosses.getAllAlive().forEach { it.remove() }
}
override fun createDisplayModule(): DisplayModule {
return EggDisplay(this)
}
override fun loadPluginCommands(): List<PluginCommand> {
return listOf(
CommandEcobosses(this)

View File

@@ -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
@@ -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)
}

View File

@@ -0,0 +1,37 @@
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.getNotMetLines(player).map { Display.PREFIX + it }
if (lines.isNotEmpty()) {
lore.add(Display.PREFIX)
lore.addAll(lines)
}
fis.lore = lore
}
}