Skip to content

Commit

Permalink
change to how skin components are generated
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Mar 4, 2023
1 parent f9d962c commit c8cc78c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,10 @@ class ChattyCommands : IdofrontCommandExecutor(), TabCompleter {
chattyData.lastChannelUsed = channel.key
chatty.launch(chatty.asyncDispatcher) {
GenericChattyDecorateEvent(this@shortcutCommand, arguments.toSentence().miniMsg()).call {
GenericChattyChatEvent(
this@shortcutCommand,
(this as AsyncChatDecorateEvent).result()
).callEvent()
GenericChattyChatEvent(this@shortcutCommand, (this as AsyncChatDecorateEvent).result()).callEvent()
}
chattyData.channelId = currentChannel
}
chattyData.channelId = currentChannel
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ fun OfflinePlayer.translatePlayerHeadComponent(): Component {
}

val playerBodyMapCache = mutableMapOf<OfflinePlayer, Component>()
fun Player.refreshSkinInCaches() {
playerBodyMapCache -= this
playerHeadMapCache -= this
}
fun OfflinePlayer.translateFullPlayerSkinComponent(): Component {
if (this !in playerBodyMapCache || playerBodyMapCache[this]!!.font() != Key.key(chattyConfig.playerHeadFont)) {
playerBodyMapCache[this] = runCatching { getFullPlayerBodyTexture(ascent = -5) }.getOrDefault(Component.empty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ class PlayerListener : Listener {

@EventHandler(priority = EventPriority.NORMAL)
fun PlayerJoinEvent.onJoin() {
player.translatePlayerHeadComponent()
player.translateFullPlayerSkinComponent()

player.verifyPlayerChannel()
if (chattyConfig.join.enabled && !player.toGeary().has<HideJoinLeave>())
joinMessage(translatePlaceholders(player, chattyMessages.joinLeave.joinMessage))
Expand All @@ -36,8 +33,7 @@ class PlayerListener : Listener {
@EventHandler
fun PlayerQuitEvent.onDisconnect() {
// Remove player incase they switch skins
playerHeadMapCache -= player
playerBodyMapCache -= player
player.refreshSkinInCaches()

if (chattyConfig.leave.enabled && !player.toGeary().has<HideJoinLeave>())
quitMessage(translatePlaceholders(player, chattyMessages.joinLeave.leaveMessage))
Expand Down

0 comments on commit c8cc78c

Please sign in to comment.