Search in sources :

Example 56 with BInventoryButton

use of com.bencodez.advancedcore.api.inventory.BInventoryButton in project VotingPlugin by Ben12345rocks.

the class VoteToday method onChest.

@Override
public void onChest(Player player) {
    BInventory inv = new BInventory(plugin.getGui().getChestVoteTodayName());
    if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
        inv.dontClose();
    }
    for (TopVoterPlayer user : plugin.getVoteToday().keySet()) {
        for (VoteSite voteSite : plugin.getVoteToday().get(user).keySet()) {
            DateTimeFormatter formatter = DateTimeFormatter.ofPattern(plugin.getConfigFile().getFormatTimeFormat());
            String timeString = plugin.getVoteToday().get(user).get(voteSite).format(formatter);
            String msg = plugin.getGui().getChestVoteTodayLine();
            HashMap<String, String> placeholders = new HashMap<String, String>();
            placeholders.put("VoteSite", voteSite.getDisplayName());
            placeholders.put("Time", timeString);
            msg = StringParser.getInstance().replacePlaceHolder(msg, placeholders);
            ItemBuilder item = null;
            if (plugin.getGui().isChestVoteTodayUseSkull() && !NMSManager.getInstance().isVersion("1.12")) {
                item = new ItemBuilder(user.getPlayerHead());
            } else {
                item = new ItemBuilder(plugin.getGui().getChestVoteTodayPlayerItem());
            }
            item.setName(StringParser.getInstance().replacePlaceHolder(plugin.getGui().getChestVoteTodayIconTitle(), "player", user.getPlayerName()));
            item.setLore(msg);
            final UUID uuid = user.getUuid();
            inv.addButton(inv.getNextSlot(), new BInventoryButton(item) {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(uuid);
                    new VoteGUI(plugin, player, user).open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
                }
            });
        }
    }
    if (plugin.getGui().getChestVoteTodayBackButton()) {
        inv.addButton(plugin.getCommandLoader().getBackButton(user));
    }
    inv.openInventory(player);
}
Also used : HashMap(java.util.HashMap) BInventoryButton(com.bencodez.advancedcore.api.inventory.BInventoryButton) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) TopVoterPlayer(com.bencodez.votingplugin.topvoter.TopVoterPlayer) BInventory(com.bencodez.advancedcore.api.inventory.BInventory) VoteSite(com.bencodez.votingplugin.objects.VoteSite) ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) UUID(java.util.UUID) DateTimeFormatter(java.time.format.DateTimeFormatter) VotingPluginUser(com.bencodez.votingplugin.user.VotingPluginUser)

Example 57 with BInventoryButton

use of com.bencodez.advancedcore.api.inventory.BInventoryButton in project VotingPlugin by Ben12345rocks.

the class CommandLoader method getBackButton.

public BInventoryButton getBackButton(VotingPluginUser user) {
    ConfigurationSection sec = plugin.getGui().getCHESTBackButton();
    boolean a = false;
    ItemBuilder item;
    if (sec != null) {
        item = new ItemBuilder(sec);
        a = sec.getBoolean("OpenVoteURL", false);
    } else {
        item = new ItemBuilder(Material.BARRIER, 1).setName("&8Back to VoteGUI");
    }
    final boolean openVoteURL = a;
    BInventoryButton b = new BInventoryButton(item) {

        @Override
        public void onClick(ClickEvent event) {
            if (!openVoteURL) {
                new VoteGUI(plugin, event.getWhoClicked(), user).open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
            } else {
                new VoteURL(plugin, event.getWhoClicked(), user, true).open();
            }
        }
    };
    // set item to end of the GUI
    if (sec != null && sec.getBoolean("EndOfGUI")) {
        b.setSlot(-2);
    }
    if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
        b.dontClose();
    }
    return b;
}
Also used : ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) VoteGUI(com.bencodez.votingplugin.commands.gui.player.VoteGUI) VoteURL(com.bencodez.votingplugin.commands.gui.player.VoteURL) BInventoryButton(com.bencodez.advancedcore.api.inventory.BInventoryButton) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) ConfigurationSection(org.bukkit.configuration.ConfigurationSection)

Example 58 with BInventoryButton

use of com.bencodez.advancedcore.api.inventory.BInventoryButton in project VotingPlugin by Ben12345rocks.

the class AdminGUI method openAdminGUIVoteSites.

/**
 * Open admin GUI vote sites.
 *
 * @param player the player
 */
public void openAdminGUIVoteSites(Player player) {
    BInventory inv = new BInventory("VoteSites");
    int count = 0;
    for (VoteSite voteSite : plugin.getVoteSites()) {
        ArrayList<String> lore = new ArrayList<String>();
        lore.add("Priority: " + voteSite.getPriority());
        lore.add("Name: " + voteSite.getDisplayName());
        lore.add("ServiceSite: " + voteSite.getServiceSite());
        lore.add("VoteURL: " + voteSite.getVoteURL());
        lore.add("VoteDelay: " + voteSite.getVoteDelay());
        lore.add("VoteDelayMin: " + voteSite.getVoteDelayMin());
        inv.addButton(count, new BInventoryButton(voteSite.getKey(), ArrayUtils.getInstance().convert(lore), new ItemStack(Material.STONE)) {

            @Override
            public void onClick(ClickEvent event) {
                Player player = event.getWhoClicked();
                openAdminGUIVoteSiteSite(player, voteSite);
            }
        });
        count++;
    }
    inv.openInventory(player);
}
Also used : VoteSite(com.bencodez.votingplugin.objects.VoteSite) Player(org.bukkit.entity.Player) BInventoryButton(com.bencodez.advancedcore.api.inventory.BInventoryButton) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) ArrayList(java.util.ArrayList) BInventory(com.bencodez.advancedcore.api.inventory.BInventory) EditGUIValueString(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString) ItemStack(org.bukkit.inventory.ItemStack)

Example 59 with BInventoryButton

use of com.bencodez.advancedcore.api.inventory.BInventoryButton in project VotingPlugin by Ben12345rocks.

the class AdminGUI method adminGUIButtons.

/**
 * Open admin GUI.
 *
 * @return ArrayList of buttons
 */
public ArrayList<BInventoryButton> adminGUIButtons() {
    ArrayList<BInventoryButton> buttons = new ArrayList<BInventoryButton>();
    buttons.add(new BInventoryButton("&cVoteSites", new String[] { "&cOnly enabled sites are listed in this section", "&cMiddle Click to create" }, new ItemStack(Material.STONE)) {

        @Override
        public void onClick(ClickEvent event) {
            Player player = event.getPlayer();
            if (event.getClick().equals(ClickType.MIDDLE)) {
                new ValueRequest().requestString(player, new StringListener() {

                    @Override
                    public void onInput(Player player, String value) {
                        plugin.getConfigVoteSites().generateVoteSite(value);
                        player.sendMessage("Generated site");
                        plugin.reload();
                    }
                });
            } else {
                openAdminGUIVoteSites(player);
            }
        }
    });
    buttons.add(new BInventoryButton(new ItemBuilder(Material.CHEST, 1).setName("&cEdit VoteShop")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            new AdminVoteVoteShop(plugin, clickEvent.getPlayer()).open(GUIMethod.CHEST);
        }
    });
    buttons.add(new BInventoryButton(new ItemBuilder(Material.DIAMOND_BLOCK, 1).setName("&cEdit Milestones")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            new AdminVoteMilestones(plugin, clickEvent.getPlayer()).open(GUIMethod.CHEST);
        }
    });
    buttons.add(new BInventoryButton(new ItemBuilder(Material.COBBLESTONE, 1).setName("&cEdit Cumulative")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            new AdminVoteCumulative(plugin, clickEvent.getPlayer()).open(GUIMethod.CHEST);
        }
    });
    buttons.add(new BInventoryButton(new ItemBuilder(Material.STONE, 1).setName("&cEdit VoteParty")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            new AdminVoteVoteParty(plugin, clickEvent.getPlayer()).open(GUIMethod.CHEST);
        }
    });
    buttons.add(new BInventoryButton(new ItemBuilder(Material.STONE, 1).setName("&cEdit FirstVote reward")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(), plugin.getRewardHandler().getDirectlyDefined("FirstVote"));
        }
    });
    buttons.add(new BInventoryButton(new ItemBuilder(Material.STONE, 1).setName("&cEdit FirstVoteToday reward")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(), plugin.getRewardHandler().getDirectlyDefined("FirstVoteToday"));
        }
    });
    buttons.add(new BInventoryButton(new ItemBuilder(Material.STONE, 1).setName("&cEdit AllSites reward")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(), plugin.getRewardHandler().getDirectlyDefined("AllSites"));
        }
    });
    buttons.add(new BInventoryButton(new ItemBuilder(Material.STONE, 1).setName("&cEdit AnySiteRewards")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(), plugin.getRewardHandler().getDirectlyDefined("AnySiteRewards"));
        }
    });
    buttons.add(new BInventoryButton(new ItemBuilder(Material.STONE, 1).setName("&cEdit EverySiteReward")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(), plugin.getRewardHandler().getDirectlyDefined("EverySiteReward"));
        }
    });
    buttons.add(new BInventoryButton(new ItemBuilder(Material.STONE, 1).setName("&cEdit BungeeVotePartyRewards")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(), plugin.getRewardHandler().getDirectlyDefined("BungeeVotePartyRewards"));
        }
    });
    buttons.add(new BInventoryButton(new ItemBuilder("GRASS_BLOCK").setName("&cEdit BungeeSettings.yml")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            new AdminVoteBungeeSettings(plugin, clickEvent.getPlayer()).open();
        }
    });
    buttons.add(new BInventoryButton("&cReload Plugin", new String[] {}, new ItemStack(Material.BUCKET, 1)) {

        @Override
        public void onClick(ClickEvent event) {
            plugin.reload();
        }
    });
    return buttons;
}
Also used : Player(org.bukkit.entity.Player) AdminVoteCumulative(com.bencodez.votingplugin.commands.gui.admin.cumulative.AdminVoteCumulative) BInventoryButton(com.bencodez.advancedcore.api.inventory.BInventoryButton) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) ArrayList(java.util.ArrayList) EditGUIValueString(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString) ValueRequest(com.bencodez.advancedcore.api.valuerequest.ValueRequest) AdminVoteVoteParty(com.bencodez.votingplugin.commands.gui.admin.AdminVoteVoteParty) ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) AdminVoteVoteShop(com.bencodez.votingplugin.commands.gui.admin.voteshop.AdminVoteVoteShop) AdminVoteMilestones(com.bencodez.votingplugin.commands.gui.admin.milestones.AdminVoteMilestones) AdminVoteBungeeSettings(com.bencodez.votingplugin.commands.gui.admin.AdminVoteBungeeSettings) StringListener(com.bencodez.advancedcore.api.valuerequest.listeners.StringListener) ItemStack(org.bukkit.inventory.ItemStack)

Example 60 with BInventoryButton

use of com.bencodez.advancedcore.api.inventory.BInventoryButton in project VotingPlugin by Ben12345rocks.

the class AdminVoteConfirmation method onChest.

@Override
public void onChest(Player player) {
    BInventory inv = new BInventory(title);
    inv.addButton(new BInventoryButton(new ItemBuilder(Material.EMERALD_BLOCK).setName("&aConfirm")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            onConfirm(clickEvent.getPlayer());
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder(Material.REDSTONE_BLOCK).setName("&aCancel")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            onDeny(clickEvent.getPlayer());
        }
    });
    inv.openInventory(player);
}
Also used : ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) BInventoryButton(com.bencodez.advancedcore.api.inventory.BInventoryButton) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) BInventory(com.bencodez.advancedcore.api.inventory.BInventory)

Aggregations

BInventoryButton (com.bencodez.advancedcore.api.inventory.BInventoryButton)66 ClickEvent (com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent)65 ItemBuilder (com.bencodez.advancedcore.api.item.ItemBuilder)57 EditGUI (com.bencodez.advancedcore.api.inventory.editgui.EditGUI)33 Player (org.bukkit.entity.Player)32 BInventory (com.bencodez.advancedcore.api.inventory.BInventory)31 RewardEditData (com.bencodez.advancedcore.api.rewards.RewardEditData)29 EditGUIValueInventory (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueInventory)26 ArrayList (java.util.ArrayList)15 ValueRequestBuilder (com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder)11 EditGUIValueString (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString)10 StringListener (com.bencodez.advancedcore.api.valuerequest.listeners.StringListener)10 ItemStack (org.bukkit.inventory.ItemStack)10 ValueRequest (com.bencodez.advancedcore.api.valuerequest.ValueRequest)9 EditGUIButton (com.bencodez.advancedcore.api.inventory.editgui.EditGUIButton)8 UpdatingBInventoryButton (com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton)7 Reward (com.bencodez.advancedcore.api.rewards.Reward)7 AdvancedCoreUser (com.bencodez.advancedcore.api.user.AdvancedCoreUser)7 VoteSite (com.bencodez.votingplugin.objects.VoteSite)7 NumberListener (com.bencodez.advancedcore.api.valuerequest.listeners.NumberListener)5