Added display to fuel
This commit is contained in:
@@ -3,8 +3,8 @@ package com.willfp.ecoweapons.display
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.display.DisplayModule
|
||||
import com.willfp.eco.core.display.DisplayPriority
|
||||
import org.bukkit.inventory.ItemStack
|
||||
import com.willfp.ecoweapons.weapons.WeaponUtils
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
class WeaponsDisplay(plugin: EcoPlugin) : DisplayModule(plugin, DisplayPriority.LOWEST) {
|
||||
override fun display(
|
||||
@@ -12,17 +12,35 @@ class WeaponsDisplay(plugin: EcoPlugin) : DisplayModule(plugin, DisplayPriority.
|
||||
vararg args: Any
|
||||
) {
|
||||
val meta = itemStack.itemMeta ?: return
|
||||
val weapon = WeaponUtils.getWeaponFromItem(meta) ?: return
|
||||
val weaponMeta = weapon.itemStack.itemMeta ?: return
|
||||
val lore: MutableList<String> = weaponMeta.lore?.toMutableList() ?: return
|
||||
val isFuel = WeaponUtils.getFuelFromItem(meta) != null
|
||||
val weapon = (
|
||||
if (isFuel) WeaponUtils.getFuelFromItem(meta)
|
||||
else WeaponUtils.getWeaponFromItem(meta)
|
||||
) ?: return
|
||||
|
||||
if (meta.hasLore()) {
|
||||
lore.addAll(meta.lore ?: return)
|
||||
if (isFuel) {
|
||||
val fuelMeta = weapon.fuelItem.itemMeta ?: return
|
||||
val lore: MutableList<String> = fuelMeta.lore?.toMutableList() ?: return
|
||||
|
||||
if (meta.hasLore()) {
|
||||
lore.addAll(meta.lore ?: return)
|
||||
}
|
||||
|
||||
meta.lore = lore
|
||||
meta.setDisplayName(fuelMeta.displayName)
|
||||
itemStack.itemMeta = meta
|
||||
} else {
|
||||
val weaponMeta = weapon.itemStack.itemMeta ?: return
|
||||
val lore: MutableList<String> = weaponMeta.lore?.toMutableList() ?: return
|
||||
|
||||
if (meta.hasLore()) {
|
||||
lore.addAll(meta.lore ?: return)
|
||||
}
|
||||
|
||||
meta.lore = lore
|
||||
meta.setDisplayName(weaponMeta.displayName)
|
||||
meta.addItemFlags(*weaponMeta.itemFlags.toTypedArray())
|
||||
itemStack.itemMeta = meta
|
||||
}
|
||||
|
||||
meta.lore = lore
|
||||
meta.setDisplayName(weaponMeta.displayName)
|
||||
meta.addItemFlags(*weaponMeta.itemFlags.toTypedArray())
|
||||
itemStack.itemMeta = meta
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user