Small tweaks
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
package com.alttd.playershops.utils;
|
||||
|
||||
import com.alttd.playershops.shop.PlayerShop;
|
||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
@@ -155,20 +156,18 @@ public class ShopUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String getItemName(ItemStack item) {
|
||||
if (item == null || !item.getType().equals(Material.AIR))
|
||||
return "Nothing";
|
||||
|
||||
String NAME = "{item}";
|
||||
public static Component itemNameComponent(ItemStack item) {
|
||||
Component component = Component.empty();
|
||||
if(item == null || item.getType().equals(Material.AIR))
|
||||
return Component.text("Nothing");
|
||||
boolean dname = item.hasItemMeta() && item.getItemMeta().hasDisplayName();
|
||||
String replacer = ChatColor.translateAlternateColorCodes('&',NAME+"&r");
|
||||
if (dname) {
|
||||
String trp = item.getItemMeta().getDisplayName();
|
||||
replacer = replacer.replace(NAME, trp);
|
||||
if(dname) {
|
||||
component = component.append(item.getItemMeta().displayName());
|
||||
} else {
|
||||
replacer = replacer.replace(NAME, materialToName(item.getType()));
|
||||
component = component.append(Component.text(materialToName(item.getType()), NamedTextColor.WHITE));
|
||||
}
|
||||
return replacer;
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
private static String materialToName(Material m) {
|
||||
|
||||
Reference in New Issue
Block a user