Search in sources :

Example 21 with BInventory

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

the class VoteTotal method onChest.

@Override
public void onChest(Player player) {
    BInventory inv = new BInventory(plugin.getGui().getChestVoteTotalName());
    inv.addPlaceholder("player", user.getPlayerName());
    for (final TopVoter top : TopVoter.values()) {
        inv.addButton(new UpdatingBInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteTotalItem(top)).addPlaceholder("Total", "" + user.getTotal(top)).addPlaceholder("topvoter", top.getName()), 1000, 1000) {

            @Override
            public void onClick(ClickEvent clickEvent) {
            }

            @Override
            public ItemBuilder onUpdate(Player arg0) {
                return new ItemBuilder(plugin.getGui().getChestVoteTotalItem(top)).addPlaceholder("Total", "" + user.getTotal(top)).addPlaceholder("topvoter", top.getName()).addPlaceholder("player", user.getPlayerName());
            }
        });
    }
    if (plugin.getGui().getChestVoteTotalBackButton()) {
        inv.addButton(plugin.getCommandLoader().getBackButton(user));
    }
    inv.openInventory(player);
}
Also used : UpdatingBInventoryButton(com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton) ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) Player(org.bukkit.entity.Player) TopVoter(com.bencodez.votingplugin.topvoter.TopVoter) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) BInventory(com.bencodez.advancedcore.api.inventory.BInventory)

Example 22 with BInventory

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

the class VoteShopConfirm method onChest.

@Override
public void onChest(Player player) {
    PlayerUtils.getInstance().setPlayerMeta(player, "ident", identifier);
    BInventory inv = new BInventory(plugin.getGui().getChestShopConfirmPurchaseTitle());
    inv.dontClose();
    inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestShopConfirmPurchaseYesItem())) {

        @Override
        public void onClick(ClickEvent event) {
            user.clearCache();
            int points = plugin.getGui().getChestShopIdentifierCost(identifier);
            int limit = plugin.getGui().getChestShopIdentifierLimit(identifier);
            HashMap<String, String> placeholders = new HashMap<String, String>();
            placeholders.put("identifier", identifier);
            placeholders.put("points", "" + points);
            placeholders.put("limit", "" + limit);
            if (user.removePoints(points)) {
                plugin.getLogger().info("VoteShop: " + user.getPlayerName() + "/" + user.getUUID() + " bought " + identifier + " for " + points);
                RewardHandler.getInstance().giveReward(user, plugin.getGui().getData(), plugin.getGui().getChestShopIdentifierRewardsPath(identifier), new RewardOptions().setPlaceholders(placeholders));
                user.sendMessage(StringParser.getInstance().replacePlaceHolder(plugin.getGui().getCHESTVoteShopPurchase(identifier), placeholders));
                if (limit > 0) {
                    user.setVoteShopIdentifierLimit(identifier, user.getVoteShopIdentifierLimit(identifier) + 1);
                }
            } else {
                user.sendMessage(StringParser.getInstance().replacePlaceHolder(plugin.getConfigFile().getFormatShopFailedMsg(), placeholders));
            }
            if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
                event.getButton().getInv().closeInv(player, null);
            } else {
                new VoteShop(plugin, event.getPlayer(), user).open();
            }
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestShopConfirmPurchaseNoItem())) {

        @Override
        public void onClick(ClickEvent event) {
            if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
                event.getButton().getInv().closeInv(player, null);
            } else {
                new VoteShop(plugin, event.getPlayer(), user).open();
            }
        }
    });
    inv.openInventory(player);
}
Also used : RewardOptions(com.bencodez.advancedcore.api.rewards.RewardOptions) ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) HashMap(java.util.HashMap) BInventoryButton(com.bencodez.advancedcore.api.inventory.BInventoryButton) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) BInventory(com.bencodez.advancedcore.api.inventory.BInventory)

Example 23 with BInventory

use of com.bencodez.advancedcore.api.inventory.BInventory 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)

Aggregations

BInventory (com.bencodez.advancedcore.api.inventory.BInventory)23 ClickEvent (com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent)23 ItemBuilder (com.bencodez.advancedcore.api.item.ItemBuilder)21 BInventoryButton (com.bencodez.advancedcore.api.inventory.BInventoryButton)19 Player (org.bukkit.entity.Player)15 VoteSite (com.bencodez.votingplugin.objects.VoteSite)7 UpdatingBInventoryButton (com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton)6 VotingPluginUser (com.bencodez.votingplugin.user.VotingPluginUser)5 ValueRequest (com.bencodez.advancedcore.api.valuerequest.ValueRequest)4 ArrayList (java.util.ArrayList)4 RewardOptions (com.bencodez.advancedcore.api.rewards.RewardOptions)3 AdminVoteConfirmation (com.bencodez.votingplugin.commands.gui.admin.AdminVoteConfirmation)3 TopVoterPlayer (com.bencodez.votingplugin.topvoter.TopVoterPlayer)3 HashMap (java.util.HashMap)3 ValueRequestBuilder (com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder)2 NumberListener (com.bencodez.advancedcore.api.valuerequest.listeners.NumberListener)2 StringListener (com.bencodez.advancedcore.api.valuerequest.listeners.StringListener)2 TopVoter (com.bencodez.votingplugin.topvoter.TopVoter)2 Entry (java.util.Map.Entry)2 ItemStack (org.bukkit.inventory.ItemStack)2