mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-22 02:12:25 +00:00
Optimize LanguageUtils#getEnchantmentString(...)
This commit is contained in:
parent
4c843c7b66
commit
8ad730376d
@ -23,6 +23,7 @@ import org.bukkit.potion.PotionType;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.StringJoiner;
|
||||||
|
|
||||||
public class LanguageUtils {
|
public class LanguageUtils {
|
||||||
|
|
||||||
@ -2417,21 +2418,13 @@ public class LanguageUtils {
|
|||||||
*/
|
*/
|
||||||
public static String getEnchantmentString(Map<Enchantment, Integer> enchantmentMap) {
|
public static String getEnchantmentString(Map<Enchantment, Integer> enchantmentMap) {
|
||||||
if (enchantmentMap == null) return null;
|
if (enchantmentMap == null) return null;
|
||||||
Enchantment[] enchantments = enchantmentMap.keySet().toArray(new Enchantment[enchantmentMap.size()]);
|
StringJoiner joiner = new StringJoiner(", ");
|
||||||
StringBuilder enchantmentList = new StringBuilder();
|
|
||||||
|
|
||||||
for (int i = 0; i < enchantments.length; i++) {
|
for (Enchantment enchantment : enchantmentMap.keySet()) {
|
||||||
Enchantment enchantment = enchantments[i];
|
joiner.add(LanguageUtils.getEnchantmentName(enchantment, enchantmentMap.get(enchantment)));
|
||||||
|
|
||||||
if (i == enchantments.length - 1) {
|
|
||||||
enchantmentList.append(LanguageUtils.getEnchantmentName(enchantment, enchantmentMap.get(enchantment)));
|
|
||||||
} else {
|
|
||||||
enchantmentList.append(LanguageUtils.getEnchantmentName(enchantment, enchantmentMap.get(enchantment)));
|
|
||||||
enchantmentList.append(", ");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return enchantmentList.toString();
|
return joiner.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user