Search in sources :

Example 1 with RecipeDisplayItem

use of io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem in project Slimefun4 by Slimefun.

the class SurvivalSlimefunGuide method displayItem.

@Override
@ParametersAreNonnullByDefault
public void displayItem(PlayerProfile profile, SlimefunItem item, boolean addToHistory) {
    Player p = profile.getPlayer();
    if (p == null) {
        return;
    }
    ChestMenu menu = create(p);
    Optional<String> wiki = item.getWikipage();
    if (wiki.isPresent()) {
        menu.addItem(8, new CustomItemStack(Material.KNOWLEDGE_BOOK, ChatColor.WHITE + Slimefun.getLocalization().getMessage(p, "guide.tooltips.wiki"), "", ChatColor.GRAY + "\u21E8 " + ChatColor.GREEN + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup")));
        menu.addMenuClickHandler(8, (pl, slot, itemstack, action) -> {
            pl.closeInventory();
            ChatUtils.sendURL(pl, wiki.get());
            return false;
        });
    }
    AsyncRecipeChoiceTask task = new AsyncRecipeChoiceTask();
    if (addToHistory) {
        profile.getGuideHistory().add(item);
    }
    ItemStack result = item.getRecipeOutput();
    RecipeType recipeType = item.getRecipeType();
    ItemStack[] recipe = item.getRecipe();
    displayItem(menu, profile, p, item, result, recipeType, recipe, task);
    if (item instanceof RecipeDisplayItem) {
        displayRecipes(p, profile, menu, (RecipeDisplayItem) item, 0);
    }
    menu.open(p);
    if (!task.isEmpty()) {
        task.start(menu.toInventory());
    }
}
Also used : Player(org.bukkit.entity.Player) RecipeDisplayItem(io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem) RecipeType(io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType) CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) ItemStack(org.bukkit.inventory.ItemStack) CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) ChestMenu(me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu) AsyncRecipeChoiceTask(io.github.thebusybiscuit.slimefun4.implementation.tasks.AsyncRecipeChoiceTask) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault)

Aggregations

CustomItemStack (io.github.bakedlibs.dough.items.CustomItemStack)1 RecipeType (io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType)1 RecipeDisplayItem (io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem)1 AsyncRecipeChoiceTask (io.github.thebusybiscuit.slimefun4.implementation.tasks.AsyncRecipeChoiceTask)1 ParametersAreNonnullByDefault (javax.annotation.ParametersAreNonnullByDefault)1 ChestMenu (me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu)1 Player (org.bukkit.entity.Player)1 ItemStack (org.bukkit.inventory.ItemStack)1