This commit is contained in:
nulli0n committed 2024-11-25 21:26:19 +05:00
1 parent 723751743b
commit 90db0b7f51
2 files changed
+32

No files matched your search

@@ -5,6 +5,7 @@ import org.jetbrains.annotations.NotNull;
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 class LangItem extends LangEntry {
});
}
public void apply(@NotNull NightItem item) {
item.setDisplayName(this.localizedName);
item.setLore(this.localizedLore);
}
@NotNull
public String getDefaultName() {
return this.defaultText;
@@ -15,11 +15,13 @@ import org.jetbrains.annotations.Nullable;
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 class NightItem implements Writeable {
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 class NightItem implements Writeable {
return this.ignoreAmount();
}
@NotNull
public NightItem localized(@NotNull LangItem langItem) {
langItem.apply(this);
return this;
}
@NotNull
public NightItem ignoreNameAndLore() {
this.setItemName(null);