mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-03-11 13:11:50 +01:00
Crafting Stations now show the amount of the item crafted
For example, a recipe with 3 Steel Ingots as output will display "3 x Steel Ingot" and the display item will be in a stack of 3
This commit is contained in:
parent
cfe1827e14
commit
f07ca103e5
@ -13,12 +13,13 @@ import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.crafting.condition.Condition.ConditionInfo;
|
||||
import net.Indyuce.mmoitems.api.crafting.recipe.CraftingRecipe;
|
||||
import net.Indyuce.mmoitems.api.crafting.recipe.RecipeInfo;
|
||||
import net.Indyuce.mmoitems.api.item.NBTItem;
|
||||
import net.Indyuce.mmoitems.api.item.plugin.ConfigItem;
|
||||
import net.Indyuce.mmoitems.api.util.message.Message;
|
||||
import net.Indyuce.mmoitems.version.nms.ItemTag;
|
||||
|
||||
public class CraftingRecipeDisplay extends ConfigItem {
|
||||
@ -105,13 +106,18 @@ public class CraftingRecipeDisplay extends ConfigItem {
|
||||
lore.set(n, ChatColor.translateAlternateColorCodes('&', lore.get(n)));
|
||||
|
||||
ItemStack item = craftingRecipe.getOutput().getPreview();
|
||||
int amount = craftingRecipe.getOutput().getAmount();
|
||||
|
||||
if(amount > 64) lore.add(0, Message.STATION_BIG_STACK.format(ChatColor.GOLD, "#size#", "" + amount).toString());
|
||||
else item.setAmount(amount);
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.addItemFlags(ItemFlag.values());
|
||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name.replace("#name#", MMOUtils.getDisplayName(item))));
|
||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name.replace("#name#", (amount > 1 ? (ChatColor.WHITE + "" + amount + " x ") : "") + MMOUtils.getDisplayName(item))));
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
|
||||
return MMOItems.plugin.getNMS().getNBTItem(item).addTag(new ItemTag("recipeId", craftingRecipe.getId())).toItem();
|
||||
return NBTItem.get(item).addTag(new ItemTag("recipeId", craftingRecipe.getId())).toItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,11 +7,9 @@ import net.Indyuce.mmoitems.version.VersionMaterial;
|
||||
public class IsSimilar {
|
||||
public static boolean check(ItemStack i1, ItemStack i2) {
|
||||
if(i1.getType() == VersionMaterial.PLAYER_HEAD.toMaterial()) {
|
||||
System.out.println("IS SIMILAR: head");
|
||||
return i1.toString().equals(i2.toString());
|
||||
}
|
||||
|
||||
System.out.println("IS SIMILAR: non head");
|
||||
|
||||
return i1.isSimilar(i2);
|
||||
}
|
||||
}
|
||||
|
@ -76,6 +76,7 @@ public enum Message {
|
||||
CONDITIONS_NOT_MET("You cannot craft this item."),
|
||||
CRAFTING_CANCELED("You cancelled a crafting recipe."),
|
||||
CRAFTING_QUEUE_FULL("The crafting queue is currently full."),
|
||||
STATION_BIG_STACK("Amount Crafted: #size#"),
|
||||
// ALREADY_CRAFTING("You are already crafting something else."),
|
||||
// ALREADY_CRAFTING_STATION("You are already crafting something else in that
|
||||
// station."),
|
||||
|
@ -62,8 +62,11 @@ public class CraftingStationPreview extends PluginInventory {
|
||||
for (int slot : fill)
|
||||
inv.setItem(slot, ConfigItem.FILL.getItem());
|
||||
|
||||
if(recipe.getRecipe() instanceof CraftingRecipe)
|
||||
inv.setItem(16, ((CraftingRecipe) recipe.getRecipe()).getOutput().getPreview());
|
||||
if(recipe.getRecipe() instanceof CraftingRecipe) {
|
||||
ItemStack item = ((CraftingRecipe) recipe.getRecipe()).getOutput().getPreview();
|
||||
item.setAmount(((CraftingRecipe) recipe.getRecipe()).getOutput().getAmount());
|
||||
inv.setItem(16, item);
|
||||
}
|
||||
if(recipe.getRecipe() instanceof UpgradingRecipe) {
|
||||
ItemStack stack = ((UpgradingRecipe) recipe.getRecipe()).getItem().getPreview();
|
||||
ItemMeta meta = stack.getItemMeta();
|
||||
@ -76,6 +79,7 @@ public class CraftingStationPreview extends PluginInventory {
|
||||
inv.setItem(34, ConfigItem.CONFIRM.getItem());
|
||||
ItemStack book = recipe.display();
|
||||
book.setType(Material.KNOWLEDGE_BOOK);
|
||||
book.setAmount(1);
|
||||
ItemMeta meta = book.getItemMeta();
|
||||
List<String> newLore = meta.getLore().subList(0, meta.getLore().size() - 3);
|
||||
meta.setLore(newLore);
|
||||
|
Loading…
Reference in New Issue
Block a user