Skip to content

Commit

Permalink
Fix: item name not rendering correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
iceBear67 committed Oct 14, 2024
1 parent d4118cd commit ccdf83b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/main/java/dev/tylerm/khs/util/ItemUtil.java
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
package dev.tylerm.khs.util;

import com.cryptomorin.xseries.XItemStack;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.inventory.ItemStack;

public class ItemUtil{
public class ItemUtil {
public static ItemStack createItem(ConfigurationSection item) {
ConfigurationSection config = new YamlConfiguration().createSection("temp");
String material = item.getString("material").toUpperCase();
boolean splash = false;
if (material.contains("POTION")) {
if(!item.contains("potionLevel")){
if (!item.contains("potionLevel")) {
config.set("level", 1);
}else{
} else {
config.set("level", item.getInt("potionLevel"));
}
}
if (material.equalsIgnoreCase("SPLASH_POTION") || material.equalsIgnoreCase("LINGERING_POTION")) {
material = "POTION";
splash = true;
}
config.set("name", item.getString("name"));
var name = item.getString("name");
if (name != null) config.set("name", ChatColor.translateAlternateColorCodes('&', name));
config.set("material", material);
config.set("enchants", item.getConfigurationSection("enchantments"));
config.set("unbreakable", item.getBoolean("unbreakable"));
if (item.contains("model-data")) {
config.set("model-data", item.getInt("model-data"));
}
if (item.isSet("lore"))
config.set("lore", item.getStringList("lore"));
config.set("lore", item.getStringList("lore").stream().map(it->ChatColor.translateAlternateColorCodes('&',it)).toList());
if (material.equalsIgnoreCase("POTION") || material.equalsIgnoreCase("SPLASH_POTION") || material.equalsIgnoreCase("LINGERING_POTION"))
config.set("base-effect", String.format("%s,%s,%s", item.getString("type"), false, splash));
ItemStack stack = XItemStack.deserialize(config);
Expand Down

0 comments on commit ccdf83b

Please sign in to comment.