|
16 | 16 | import fr.maxlego08.menu.zcore.utils.ZUtils; |
17 | 17 | import fr.maxlego08.menu.zcore.utils.attribute.AttributeApplier; |
18 | 18 | import fr.maxlego08.menu.zcore.utils.meta.Meta; |
19 | | -import fr.maxlego08.menu.zcore.utils.nms.NMSUtils; |
20 | 19 | import fr.maxlego08.menu.zcore.utils.nms.NmsVersion; |
21 | 20 | import org.bukkit.Bukkit; |
22 | 21 | import org.bukkit.Color; |
@@ -59,6 +58,8 @@ public class MenuItemStack extends ZUtils { |
59 | 58 | private List<String> lore = new ArrayList<>(); |
60 | 59 | private List<ItemFlag> flags = new ArrayList<>(); |
61 | 60 | private String displayName; |
| 61 | + private Map<String, String> translatedDisplayName = new HashMap<>(); |
| 62 | + private Map<String, List<String>> translatedLore = new HashMap<>(); |
62 | 63 | private boolean isGlowing; |
63 | 64 | private String modelID; |
64 | 65 | private Map<Enchantment, Integer> enchantments = new HashMap<>(); |
@@ -236,22 +237,25 @@ public ItemStack build(Player player, boolean useCache, Placeholders placeholder |
236 | 237 |
|
237 | 238 | Material finalMaterial = itemStack.getType(); |
238 | 239 | ItemMeta itemMeta = itemStack.getItemMeta(); |
| 240 | + String locale = findPlayerLocale(player); |
239 | 241 |
|
240 | 242 | if (itemMeta != null) { |
241 | 243 | if (this.displayName != null) { |
242 | 244 | try { |
243 | | - Meta.meta.updateDisplayName(itemMeta, placeholders.parse(this.displayName), offlinePlayer == null ? player : offlinePlayer); |
| 245 | + String displayName = locale == null ? this.displayName : this.translatedDisplayName.getOrDefault(locale, this.displayName); |
| 246 | + Meta.meta.updateDisplayName(itemMeta, placeholders.parse(displayName), offlinePlayer == null ? player : offlinePlayer); |
244 | 247 | } catch (Exception exception) { |
245 | 248 | Logger.info("Error with update display name for item " + path + " in file " + filePath + " (" + player + ", " + this.displayName + ")", Logger.LogType.ERROR); |
246 | 249 | exception.printStackTrace(); |
247 | 250 | } |
248 | 251 | } |
249 | 252 |
|
250 | 253 | if (!this.lore.isEmpty()) { |
251 | | - Meta.meta.updateLore(itemMeta, placeholders.parse(this.lore), offlinePlayer == null ? player : offlinePlayer); |
| 254 | + List<String> lore = locale == null ? this.lore : this.translatedLore.getOrDefault(locale, this.lore); |
| 255 | + Meta.meta.updateLore(itemMeta, placeholders.parse(lore), offlinePlayer == null ? player : offlinePlayer); |
252 | 256 | } |
253 | 257 |
|
254 | | - if (this.isGlowing && NMSUtils.getNMSVersion() != 1.7) { |
| 258 | + if (this.isGlowing) { |
255 | 259 |
|
256 | 260 | itemMeta.addEnchant(Enchantment.ARROW_DAMAGE, 1, true); |
257 | 261 | itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS); |
@@ -739,4 +743,20 @@ private List<Color> getColors(MapConfiguration section, String key) { |
739 | 743 |
|
740 | 744 | return colors; |
741 | 745 | } |
| 746 | + |
| 747 | + public Map<String, String> getTranslatedDisplayName() { |
| 748 | + return translatedDisplayName; |
| 749 | + } |
| 750 | + |
| 751 | + public void setTranslatedDisplayName(Map<String, String> translatedDisplayName) { |
| 752 | + this.translatedDisplayName = translatedDisplayName; |
| 753 | + } |
| 754 | + |
| 755 | + public Map<String, List<String>> getTranslatedLore() { |
| 756 | + return translatedLore; |
| 757 | + } |
| 758 | + |
| 759 | + public void setTranslatedLore(Map<String, List<String>> translatedLore) { |
| 760 | + this.translatedLore = translatedLore; |
| 761 | + } |
742 | 762 | } |
0 commit comments