Search in sources :

Example 16 with GuiItem

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

the class ItemsRewardPreviewGUI method createItemsPane.

private Pane createItemsPane() {
    OutlinePane pane = new OutlinePane(0, 0, 9, 6, Priority.LOWEST);
    this.itemsReward.getItems().stream().map(item -> new GuiItem(new ItemStack(item))).forEach(pane::addItem);
    return pane;
}
Also used : OutlinePane(com.github.stefvanschie.inventoryframework.pane.OutlinePane) MessageService(dte.employme.messages.service.MessageService) GuiItem(com.github.stefvanschie.inventoryframework.gui.GuiItem) ChestGui(com.github.stefvanschie.inventoryframework.gui.type.ChestGui) ItemsReward(dte.employme.job.rewards.ItemsReward) INVENTORY_ITEMS_REWARD_PREVIEW_TITLE(dte.employme.messages.MessageKey.INVENTORY_ITEMS_REWARD_PREVIEW_TITLE) Pane(com.github.stefvanschie.inventoryframework.pane.Pane) Priority(com.github.stefvanschie.inventoryframework.pane.Pane.Priority) ItemStack(org.bukkit.inventory.ItemStack) GuiItem(com.github.stefvanschie.inventoryframework.gui.GuiItem) OutlinePane(com.github.stefvanschie.inventoryframework.pane.OutlinePane) ItemStack(org.bukkit.inventory.ItemStack)

Example 17 with GuiItem

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

the class JobBoardGUI method createOfferIcon.

private GuiItem createOfferIcon(Job job) {
    ItemStack basicIcon = this.jobIconFactory.createFor(job);
    boolean finished = this.jobService.hasFinished(this.player, job);
    // add the status and ID to the lore
    String separator = createSeparationLine(finished ? WHITE : DARK_RED, finished ? 25 : 29);
    String finishMessage = this.messageService.getMessage(finished ? INVENTORY_JOB_BOARD_OFFER_COMPLETED : INVENTORY_JOB_BOARD_OFFER_NOT_COMPLETED).first();
    List<String> lore = basicIcon.getItemMeta().getLore();
    lore.add(separator);
    lore.add(StringUtils.repeat(" ", finished ? 8 : 4) + finishMessage);
    lore.add(separator);
    ItemStack item = new ItemBuilder(basicIcon).withLore(lore.toArray(new String[0])).createCopy();
    return new GuiItem(item, event -> {
        // Right click = preview mode for jobs that offer items
        if (event.isRightClick() && job.getReward() instanceof ItemsReward) {
            ItemsRewardPreviewGUI gui = new ItemsRewardPreviewGUI((ItemsReward) job.getReward(), this.messageService);
            gui.setOnClose(closeEvent -> this.player.openInventory(event.getInventory()));
            gui.show(this.player);
        } else // the user wants to finish the job
        if (this.jobService.hasFinished(this.player, job)) {
            this.player.closeInventory();
            this.jobBoard.completeJob(job, this.player);
        }
    });
}
Also used : ItemsReward(dte.employme.job.rewards.ItemsReward) ItemBuilder(dte.employme.utils.items.ItemBuilder) GuiItem(com.github.stefvanschie.inventoryframework.gui.GuiItem) ItemStack(org.bukkit.inventory.ItemStack)

Example 18 with GuiItem

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

the class JobCreationGUI method createOptionsPane.

private Pane createOptionsPane() {
    OutlinePane pane = new OutlinePane(2, 1, 6, 1, Priority.LOW);
    pane.setOrientation(HORIZONTAL);
    pane.setGap(3);
    // add the money job icon
    pane.addItem(new GuiItem(new ItemBuilder(Material.GOLD_INGOT).named(this.messageService.getMessage(INVENTORY_JOB_CREATION_MONEY_JOB_ICON_NAME).first()).withLore(this.messageService.getMessage(INVENTORY_JOB_CREATION_MONEY_JOB_ICON_LORE).toArray()).createCopy(), event -> {
        Player player = (Player) event.getWhoClicked();
        player.closeInventory();
        this.moneyJobConversationFactory.buildConversation(player).begin();
    }));
    // add the items job icon
    pane.addItem(new GuiItem(new ItemBuilder(Material.CHEST).named(this.messageService.getMessage(INVENTORY_JOB_CREATION_ITEMS_JOB_ICON_NAME).first()).withLore(this.messageService.getMessage(INVENTORY_JOB_CREATION_ITEMS_JOB_ICON_LORE).toArray()).createCopy(), event -> new ItemsRewardOfferGUI(this.jobBoard, this.messageService, this.playerContainerService, this.rewardService).show(event.getWhoClicked())));
    return pane;
}
Also used : INVENTORY_JOB_CREATION_MONEY_JOB_ICON_LORE(dte.employme.messages.MessageKey.INVENTORY_JOB_CREATION_MONEY_JOB_ICON_LORE) GuiItem(com.github.stefvanschie.inventoryframework.gui.GuiItem) RewardService(dte.employme.job.rewards.service.RewardService) Player(org.bukkit.entity.Player) PlayerContainerService(dte.employme.containers.service.PlayerContainerService) ConversationFactory(org.bukkit.conversations.ConversationFactory) INVENTORY_JOB_CREATION_TITLE(dte.employme.messages.MessageKey.INVENTORY_JOB_CREATION_TITLE) HORIZONTAL(com.github.stefvanschie.inventoryframework.pane.Orientable.Orientation.HORIZONTAL) INVENTORY_JOB_CREATION_MONEY_JOB_ICON_NAME(dte.employme.messages.MessageKey.INVENTORY_JOB_CREATION_MONEY_JOB_ICON_NAME) Material(org.bukkit.Material) OutlinePane(com.github.stefvanschie.inventoryframework.pane.OutlinePane) InventoryFrameworkUtils.createRectangle(dte.employme.utils.InventoryFrameworkUtils.createRectangle) Economy(net.milkbowl.vault.economy.Economy) ChestGui(com.github.stefvanschie.inventoryframework.gui.type.ChestGui) JobBoard(dte.employme.board.JobBoard) MoneyReward(dte.employme.job.rewards.MoneyReward) INVENTORY_JOB_CREATION_ITEMS_JOB_ICON_LORE(dte.employme.messages.MessageKey.INVENTORY_JOB_CREATION_ITEMS_JOB_ICON_LORE) InventoryUtils.createWall(dte.employme.utils.InventoryUtils.createWall) Priority(com.github.stefvanschie.inventoryframework.pane.Pane.Priority) MessageService(dte.employme.messages.service.MessageService) ItemBuilder(dte.employme.utils.items.ItemBuilder) Conversations(dte.employme.utils.Conversations) Pane(com.github.stefvanschie.inventoryframework.pane.Pane) INVENTORY_JOB_CREATION_ITEMS_JOB_ICON_NAME(dte.employme.messages.MessageKey.INVENTORY_JOB_CREATION_ITEMS_JOB_ICON_NAME) JobPaymentPrompt(dte.employme.job.prompts.JobPaymentPrompt) GuiItem(com.github.stefvanschie.inventoryframework.gui.GuiItem) ItemBuilder(dte.employme.utils.items.ItemBuilder) Player(org.bukkit.entity.Player) OutlinePane(com.github.stefvanschie.inventoryframework.pane.OutlinePane)

Example 19 with GuiItem

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

the class JobDeletionGUI method createDeletionIcon.

private GuiItem createDeletionIcon(Job job) {
    ItemStack item = new ItemBuilder(this.jobIconFactory.createFor(job)).addToLore(true, createSeparationLine(GRAY, 23), this.messageService.getMessage(INVENTORY_JOB_DELETION_DELETE_INSTRUCTION).first(), createSeparationLine(GRAY, 23)).createCopy();
    return new GuiItem(item, event -> {
        Player player = (Player) event.getWhoClicked();
        // Right click = preview mode for jobs that offer items
        if (event.isRightClick() && job.getReward() instanceof ItemsReward) {
            ItemsRewardPreviewGUI gui = new ItemsRewardPreviewGUI((ItemsReward) job.getReward(), this.messageService);
            gui.setOnClose(closeEvent -> show(player));
            gui.show(player);
        } else // delete the job
        {
            player.closeInventory();
            this.jobBoard.removeJob(job);
            this.rewardService.refund(job.getEmployer(), job.getReward());
            this.messageService.getMessage(JOB_SUCCESSFULLY_DELETED).sendTo(player);
        }
    });
}
Also used : ItemsReward(dte.employme.job.rewards.ItemsReward) ItemBuilder(dte.employme.utils.items.ItemBuilder) GuiItem(com.github.stefvanschie.inventoryframework.gui.GuiItem) Player(org.bukkit.entity.Player) ItemStack(org.bukkit.inventory.ItemStack)

Example 20 with GuiItem

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

the class InventoryFrameworkUtils method createWalls.

public static Pane createWalls(ChestGui gui, Priority priority) {
    PatternPane background = new PatternPane(0, 0, 9, 6, createWallsPattern(gui));
    background.bindItem('W', new GuiItem(createWall(Material.BLACK_STAINED_GLASS_PANE)));
    return background;
}
Also used : PatternPane(com.github.stefvanschie.inventoryframework.pane.PatternPane) GuiItem(com.github.stefvanschie.inventoryframework.gui.GuiItem)

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