Skip to content

Commit

Permalink
feat: FireworkEffectMeta support for asColorable (#69)
Browse files Browse the repository at this point in the history
* FireworkEffectMeta

* fix: bad FireworkEffectMeta for ItemMetas#asColorable

---------

Co-authored-by: Boy <sivertpaulsen2@gmail.com>
  • Loading branch information
BimboBigBoy and Boy0000 committed May 19, 2024
1 parent 2c2117b commit a3d2961
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.mineinabyss.idofront.items

import org.bukkit.Color
import org.bukkit.FireworkEffect
import org.bukkit.inventory.meta.FireworkEffectMeta
import org.bukkit.inventory.meta.FireworkMeta
import org.bukkit.inventory.meta.ItemMeta
import org.bukkit.inventory.meta.LeatherArmorMeta
import org.bukkit.inventory.meta.MapMeta
Expand Down Expand Up @@ -40,6 +42,20 @@ fun ItemMeta.asColorable(): Colorable? {
}
}

is FireworkEffectMeta -> object : Colorable {
override var color: Color?
get() = meta.effect?.colors?.firstOrNull()
set(value) {
meta.effect = FireworkEffect.builder()
.withColor(setOf(value ?: meta.effect?.colors ?: listOf(Color.GRAY)))
.with(meta.effect?.type ?: FireworkEffect.Type.BALL)
.withFade(meta.effect?.fadeColors ?: emptyList<Color>())
.trail(meta.effect?.hasTrail() ?: false)
.flicker(meta.effect?.hasFlicker() ?: false)
.build()
}
}

else -> null
}
}
}

0 comments on commit a3d2961

Please sign in to comment.