Skip to content

Commit

Permalink
add fullskin tag and fix nullpointer in placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Feb 3, 2023
1 parent bad1efc commit aafe04b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ object ChattyPermissions {
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,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fun chattyPlaceholders(player: Player?, string: String? = null) : Map<String, St
"player_channel_format" to channel?.format.toString(),
"player_channel_aliases" to channel?.channelAliases.toString(),
"player_channel_proxy_enabled" to channel?.proxy.toString(),
"player_spy_last" to player?.toGeary()?.get<SpyOnChannels>()?.channels?.last().toString(),
"player_spy_last" to player?.toGeary()?.get<SpyOnChannels>()?.channels?.lastOrNull().toString(),

"ping_defaultsound" to chattyConfig.ping.defaultPingSound,
"ping_volume" to chattyConfig.ping.pingVolume.toString(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mineinabyss.chatty.tags

import com.mineinabyss.chatty.helpers.toPlayer
import com.mineinabyss.chatty.helpers.translateFullPlayerSkinComponent
import com.mineinabyss.chatty.helpers.translatePlayerHeadComponent
import com.mineinabyss.idofront.font.Space
import com.mineinabyss.idofront.messaging.miniMsg
Expand All @@ -16,6 +17,7 @@ object ChattyTags {

private val SHIFT = "shift"
private val HEAD = "head"
private val SKIN = "skin"
private val WHITE = "white"

val SHIFT_RESOLVER: TagResolver = SerializableResolver.claimingComponent(
Expand All @@ -27,6 +29,11 @@ object ChattyTags {
{ component: Component? -> emit(component) }
)

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

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

Expand All @@ -40,6 +47,12 @@ object ChattyTags {
args.popOr("A player name is needed").value().toPlayer()?.translatePlayerHeadComponent()
?: Component.empty()
) else Tag.selfClosingInserting(Component.empty())

SKIN -> return if (args.hasNext()) Tag.selfClosingInserting(
args.popOr("A player name is needed").value().toPlayer()?.translateFullPlayerSkinComponent()
?: Component.empty()
) else Tag.selfClosingInserting(Component.empty())

WHITE -> Tag.selfClosingInserting(Component.empty().color(NamedTextColor.WHITE))
}

Expand Down

0 comments on commit aafe04b

Please sign in to comment.