diff --git a/type.generic/src/main/java/net/swofty/types/generic/collection/CollectionCategory.java b/type.generic/src/main/java/net/swofty/types/generic/collection/CollectionCategory.java index 83628ec5..b50f3c32 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/collection/CollectionCategory.java +++ b/type.generic/src/main/java/net/swofty/types/generic/collection/CollectionCategory.java @@ -1,11 +1,14 @@ package net.swofty.types.generic.collection; +import net.kyori.adventure.text.Component; import net.minestom.server.item.ItemComponent; import net.minestom.server.item.ItemStack; import net.minestom.server.item.Material; import net.swofty.commons.item.ItemType; import net.swofty.types.generic.gui.inventory.ItemStackCreator; import net.swofty.types.generic.item.ItemTypeLinker; +import net.swofty.types.generic.item.SkyBlockItem; +import net.swofty.types.generic.item.impl.Minion; import net.swofty.types.generic.item.impl.SkyBlockRecipe; import net.swofty.types.generic.item.updater.NonPlayerItemUpdater; import net.swofty.types.generic.user.SkyBlockPlayer; @@ -55,7 +58,11 @@ public List getDisplay(List lore, String itemDisplay) { switch (unlock.type()) { case RECIPE -> { ((UnlockRecipe) unlock).getRecipes().forEach(recipe -> { - lore.add("§7 §e" + recipe.getResult().getDisplayName() + " §7Recipes"); + if (recipe.getResult().getDisplayName().contains("Minion") && !Arrays.toString(lore.toArray()).contains("Minion §7Recipes")) { + lore.add("§9 " + StringUtility.toNormalCase(recipe.getResult().getAttributeHandler().getMinionType().toString()) + " Minion §7Recipes"); + } else if (!recipe.getResult().getDisplayName().contains("Minion")) { + lore.add("§7 §e" + recipe.getResult().getDisplayName() + " §7Recipe"); + } }); } case CUSTOM_AWARD -> { @@ -92,16 +99,28 @@ public UnlockType type() { @Override public ItemStack.Builder getDisplay(SkyBlockPlayer player) { + SkyBlockItem skyBlockItem = getRecipes().getFirst().getResult(); ItemStack.Builder updatedItem = new NonPlayerItemUpdater(getRecipes().getFirst().getResult()).getUpdatedItem(); - ArrayList lore = new ArrayList<>( - updatedItem.build().get(ItemComponent.LORE).stream().map(StringUtility::getTextFromComponent).toList() - ); - lore.add(" "); - int others = getRecipes().size() - 1; - if (others > 0) { - lore.add("§8+" + others + " more recipes"); + ArrayList lore = new ArrayList<>(updatedItem.build().get(ItemComponent.LORE).stream().map(StringUtility::getTextFromComponent).toList()); + if (skyBlockItem.getGenericInstance() instanceof Minion) { + String material = StringUtility.toNormalCase(skyBlockItem.getAttributeHandler().getMinionType().toString()); + updatedItem.customName(Component.text("§r§9" + material + " Minion Recipes")); + lore.clear(); + lore.add("§7Place this minion and it will start"); + lore.add("§7generating and mining " + material + "!"); + lore.add("§7Requires an open area to place"); + lore.add("§7" + material + "."); + lore.add(""); + lore.add("§eClick to view recipes!"); + } else { + lore.add(" "); + int others = getRecipes().size() - 1; + + if (others > 0) { + lore.add("§8+" + others + " more recipes"); + } + lore.add("§eClick to view recipe"); } - lore.add("§eClick to view recipe"); return ItemStackCreator.updateLore(updatedItem, lore); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/gui/inventory/inventories/sbmenu/collection/GUICollectionReward.java b/type.generic/src/main/java/net/swofty/types/generic/gui/inventory/inventories/sbmenu/collection/GUICollectionReward.java index d5d49f82..523a1522 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/gui/inventory/inventories/sbmenu/collection/GUICollectionReward.java +++ b/type.generic/src/main/java/net/swofty/types/generic/gui/inventory/inventories/sbmenu/collection/GUICollectionReward.java @@ -10,11 +10,13 @@ import net.swofty.types.generic.collection.CollectionCategory; import net.swofty.types.generic.gui.inventory.ItemStackCreator; import net.swofty.types.generic.gui.inventory.SkyBlockInventoryGUI; +import net.swofty.types.generic.gui.inventory.inventories.sbmenu.recipe.GUIMinionRecipes; import net.swofty.types.generic.gui.inventory.inventories.sbmenu.recipe.GUIRecipe; import net.swofty.types.generic.gui.inventory.item.GUIClickableItem; import net.swofty.types.generic.gui.inventory.item.GUIItem; import net.swofty.types.generic.item.ItemTypeLinker; import net.swofty.types.generic.item.SkyBlockItem; +import net.swofty.types.generic.item.impl.Minion; import net.swofty.types.generic.user.SkyBlockPlayer; import net.swofty.commons.StringUtility; @@ -82,8 +84,16 @@ public ItemStack.Builder getItem(SkyBlockPlayer player) { @Override public void run(InventoryPreClickEvent e, SkyBlockPlayer player) { if (unlock instanceof CollectionCategory.UnlockRecipe) { - SkyBlockItem item = ((CollectionCategory.UnlockRecipe) unlock).getRecipe().getResult(); - new GUIRecipe(item.getAttributeHandler().getPotentialClassLinker(), null).open(player); + try { + SkyBlockItem skyBlockItem = ((CollectionCategory.UnlockRecipe) unlock).getRecipes().getFirst().getResult(); + if (skyBlockItem.getGenericInstance() instanceof Minion) { + new GUIMinionRecipes(skyBlockItem.getAttributeHandler().getMinionType(), new GUICollectionReward(item, reward)).open(player); + } else { + new GUIRecipe(skyBlockItem.getAttributeHandler().getPotentialClassLinker(), null).open(player); + } + } catch (NullPointerException exception) { + player.sendMessage("There is no recipe available for this item!"); + } } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/gui/inventory/inventories/sbmenu/recipe/GUIMinionRecipes.java b/type.generic/src/main/java/net/swofty/types/generic/gui/inventory/inventories/sbmenu/recipe/GUIMinionRecipes.java new file mode 100644 index 00000000..d2faa291 --- /dev/null +++ b/type.generic/src/main/java/net/swofty/types/generic/gui/inventory/inventories/sbmenu/recipe/GUIMinionRecipes.java @@ -0,0 +1,95 @@ +package net.swofty.types.generic.gui.inventory.inventories.sbmenu.recipe; + +import net.minestom.server.event.inventory.InventoryCloseEvent; +import net.minestom.server.event.inventory.InventoryPreClickEvent; +import net.minestom.server.inventory.Inventory; +import net.minestom.server.inventory.InventoryType; +import net.minestom.server.item.ItemStack; +import net.minestom.server.item.Material; +import net.swofty.commons.StringUtility; +import net.swofty.commons.item.attribute.attributes.ItemAttributeMinionData; +import net.swofty.types.generic.gui.inventory.ItemStackCreator; +import net.swofty.types.generic.gui.inventory.SkyBlockInventoryGUI; +import net.swofty.types.generic.gui.inventory.item.GUIClickableItem; +import net.swofty.types.generic.item.SkyBlockItem; +import net.swofty.types.generic.minion.MinionRegistry; +import net.swofty.types.generic.minion.SkyBlockMinion; +import net.swofty.types.generic.user.SkyBlockPlayer; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class GUIMinionRecipes extends SkyBlockInventoryGUI { + private static final Map SLOTS = new HashMap<>(Map.of( + 10, new int[] { 11, 12, 13, 14, 15, 20, 21, 22, 23, 24 }, + 11, new int[] { 11, 12, 13, 14, 15, 21, 22, 23, 30, 31, 32 } + )); + + SkyBlockInventoryGUI previousGUI; + MinionRegistry minionRegistry; + + public GUIMinionRecipes(MinionRegistry minionRegistry, SkyBlockInventoryGUI previousGUI) { + super(StringUtility.toNormalCase(minionRegistry.toString()) + " Minion Recipes", InventoryType.CHEST_6_ROW); + this.previousGUI = previousGUI; + this.minionRegistry = minionRegistry; + } + + @Override + public void onOpen(InventoryGUIOpenEvent e) { + fill(ItemStackCreator.createNamedItemStack(Material.BLACK_STAINED_GLASS_PANE)); + set(GUIClickableItem.getCloseItem(49)); + set(GUIClickableItem.getGoBackItem(48, previousGUI)); + + List craftableMinionTiers = new ArrayList<>(); + + for (SkyBlockMinion.MinionTier minionTier : minionRegistry.asSkyBlockMinion().getTiers()) { + if (minionTier.craftable()) craftableMinionTiers.add(minionTier); + } + + int[] slots = SLOTS.get(craftableMinionTiers.size()); + int i = 0; + for (SkyBlockMinion.MinionTier minionTier : craftableMinionTiers) { + int slot = slots[i]; + i++; + SkyBlockItem minion = new SkyBlockItem(minionRegistry.getItemTypeLinker()); + minion.getAttributeHandler().setMinionData(new ItemAttributeMinionData.MinionData(minionTier.tier(), 0)); + + set(new GUIClickableItem(slot) { + @Override + public void run(InventoryPreClickEvent e, SkyBlockPlayer player) { + new GUIRecipe(minion, new GUIMinionRecipes(minionRegistry, previousGUI), minionTier.tier() - 1).open(player); + } + + @Override + public ItemStack.Builder getItem(SkyBlockPlayer player) { + return ItemStackCreator.getStackHead(minion.getDisplayName(), minionTier.texture(), 1, + minion.getLore()); + } + }); + } + + updateItemStacks(getInventory(), getPlayer()); + } + + @Override + public boolean allowHotkeying() { + return false; + } + + @Override + public void onClose(InventoryCloseEvent e, CloseReason reason) { + + } + + @Override + public void suddenlyQuit(Inventory inventory, SkyBlockPlayer player) { + + } + + @Override + public void onBottomClick(InventoryPreClickEvent e) { + e.setCancelled(true); + } +} diff --git a/type.generic/src/main/java/net/swofty/types/generic/gui/inventory/inventories/sbmenu/recipe/GUIRecipe.java b/type.generic/src/main/java/net/swofty/types/generic/gui/inventory/inventories/sbmenu/recipe/GUIRecipe.java index 95bd03f4..e1bf834a 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/gui/inventory/inventories/sbmenu/recipe/GUIRecipe.java +++ b/type.generic/src/main/java/net/swofty/types/generic/gui/inventory/inventories/sbmenu/recipe/GUIRecipe.java @@ -21,6 +21,7 @@ import net.swofty.types.generic.user.SkyBlockPlayer; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; public class GUIRecipe extends SkyBlockInventoryGUI { @@ -82,6 +83,8 @@ public ItemStack.Builder getItem(SkyBlockPlayer player) { recipeIndex = 0; SkyBlockRecipe recipe = recipes.get(recipeIndex); + Arrays.stream(recipe.getRecipeDisplay()).toList().forEach(recipeList -> System.out.println("RecipeList: " + recipeList.toString())); + if (recipes.size() > recipeIndex + 1) { set(new GUIClickableItem(32) { @Override diff --git a/type.generic/src/main/java/net/swofty/types/generic/item/impl/Minion.java b/type.generic/src/main/java/net/swofty/types/generic/item/impl/Minion.java index 5f0c9c71..a60ef93f 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/item/impl/Minion.java +++ b/type.generic/src/main/java/net/swofty/types/generic/item/impl/Minion.java @@ -58,11 +58,27 @@ default List> getRawRecipes() { )), pattern ); + try { + for (SkyBlockItem skyBlockItem : recipe.getRecipeDisplay()) { + System.out.println("Before addExtraRequirement: " + skyBlockItem); + } + } catch (NullPointerException _) { + + } recipe.addExtraRequirement('B', (minionItem) -> { + System.out.println("1: " + minionItem.toString()); if (minionItem.getGenericInstance() instanceof Minion) return minionItem.getAttributeHandler().getMinionData().tier() == Math.max(1, tier.tier() - 1); + System.out.println("2: " + minionItem.toString()); return true; }); + try { + for (SkyBlockItem skyBlockItem : recipe.getRecipeDisplay()) { + System.out.println("After addExtraRequirement: " + skyBlockItem); + } + } catch (NullPointerException _) { + + } toReturn.add(recipe); }); diff --git a/type.generic/src/main/java/net/swofty/types/generic/item/impl/SkyBlockRecipe.java b/type.generic/src/main/java/net/swofty/types/generic/item/impl/SkyBlockRecipe.java index ad6a5808..8b90d731 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/item/impl/SkyBlockRecipe.java +++ b/type.generic/src/main/java/net/swofty/types/generic/item/impl/SkyBlockRecipe.java @@ -54,7 +54,7 @@ public static SkyBlockRecipe parseRecipe(ItemStack[] stacks) { return ShapelessRecipe.parseShapelessRecipe(stacks); } - public static @NotNull List> getFromType(ItemTypeLinker type) { + public static @NotNull List> getFromType(ItemTypeLinker type) { ArrayList> recipes = new ArrayList<>(); ShapedRecipe.CACHED_RECIPES.forEach(recipe -> { ItemTypeLinker itemTypeLinker = recipe.getResult().getAttributeHandler().getPotentialClassLinker(); diff --git a/type.generic/src/main/java/net/swofty/types/generic/item/impl/recipes/ShapedRecipe.java b/type.generic/src/main/java/net/swofty/types/generic/item/impl/recipes/ShapedRecipe.java index a7332d44..e11e22d1 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/item/impl/recipes/ShapedRecipe.java +++ b/type.generic/src/main/java/net/swofty/types/generic/item/impl/recipes/ShapedRecipe.java @@ -232,7 +232,7 @@ public static ShapedRecipe parseShapedRecipe(ItemStack[] stacks) { } } } - + System.out.println("First Filter: " + recipe.getRecipeDisplay().toString()); return false; }) .filter(recipe -> { @@ -240,18 +240,21 @@ public static ShapedRecipe parseShapedRecipe(ItemStack[] stacks) { Character character = entry.getKey(); Function extraRequirements = recipe.getExtraRequirements().get(character); + System.out.println("ExtraRequirements: " + extraRequirements.toString()); if (extraRequirements == null) { continue; } for (int position : entry.getValue()) { SkyBlockItem item = new SkyBlockItem(stacks[position]); + System.out.println("Item: " + item.toString()); if (!extraRequirements.apply(item)) { return false; } + //extraRequirements.apply(item); } } - + System.out.println("Second Filter: " + recipe.getRecipeDisplay().toString()); return true; }) .max(Comparator.comparing(recipe -> {