Skip to content

Commit

Permalink
fix: unrenamed inputitem in anvil outputting blank renamed resultitem
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Jan 3, 2024
1 parent 2bf78b0 commit c5650bd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/src/main/kotlin/com/mineinabyss/emojy/EmojyListener.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.mineinabyss.idofront.textcomponents.miniMsg
import com.mineinabyss.idofront.textcomponents.serialize
import io.papermc.paper.event.player.AsyncChatDecorateEvent
import io.papermc.paper.event.player.AsyncChatEvent
import net.kyori.adventure.text.Component
import org.bukkit.Bukkit
import org.bukkit.entity.Player
import org.bukkit.event.EventHandler
Expand All @@ -33,8 +34,9 @@ class EmojyListener : Listener {

@EventHandler
fun PrepareAnvilEvent.onAnvil() {
if (result?.itemMeta?.hasDisplayName() != true) return
val inventory = inventory as? AnvilInventory ?: return
val displayName = (inventory.renameText?.miniMsg() ?: inventory.firstItem?.itemMeta?.displayName())?.transform(inventory.viewers.firstOrNull() as? Player, false)
val displayName = ((inventory.renameText?.miniMsg() ?: inventory.firstItem?.itemMeta?.displayName())?.transform(inventory.viewers.firstOrNull() as? Player, false))
result = result?.editItemMeta {
displayName(displayName)
}
Expand Down

0 comments on commit c5650bd

Please sign in to comment.