Search in sources :

Example 11 with OutlinePane

use of com.github.stefvanschie.inventoryframework.pane.OutlinePane in project EmployMe by DavidTheExplorer.

the class JobBoardGUI method createJobsPane.

private Pane createJobsPane() {
    OutlinePane pane = new OutlinePane(1, 1, 7, 5, Priority.LOW);
    pane.setOrientation(HORIZONTAL);
    this.jobBoard.getOfferedJobs().stream().sorted(this.orderComparator).map(this::createOfferIcon).forEach(pane::addItem);
    return pane;
}
Also used : OutlinePane(com.github.stefvanschie.inventoryframework.pane.OutlinePane)

Example 12 with OutlinePane

use of com.github.stefvanschie.inventoryframework.pane.OutlinePane 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 13 with OutlinePane

use of com.github.stefvanschie.inventoryframework.pane.OutlinePane in project EmployMe by DavidTheExplorer.

the class PlayerJobsGUI method createJobsPane.

private Pane createJobsPane() {
    OutlinePane pane = new OutlinePane(1, 1, 7, 5, Priority.LOW);
    pane.setOrientation(HORIZONTAL);
    this.jobsToDisplay.stream().sorted(this.orderComparator).map(this.jobIconFactory::createFor).map(GuiItem::new).forEach(pane::addItem);
    return pane;
}
Also used : OutlinePane(com.github.stefvanschie.inventoryframework.pane.OutlinePane)

Example 14 with OutlinePane

use of com.github.stefvanschie.inventoryframework.pane.OutlinePane in project EmployMe by DavidTheExplorer.

the class GoalEnchantmentSelectionGUI method getEnchantmentsPane.

private Pane getEnchantmentsPane() {
    OutlinePane pane = new OutlinePane(0, 0, 9, 6, Priority.LOW);
    EnchantmentUtils.getRemainingEnchantments(this.goalCustomizationGUI.getCurrentItem()).stream().sorted(ORDER_BY_NAME).map(this::createEnchantedBook).forEach(pane::addItem);
    return pane;
}
Also used : OutlinePane(com.github.stefvanschie.inventoryframework.pane.OutlinePane)

Example 15 with OutlinePane

use of com.github.stefvanschie.inventoryframework.pane.OutlinePane in project buildinggame by stefvanschie.

the class ReportMenu method playerReportsGui.

/**
 * Creates a reports gui where the reports are for the specified player.
 *
 * @param player the reportee of the reports gui
 * @return the gui created
 * @since 6.5.0
 */
@NotNull
@Contract(pure = true)
private ChestGui playerReportsGui(@NotNull OfflinePlayer player) {
    ChestGui gui = new ChestGui(6, ChatColor.GREEN + player.getName() + "'s reports");
    var paginatedPane = new PaginatedPane(0, 0, 9, 5);
    int paginatedPaneArea = paginatedPane.getLength() * paginatedPane.getHeight();
    for (int page = 0; page < Math.min(1, Math.ceil((double) Report.getReports(player).size() / paginatedPaneArea)); page++) {
        var outlinePane = new OutlinePane(0, 0, 9, 5);
        for (int i = 0; i < paginatedPaneArea; i++) {
            var index = i + (page * paginatedPaneArea);
            if (index >= Report.getReports(player).size()) {
                break;
            }
            var report = Report.getReports(player).get(index);
            var reportItem = new ItemStack(Material.PAPER);
            var reportMeta = reportItem.getItemMeta();
            reportMeta.setDisplayName(ChatColor.GOLD + "Report #" + (index + 1));
            reportMeta.setLore(Arrays.asList(ChatColor.AQUA + "By: " + report.getReporter().getName(), ChatColor.AQUA + "At: " + report.getDate().format(DateTimeFormatter.RFC_1123_DATE_TIME)));
            reportItem.setItemMeta(reportMeta);
            outlinePane.addItem(new GuiItem(reportItem, event -> {
                HumanEntity clicker = event.getWhoClicked();
                if (event.isLeftClick()) {
                    new BukkitRunnable() {

                        @Override
                        public void run() {
                            try {
                                var clipboard = report.loadSchematic();
                                new BukkitRunnable() {

                                    @Override
                                    public void run() {
                                        WorldEditPlugin plugin = WorldEditPlugin.getPlugin(WorldEditPlugin.class);
                                        LocalSession session = plugin.getSession((Player) clicker);
                                        session.setClipboard(new ClipboardHolder(clipboard));
                                        clicker.closeInventory();
                                        MessageManager.getInstance().send(clicker, ChatColor.GREEN + "The schematic has been copied to your clipboard.");
                                    }
                                }.runTask(Main.getInstance());
                            } catch (IOException exception) {
                                exception.printStackTrace();
                            }
                        }
                    }.runTaskAsynchronously(Main.getInstance());
                } else if (event.isRightClick()) {
                    new ConfirmationMenu(ChatColor.GREEN + "Are you sure you want to delete this report?", click -> new BukkitRunnable() {

                        @Override
                        public void run() {
                            if (click == ConfirmationMenu.Response.ACCEPT) {
                                Report.delete(report);
                                playerReportsGui((OfflinePlayer) clicker).show(clicker);
                            } else if (click == ConfirmationMenu.Response.DENY) {
                                gui.show(clicker);
                            } else {
                                throw new IllegalStateException("Unknown confirmation click type");
                            }
                        }
                    }.runTaskLater(Main.getInstance(), 1L)).show(clicker);
                }
                event.setCancelled(true);
            }));
        }
        paginatedPane.addPane(page, outlinePane);
    }
    gui.addPane(paginatedPane);
    var backItemPane = new OutlinePane(4, 5, 1, 1);
    var backItem = new ItemStack(Material.BOOK);
    var backMeta = backItem.getItemMeta();
    backMeta.setDisplayName(ChatColor.GREEN + "Go back");
    backItem.setItemMeta(backMeta);
    backItemPane.addItem(new GuiItem(backItem, event -> show(event.getWhoClicked())));
    gui.addPane(backItemPane);
    if (paginatedPane.getPages() > 1) {
        var previousPageItemPane = new OutlinePane(2, 5, 1, 1);
        var nextPageItemPane = new OutlinePane(6, 5, 1, 1);
        var previousPageItem = new ItemStack(Material.SUGAR_CANE);
        var previousPageMeta = previousPageItem.getItemMeta();
        previousPageMeta.setDisplayName(ChatColor.GREEN + "Previous page");
        previousPageItem.setItemMeta(previousPageMeta);
        previousPageItemPane.addItem(new GuiItem(previousPageItem, event -> {
            paginatedPane.setPage(paginatedPane.getPage() - 1);
            if (paginatedPane.getPage() == 0) {
                previousPageItemPane.setVisible(false);
            }
            nextPageItemPane.setVisible(true);
            update();
            event.setCancelled(true);
        }));
        var nextPageItem = new ItemStack(Material.SUGAR_CANE);
        var nextPageMeta = nextPageItem.getItemMeta();
        nextPageMeta.setDisplayName(ChatColor.GREEN + "Next page");
        nextPageItem.setItemMeta(nextPageMeta);
        nextPageItemPane.addItem(new GuiItem(nextPageItem, event -> {
            paginatedPane.setPage(paginatedPane.getPage() + 1);
            if (paginatedPane.getPage() == paginatedPane.getPages() - 1) {
                nextPageItemPane.setVisible(false);
            }
            previousPageItemPane.setVisible(true);
            update();
            event.setCancelled(true);
        }));
        gui.addPane(previousPageItemPane);
        gui.addPane(nextPageItemPane);
    }
    return gui;
}
Also used : ChestGui(com.github.stefvanschie.inventoryframework.gui.type.ChestGui) Arrays(java.util.Arrays) GuiItem(com.github.stefvanschie.inventoryframework.gui.GuiItem) ClipboardHolder(com.sk89q.worldedit.session.ClipboardHolder) Player(org.bukkit.entity.Player) SkullMeta(org.bukkit.inventory.meta.SkullMeta) Main(com.gmail.stefvanschiedev.buildinggame.Main) Material(org.bukkit.Material) PaginatedPane(com.github.stefvanschie.inventoryframework.pane.PaginatedPane) HumanEntity(org.bukkit.entity.HumanEntity) OutlinePane(com.github.stefvanschie.inventoryframework.pane.OutlinePane) ChestGui(com.github.stefvanschie.inventoryframework.gui.type.ChestGui) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) MessageManager(com.gmail.stefvanschiedev.buildinggame.managers.messages.MessageManager) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) OfflinePlayer(org.bukkit.OfflinePlayer) ItemStack(org.bukkit.inventory.ItemStack) WorldEditPlugin(com.sk89q.worldedit.bukkit.WorldEditPlugin) Contract(org.jetbrains.annotations.Contract) List(java.util.List) DateTimeFormatter(java.time.format.DateTimeFormatter) ChatColor(org.bukkit.ChatColor) LocalSession(com.sk89q.worldedit.LocalSession) NotNull(org.jetbrains.annotations.NotNull) Comparator(java.util.Comparator) Collections(java.util.Collections) Report(com.gmail.stefvanschiedev.buildinggame.utils.Report) GuiItem(com.github.stefvanschie.inventoryframework.gui.GuiItem) Player(org.bukkit.entity.Player) OfflinePlayer(org.bukkit.OfflinePlayer) ClipboardHolder(com.sk89q.worldedit.session.ClipboardHolder) PaginatedPane(com.github.stefvanschie.inventoryframework.pane.PaginatedPane) LocalSession(com.sk89q.worldedit.LocalSession) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) IOException(java.io.IOException) WorldEditPlugin(com.sk89q.worldedit.bukkit.WorldEditPlugin) OutlinePane(com.github.stefvanschie.inventoryframework.pane.OutlinePane) HumanEntity(org.bukkit.entity.HumanEntity) ItemStack(org.bukkit.inventory.ItemStack) NotNull(org.jetbrains.annotations.NotNull) Contract(org.jetbrains.annotations.Contract)

Aggregations

OutlinePane (com.github.stefvanschie.inventoryframework.pane.OutlinePane)23 GuiItem (com.github.stefvanschie.inventoryframework.gui.GuiItem)17 ChestGui (com.github.stefvanschie.inventoryframework.gui.type.ChestGui)17 ItemStack (org.bukkit.inventory.ItemStack)16 PaginatedPane (com.github.stefvanschie.inventoryframework.pane.PaginatedPane)9 StaticPane (com.github.stefvanschie.inventoryframework.pane.StaticPane)9 Material (org.bukkit.Material)7 Player (org.bukkit.entity.Player)7 YamlConfiguration (org.bukkit.configuration.file.YamlConfiguration)5 HumanEntity (org.bukkit.entity.HumanEntity)5 NotNull (org.jetbrains.annotations.NotNull)5 Main (com.gmail.stefvanschiedev.buildinggame.Main)4 MessageManager (com.gmail.stefvanschiedev.buildinggame.managers.messages.MessageManager)4 ChatColor (org.bukkit.ChatColor)4 Pane (com.github.stefvanschie.inventoryframework.pane.Pane)3 Priority (com.github.stefvanschie.inventoryframework.pane.Pane.Priority)3 SettingsManager (com.gmail.stefvanschiedev.buildinggame.managers.files.SettingsManager)3 MessageService (dte.employme.messages.service.MessageService)3 IOException (java.io.IOException)3 List (java.util.List)3