Skip to content

Commit

Permalink
v2.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
nulli0n committed Nov 25, 2024
1 parent 7237517 commit 90db0b7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/su/nightexpress/nightcore/util/bukkit/NightItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 90db0b7

Please sign in to comment.