Skip to content

Commit

Permalink
perf: better code
Browse files Browse the repository at this point in the history
  • Loading branch information
DongShaoNB committed Aug 20, 2024
1 parent eb66103 commit 5cd2da2
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/main/kotlin/cc/dsnb/bedrockplayersupport/util/StringUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,6 @@ object StringUtil {
return stringBuilder.toString()
}

fun formatTextToString(player: Player?, originalText: String): String {
return BedrockPlayerSupport.legacySection.serialize(
BedrockPlayerSupport.miniMessage.deserialize(
if (BedrockPlayerSupport.mainConfigManager.getConfigData().enableSupportPAPI()) {
PlaceholderAPI.setPlaceholders(player, originalText)
} else {
originalText
}
)
)
}

fun formatTextToComponent(player: Player?, originalText: String): Component {
return BedrockPlayerSupport.miniMessage.deserialize(
if (BedrockPlayerSupport.mainConfigManager.getConfigData().enableSupportPAPI()) {
Expand All @@ -44,4 +32,10 @@ object StringUtil {
)
}

fun formatTextToString(player: Player?, originalText: String): String {
return BedrockPlayerSupport.legacySection.serialize(
formatTextToComponent(player, originalText)
)
}

}

0 comments on commit 5cd2da2

Please sign in to comment.