Skip to content

Commit

Permalink
feat(plugin): remove apache commons-text
Browse files Browse the repository at this point in the history
due to increased jar size (+800kb)
  • Loading branch information
iGabyTM committed Jul 28, 2024
1 parent 5259a23 commit 58c2262
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 0 additions & 2 deletions plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ dependencies {

// PAPI
compileOnly 'me.clip:placeholderapi:2.10.10'

implementation 'org.apache.commons:commons-text:1.12.0'
}

compileKotlin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import net.kyori.adventure.text.format.TextDecoration
import net.kyori.adventure.text.minimessage.ParsingException
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver
import net.md_5.bungee.api.ChatColor
import org.apache.commons.lang3.StringUtils
import org.bukkit.Bukkit
import org.bukkit.Color
import org.bukkit.OfflinePlayer
Expand All @@ -26,11 +25,12 @@ fun String.color(): String {
}

fun String.replace(args: Map<String, String>): String {
return this.replace(args.keys.toTypedArray(), args.values.toTypedArray())
return args.entries.fold(this) { string, (placeholder, value) -> string.replace(placeholder, value) }
}

fun String.replace(placeholders: Array<String>, values: Array<String>): String {
return StringUtils.replaceEach(this, placeholders, values)
return placeholders.zip(values)
.fold(this) { string, (placeholder, value) -> string.replace(placeholder, value) }
}

fun String.mini(removeItalic: Boolean = false, customTagResolvers: Set<TagResolver> = emptySet()): Component {
Expand Down

0 comments on commit 58c2262

Please sign in to comment.