Skip to content

Commit

Permalink
refactor: remove skin component logics
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Jul 5, 2024
1 parent ba8d58e commit b7371f4
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ object ChattyPermissions {
Permission("chatty.tags.hover") to StandardTags.hoverEvent(),
Permission("chatty.tags.reset") to StandardTags.reset(),
Permission("chatty.tags.shift") to ChattyTags.SHIFT_RESOLVER,
Permission("chatty.tags.head") to ChattyTags.HEAD_RESOLVER,
Permission("chatty.tags.skin") to ChattyTags.SKIN_RESOLVER,
)
const val HELD_ITEM_RESOLVER = "chatty.tags.held_item"
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.mineinabyss.chatty.components.ChannelData
import com.mineinabyss.chatty.components.HideJoinLeave
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
Expand Down Expand Up @@ -43,9 +42,6 @@ class PlayerListener : Listener {
fun PlayerQuitEvent.onDisconnect() {
if (chatty.config.leave.enabled && !player.toGeary().has<HideJoinLeave>())
quitMessage(translatePlaceholders(player, chatty.messages.joinLeave.leaveMessage).miniMsg(player.buildTagResolver(true)))

// Remove player incase they switch skins
player.refreshSkinInCaches()
}

@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import com.mineinabyss.chatty.components.ChannelData
import com.mineinabyss.chatty.components.SpyOnChannels
import com.mineinabyss.chatty.components.chattyNickname
import com.mineinabyss.chatty.helpers.channelNames
import com.mineinabyss.chatty.helpers.translateFullPlayerSkinComponent
import com.mineinabyss.chatty.helpers.translatePlayerHeadComponent
import com.mineinabyss.geary.papermc.tracking.entities.toGeary
import com.mineinabyss.geary.papermc.tracking.entities.toGearyOrNull
import com.mineinabyss.idofront.font.Space
Expand Down Expand Up @@ -47,8 +45,6 @@ fun chattyPlaceholders(player: Player?, string: String? = null): Map<String, Str
"player_ping_toggle" to (channelData?.disablePingSound?.not() ?: "false").toString(),

"nickname" to (player?.chattyNickname ?: player?.displayName()?.serialize() ?: player?.name.toString()),
"player_head" to player?.translatePlayerHeadComponent()?.serialize().toString(),
"player_full_skin" to player?.translateFullPlayerSkinComponent()?.serialize().toString(),
"shift_$shift" to Space.of(shift)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,11 @@ import org.bukkit.inventory.ItemStack
object ChattyTags {

private const val SHIFT = "shift"
private const val HEAD = "head"
private const val SKIN = "skin"

val SHIFT_RESOLVER: TagResolver = SerializableResolver.claimingComponent(
SHIFT, { args: ArgumentQueue, ctx: Context -> create(args, ctx, SHIFT) },
{ component: Component? -> emit(component) }
)
val HEAD_RESOLVER: TagResolver = SerializableResolver.claimingComponent(
HEAD, { args: ArgumentQueue, ctx: Context -> create(args, ctx, HEAD) },
{ component: Component? -> emit(component) }
)

val SKIN_RESOLVER: TagResolver = SerializableResolver.claimingComponent(
SKIN, { args: ArgumentQueue, ctx: Context -> create(args, ctx, SKIN) },
{ component: Component? -> emit(component) }
)

fun HELD_ITEM(player: Player) = (player.inventory.itemInMainHand.takeUnless { it == ItemStack.empty() } ?: player.inventory.itemInOffHand.takeUnless { it == ItemStack.empty() })?.let { item ->
val component = item.itemMeta?.displayName()?.let { Component.textOfChildren("[".miniMsg(), it, "]".miniMsg()) } ?: item.displayName()
Expand All @@ -49,8 +38,6 @@ object ChattyTags {
private fun create(args: ArgumentQueue, ctx: Context, tag: String): Tag {
return Tag.selfClosingInserting(when {
tag == SHIFT && args.hasNext() -> Space.of(args.popOr("A shift value is needed").value().toIntOrNull() ?: 0).miniMsg()
tag == HEAD && args.hasNext() -> args.popOr("A player name is needed").value().toPlayer()?.translatePlayerHeadComponent() ?: Component.empty()
tag == SKIN && args.hasNext() -> args.popOr("A player name is needed").value().toPlayer()?.translateFullPlayerSkinComponent() ?: Component.empty()
else -> Component.empty()
})
}
Expand Down

0 comments on commit b7371f4

Please sign in to comment.