Skip to content

Commit

Permalink
fix: only handle books if it is being signed
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Jun 24, 2024
1 parent 86f6f1e commit 336daa3
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package com.mineinabyss.chatty.listeners
import com.mineinabyss.chatty.chatty
import com.mineinabyss.chatty.components.ChannelData
import com.mineinabyss.chatty.components.HideJoinLeave
import com.mineinabyss.chatty.helpers.*
import com.mineinabyss.chatty.helpers.buildTagResolver
import com.mineinabyss.chatty.helpers.parseTags
import com.mineinabyss.chatty.helpers.refreshSkinInCaches
import com.mineinabyss.chatty.helpers.translatePlaceholders
import com.mineinabyss.geary.papermc.tracking.entities.toGeary
import com.mineinabyss.geary.serialization.getOrSetPersisting
import com.mineinabyss.idofront.items.editItemMeta
import com.mineinabyss.idofront.textcomponents.miniMsg
import com.mineinabyss.idofront.textcomponents.serialize
import net.kyori.adventure.text.Component
import org.bukkit.entity.Player
import org.bukkit.event.EventHandler
import org.bukkit.event.EventPriority
Expand Down Expand Up @@ -47,9 +48,9 @@ class PlayerListener : Listener {
quitMessage(translatePlaceholders(player, chatty.messages.joinLeave.leaveMessage).miniMsg(player.buildTagResolver(true)))
}

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
fun PlayerEditBookEvent.onBookSign() {
newBookMeta = newBookMeta.apply {
if (isSigning) newBookMeta = newBookMeta.apply {
if (hasAuthor())
author(author().parseTags(player))
if (hasTitle())
Expand All @@ -68,7 +69,6 @@ class PlayerListener : Listener {

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
fun PrepareAnvilEvent.onAnvilRename() {
if (result?.itemMeta?.hasDisplayName() != true) return
result = result?.editItemMeta {
if (!hasDisplayName()) return@editItemMeta
displayName(displayName()?.parseTags(viewers.firstOrNull() as? Player))
Expand Down

0 comments on commit 336daa3

Please sign in to comment.