From 58c22628df216f65ea3d60ba6109b2250112ac6a Mon Sep 17 00:00:00 2001 From: iGabyTM Date: Sun, 28 Jul 2024 18:25:42 +0300 Subject: [PATCH] feat(plugin): remove apache commons-text due to increased jar size (+800kb) --- plugin/build.gradle | 2 -- .../me/gabytm/minecraft/arcanevouchers/functions/Strings.kt | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/plugin/build.gradle b/plugin/build.gradle index a81749a..46c04df 100644 --- a/plugin/build.gradle +++ b/plugin/build.gradle @@ -74,8 +74,6 @@ dependencies { // PAPI compileOnly 'me.clip:placeholderapi:2.10.10' - - implementation 'org.apache.commons:commons-text:1.12.0' } compileKotlin { diff --git a/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/functions/Strings.kt b/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/functions/Strings.kt index 578df60..07b6df9 100644 --- a/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/functions/Strings.kt +++ b/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/functions/Strings.kt @@ -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 @@ -26,11 +25,12 @@ fun String.color(): String { } fun String.replace(args: Map): 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, values: Array): 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 = emptySet()): Component {