Search in sources :

Example 21 with GuiItem

use of com.github.stefvanschie.inventoryframework.gui.GuiItem in project EmployMe by DavidTheExplorer.

the class GoalCustomizationGUI method createEnchantmentsItem.

private GuiItem createEnchantmentsItem() {
    ItemStack item = new ItemBuilder(Material.ENCHANTED_BOOK).named(this.messageService.getMessage(INVENTORY_GOAL_CUSTOMIZATION_ENCHANTMENTS_ITEM_NAME).first()).withLore(this.messageService.getMessage(INVENTORY_GOAL_CUSTOMIZATION_ENCHANTMENTS_ITEM_LORE).toArray()).glowing().createCopy();
    return new GuiItem(item, event -> {
        if (getType() == NO_ITEM_TYPE)
            return;
        closeWithoutRefund(event.getWhoClicked());
        new GoalEnchantmentSelectionGUI(this.messageService, this, this.reward, this.rewardService).show(event.getWhoClicked());
    });
}
Also used : ItemBuilder(dte.employme.utils.items.ItemBuilder) GuiItem(com.github.stefvanschie.inventoryframework.gui.GuiItem) ItemStack(org.bukkit.inventory.ItemStack)

Example 22 with GuiItem

use of com.github.stefvanschie.inventoryframework.gui.GuiItem in project EmployMe by DavidTheExplorer.

the class GoalCustomizationGUI method setEnchantmentsItemVisibility.

private void setEnchantmentsItemVisibility(boolean visible) {
    GuiItem updatedItem = visible ? createEnchantmentsItem() : new GuiItem(createWall(Material.WHITE_STAINED_GLASS_PANE));
    this.optionsPane.addItem(updatedItem, 6, 3);
}
Also used : GuiItem(com.github.stefvanschie.inventoryframework.gui.GuiItem)

Example 23 with GuiItem

use of com.github.stefvanschie.inventoryframework.gui.GuiItem in project EmployMe by DavidTheExplorer.

the class GoalCustomizationGUI method createTypeChoosingItem.

private GuiItem createTypeChoosingItem() {
    return new GuiItem(new ItemBuilder(Material.ANVIL).named(this.messageService.getMessage(INVENTORY_GOAL_CUSTOMIZATION_TYPE_ITEM_NAME).first()).withLore(this.messageService.getMessage(INVENTORY_GOAL_CUSTOMIZATION_TYPE_ITEM_LORE).toArray()).glowing().createCopy(), event -> {
        HumanEntity player = event.getWhoClicked();
        closeWithoutRefund(player);
        new ItemPaletteGUI(this, this.messageService, this.rewardService, this.reward).show(player);
    });
}
Also used : GuiItem(com.github.stefvanschie.inventoryframework.gui.GuiItem) ItemBuilder(dte.employme.utils.items.ItemBuilder) HumanEntity(org.bukkit.entity.HumanEntity)

Example 24 with GuiItem

use of com.github.stefvanschie.inventoryframework.gui.GuiItem in project EmployMe by DavidTheExplorer.

the class GoalCustomizationGUI method createFinishItem.

/*
	 * Items
	 */
private GuiItem createFinishItem() {
    return new GuiItem(new ItemBuilder(Material.GREEN_TERRACOTTA).named(this.messageService.getMessage(INVENTORY_GOAL_CUSTOMIZATION_FINISH_ITEM_NAME).first()).createCopy(), event -> {
        Material type = this.currentItem.getItem().getType();
        // the user didn't select an item
        if (type == NO_ITEM_TYPE)
            return;
        // the goal is a non-enchanted enchanted book lmfao
        if (type == Material.ENCHANTED_BOOK && getEnchantments(getCurrentItem()).isEmpty())
            return;
        Player player = (Player) event.getWhoClicked();
        closeWithoutRefund(player);
        Job job = new SimpleJob.Builder().by(player).of(createGoal()).thatOffers(this.reward).build();
        this.jobBoard.addJob(job);
    });
}
Also used : GuiItem(com.github.stefvanschie.inventoryframework.gui.GuiItem) ItemBuilder(dte.employme.utils.items.ItemBuilder) Player(org.bukkit.entity.Player) OfflinePlayer(org.bukkit.OfflinePlayer) ItemBuilder(dte.employme.utils.items.ItemBuilder) Material(org.bukkit.Material) SimpleJob(dte.employme.job.SimpleJob) Job(dte.employme.job.Job)

Example 25 with GuiItem

use of com.github.stefvanschie.inventoryframework.gui.GuiItem in project EmployMe by DavidTheExplorer.

the class GoalEnchantmentSelectionGUI method createEnchantedBook.

private GuiItem createEnchantedBook(Enchantment enchantment) {
    ItemStack item = new ItemBuilder(Material.ENCHANTED_BOOK).named(GREEN + EnchantmentUtils.getDisplayName(enchantment)).withLore(this.messageService.getMessage(INVENTORY_GOAL_ENCHANTMENT_SELECTION_ITEM_LORE).toArray()).createCopy();
    return new GuiItem(item, event -> {
        this.showCustomizationGUIOnClose = false;
        Player player = (Player) event.getWhoClicked();
        player.closeInventory();
        Conversations.createFactory(this.messageService).withFirstPrompt(new EnchantmentLevelPrompt(enchantment, this.messageService)).withInitialSessionData(new MapBuilder<Object, Object>().put("Reward", this.reward).build()).addConversationAbandonedListener(Conversations.refundRewardIfAbandoned(this.rewardService)).addConversationAbandonedListener(abandonedEvent -> {
            if (!abandonedEvent.gracefulExit())
                return;
            int level = (int) abandonedEvent.getContext().getSessionData("level");
            this.goalCustomizationGUI.addEnchantment(enchantment, level);
            this.goalCustomizationGUI.setRefundRewardOnClose(true);
            this.goalCustomizationGUI.show(player);
        }).buildConversation(player).begin();
    });
}
Also used : ItemBuilder(dte.employme.utils.items.ItemBuilder) GuiItem(com.github.stefvanschie.inventoryframework.gui.GuiItem) Player(org.bukkit.entity.Player) EnchantmentLevelPrompt(dte.employme.job.prompts.EnchantmentLevelPrompt) ItemStack(org.bukkit.inventory.ItemStack)

Aggregations

GuiItem (com.github.stefvanschie.inventoryframework.gui.GuiItem)46 ItemStack (org.bukkit.inventory.ItemStack)34 ChestGui (com.github.stefvanschie.inventoryframework.gui.type.ChestGui)28 OutlinePane (com.github.stefvanschie.inventoryframework.pane.OutlinePane)25 StaticPane (com.github.stefvanschie.inventoryframework.pane.StaticPane)21 Player (org.bukkit.entity.Player)20 Material (org.bukkit.Material)18 PaginatedPane (com.github.stefvanschie.inventoryframework.pane.PaginatedPane)15 Pane (com.github.stefvanschie.inventoryframework.pane.Pane)11 ItemBuilder (dte.employme.utils.items.ItemBuilder)11 GUIs (fr.rosstail.nodewar.guis.GUIs)9 AdaptMessage (fr.rosstail.nodewar.lang.AdaptMessage)9 Nodewar (fr.rosstail.nodewar.Nodewar)7 YamlConfiguration (org.bukkit.configuration.file.YamlConfiguration)7 HumanEntity (org.bukkit.entity.HumanEntity)7 ArrayList (java.util.ArrayList)6 List (java.util.List)5 ChatColor (org.bukkit.ChatColor)5 NotNull (org.jetbrains.annotations.NotNull)5 Main (com.gmail.stefvanschiedev.buildinggame.Main)4