Search in sources :

Example 26 with ClickEvent

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

the class VoteStreak method onChest.

@Override
public void onChest(Player player) {
    BInventory inv = new BInventory(plugin.getGui().getChestVoteStreakName());
    inv.addPlaceholder("player", user.getPlayerName());
    inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteStreakCurrentDayStreakItem()).addPlaceholder("Streak", "" + user.getDayVoteStreak())) {

        @Override
        public void onClick(ClickEvent clickEvent) {
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteStreakCurrentWeekStreakItem()).addPlaceholder("Streak", "" + user.getWeekVoteStreak())) {

        @Override
        public void onClick(ClickEvent clickEvent) {
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteStreakCurrentMonthStreakItem()).addPlaceholder("Streak", "" + user.getMonthVoteStreak())) {

        @Override
        public void onClick(ClickEvent clickEvent) {
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteStreakHighestDayStreakItem()).addPlaceholder("Streak", "" + user.getBestDayVoteStreak())) {

        @Override
        public void onClick(ClickEvent clickEvent) {
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteStreakHighestWeekStreakItem()).addPlaceholder("Streak", "" + user.getBestWeekVoteStreak())) {

        @Override
        public void onClick(ClickEvent clickEvent) {
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteStreakHighestMonthStreakItem()).addPlaceholder("Streak", "" + user.getBestMonthVoteStreak())) {

        @Override
        public void onClick(ClickEvent clickEvent) {
        }
    });
    if (plugin.getGui().getChestVoteStreakBackButton()) {
        inv.addButton(plugin.getCommandLoader().getBackButton(user));
    }
    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)

Example 27 with ClickEvent

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

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

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

ClickEvent (com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent)29 ItemBuilder (com.bencodez.advancedcore.api.item.ItemBuilder)26 BInventoryButton (com.bencodez.advancedcore.api.inventory.BInventoryButton)25 BInventory (com.bencodez.advancedcore.api.inventory.BInventory)23 Player (org.bukkit.entity.Player)19 VoteSite (com.bencodez.votingplugin.objects.VoteSite)9 ArrayList (java.util.ArrayList)8 UpdatingBInventoryButton (com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton)6 EditGUIValueString (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString)5 ValueRequest (com.bencodez.advancedcore.api.valuerequest.ValueRequest)5 VotingPluginUser (com.bencodez.votingplugin.user.VotingPluginUser)5 EditGUI (com.bencodez.advancedcore.api.inventory.editgui.EditGUI)4 ValueRequestBuilder (com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder)4 StringListener (com.bencodez.advancedcore.api.valuerequest.listeners.StringListener)4 EditGUIButton (com.bencodez.advancedcore.api.inventory.editgui.EditGUIButton)3 EditGUIValueList (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueList)3 EditGUIValueNumber (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueNumber)3 RewardOptions (com.bencodez.advancedcore.api.rewards.RewardOptions)3 NumberListener (com.bencodez.advancedcore.api.valuerequest.listeners.NumberListener)3 RewardEditGUI (com.bencodez.advancedcore.command.gui.RewardEditGUI)3