diff --git a/src/main/java/su/nightexpress/nightcore/language/entry/LangItem.java b/src/main/java/su/nightexpress/nightcore/language/entry/LangItem.java index 709499c..52427ff 100644 --- a/src/main/java/su/nightexpress/nightcore/language/entry/LangItem.java +++ b/src/main/java/su/nightexpress/nightcore/language/entry/LangItem.java @@ -5,6 +5,7 @@ import su.nightexpress.nightcore.NightCorePlugin; import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.util.ItemUtil; +import su.nightexpress.nightcore.util.bukkit.NightItem; import su.nightexpress.nightcore.util.text.NightMessage; import su.nightexpress.nightcore.util.text.TextRoot; @@ -60,6 +61,11 @@ public void apply(@NotNull ItemStack item) { }); } + public void apply(@NotNull NightItem item) { + item.setDisplayName(this.localizedName); + item.setLore(this.localizedLore); + } + @NotNull public String getDefaultName() { return this.defaultText; diff --git a/src/main/java/su/nightexpress/nightcore/util/bukkit/NightItem.java b/src/main/java/su/nightexpress/nightcore/util/bukkit/NightItem.java index 1e9b572..767459b 100644 --- a/src/main/java/su/nightexpress/nightcore/util/bukkit/NightItem.java +++ b/src/main/java/su/nightexpress/nightcore/util/bukkit/NightItem.java @@ -15,11 +15,13 @@ import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.Writeable; import su.nightexpress.nightcore.core.CoreLogger; +import su.nightexpress.nightcore.language.entry.LangItem; import su.nightexpress.nightcore.util.*; import su.nightexpress.nightcore.util.placeholder.Replacer; import su.nightexpress.nightcore.util.text.NightMessage; import java.nio.charset.StandardCharsets; +import java.util.ArrayList; import java.util.Base64; import java.util.List; @@ -59,6 +61,24 @@ public NightItem(@NotNull Material material, int amount) { this.setAmount(amount); } + @NotNull + public NightItem copy() { + return new NightItem(this.material, this.amount) + .setDamage(this.damage) + .setUnbreakable(this.unbreakable) + .setItemName(this.itemName) + .setDisplayName(this.displayName) + .setLore(this.lore == null ? null : new ArrayList<>(this.lore)) + .setSkinURL(this.skinURL) + .setColor(this.color) + .setModelData(this.modelData) + .setModelPath(this.modelPath) + .setTooltipStyle(this.tooltipStyle) + .setEnchantGlint(this.enchantGlint) + .setHideComponents(this.hideComponents) + .setHideTooltip(this.hideTooltip); + } + @NotNull public static NightItem fromItemStack(@NotNull ItemStack itemStack) { NightItem nightItem = new NightItem(itemStack.getType()); @@ -328,6 +348,12 @@ public NightItem singleAmount() { return this.ignoreAmount(); } + @NotNull + public NightItem localized(@NotNull LangItem langItem) { + langItem.apply(this); + return this; + } + @NotNull public NightItem ignoreNameAndLore() { this.setItemName(null);