From 2319b5622136ef6cfa66c293999f28573c3fb422 Mon Sep 17 00:00:00 2001 From: Gunging Date: Tue, 11 May 2021 11:55:55 -0400 Subject: [PATCH] Crafting stations that require an item be upgraded to a specific level now display which level they expect. --- src/main/java/net/Indyuce/mmoitems/MMOItems.java | 1 + .../crafting/ingredient/MMOItemIngredient.java | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/Indyuce/mmoitems/MMOItems.java b/src/main/java/net/Indyuce/mmoitems/MMOItems.java index 6aab5542..eb334482 100644 --- a/src/main/java/net/Indyuce/mmoitems/MMOItems.java +++ b/src/main/java/net/Indyuce/mmoitems/MMOItems.java @@ -431,6 +431,7 @@ public class MMOItems extends LuminePlugin { * will clear all other PlayerInventories for now, as to keep * backwards compatibility. */ + @Deprecated public void setPlayerInventory(PlayerInventory value) { // Unregisters those previously registered diff --git a/src/main/java/net/Indyuce/mmoitems/api/crafting/ingredient/MMOItemIngredient.java b/src/main/java/net/Indyuce/mmoitems/api/crafting/ingredient/MMOItemIngredient.java index 589de6ac..d55e3c73 100644 --- a/src/main/java/net/Indyuce/mmoitems/api/crafting/ingredient/MMOItemIngredient.java +++ b/src/main/java/net/Indyuce/mmoitems/api/crafting/ingredient/MMOItemIngredient.java @@ -1,6 +1,7 @@ package net.Indyuce.mmoitems.api.crafting.ingredient; import net.Indyuce.mmoitems.ItemStats; +import net.Indyuce.mmoitems.stat.DisplayName; import org.bukkit.inventory.ItemStack; import net.Indyuce.mmoitems.MMOItems; @@ -69,11 +70,15 @@ public class MMOItemIngredient extends Ingredient { } private String findName() { + String name = null; if (template.getBaseItemData().containsKey(ItemStats.NAME)) - return template.getBaseItemData().get(ItemStats.NAME).toString().replace("", "").replace("", "").replace("", ""); - if (template.getBaseItemData().containsKey(ItemStats.MATERIAL)) - return MMOUtils.caseOnWords( - ((MaterialData) template.getBaseItemData().get(ItemStats.MATERIAL)).getMaterial().name().toLowerCase().replace("_", " ")); - return "Unrecognized Item"; + name = template.getBaseItemData().get(ItemStats.NAME).toString().replace("", "").replace("", "").replace("", ""); + + if (template.getBaseItemData().containsKey(ItemStats.MATERIAL) && name == null) + name = MMOUtils.caseOnWords(((MaterialData) template.getBaseItemData().get(ItemStats.MATERIAL)).getMaterial().name().toLowerCase().replace("_", " ")); + + if (name == null) { name = "Unrecognized Item"; } + if (level != 0) { return DisplayName.appendUpgradeLevel(name, level); } + return name; } }