Small tweaks

This commit is contained in:
Len
2022-08-25 17:45:11 +02:00
parent abf53fbbbe
commit 3be53703be
3 changed files with 17 additions and 17 deletions
@@ -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) {