Search in sources :

Example 56 with ItemBuilder

use of com.bencodez.advancedcore.api.item.ItemBuilder in project VotingPlugin by Ben12345rocks.

the class VoteLast method onChest.

@Override
public void onChest(Player player) {
    BInventory inv = new BInventory(plugin.getGui().getChestVoteLastName());
    inv.addPlaceholder("player", user.getPlayerName());
    for (VoteSite site : plugin.getVoteSites()) {
        if (!site.isHidden()) {
            inv.addButton(inv.getNextSlot(), new UpdatingBInventoryButton(site.getItem().setName(site.getDisplayName()).setLore(user.voteCommandLastGUILine(site)).setAmountNone(1), 1000, 1000) {

                @Override
                public void onClick(ClickEvent clickEvent) {
                }

                @Override
                public ItemBuilder onUpdate(Player p) {
                    return site.getItem().setName(site.getDisplayName()).setLore(user.voteCommandLastGUILine(site)).setAmountNone(1);
                }
            });
        }
    }
    if (plugin.getGui().getChestVoteLastBackButton()) {
        inv.addButton(plugin.getCommandLoader().getBackButton(user));
    }
    inv.openInventory(player);
}
Also used : VoteSite(com.bencodez.votingplugin.objects.VoteSite) UpdatingBInventoryButton(com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton) Player(org.bukkit.entity.Player) ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) BInventory(com.bencodez.advancedcore.api.inventory.BInventory)

Example 57 with ItemBuilder

use of com.bencodez.advancedcore.api.item.ItemBuilder in project VotingPlugin by Ben12345rocks.

the class VoteNext method onChest.

@Override
public void onChest(Player player) {
    BInventory inv = new BInventory(plugin.getGui().getChestVoteNextName());
    inv.addPlaceholder("player", user.getPlayerName());
    for (VoteSite site : plugin.getVoteSites()) {
        if (!site.isHidden()) {
            inv.addButton(inv.getNextSlot(), new UpdatingBInventoryButton(site.getItem().setName(site.getDisplayName()).setLore(user.voteCommandNextInfo(site)).setAmountNone(1), 1000, 1000) {

                @Override
                public void onClick(ClickEvent clickEvent) {
                }

                @Override
                public ItemBuilder onUpdate(Player player) {
                    return site.getItem().setName(site.getDisplayName()).setLore(user.voteCommandNextInfo(site)).setAmountNone(1).addPlaceholder("player", user.getPlayerName());
                }
            });
        }
    }
    if (plugin.getGui().getChestVoteNextBackButton()) {
        inv.addButton(plugin.getCommandLoader().getBackButton(user));
    }
    inv.openInventory(player);
}
Also used : VoteSite(com.bencodez.votingplugin.objects.VoteSite) UpdatingBInventoryButton(com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton) Player(org.bukkit.entity.Player) ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) BInventory(com.bencodez.advancedcore.api.inventory.BInventory)

Example 58 with ItemBuilder

use of com.bencodez.advancedcore.api.item.ItemBuilder 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);
                plugin.getRewardHandler().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 59 with ItemBuilder

use of com.bencodez.advancedcore.api.item.ItemBuilder 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 60 with ItemBuilder

use of com.bencodez.advancedcore.api.item.ItemBuilder 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

ItemBuilder (com.bencodez.advancedcore.api.item.ItemBuilder)71 ClickEvent (com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent)64 BInventoryButton (com.bencodez.advancedcore.api.inventory.BInventoryButton)57 EditGUI (com.bencodez.advancedcore.api.inventory.editgui.EditGUI)32 Player (org.bukkit.entity.Player)32 EditGUIValueInventory (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueInventory)30 BInventory (com.bencodez.advancedcore.api.inventory.BInventory)28 RewardEditData (com.bencodez.advancedcore.api.rewards.RewardEditData)28 EditGUIButton (com.bencodez.advancedcore.api.inventory.editgui.EditGUIButton)13 ArrayList (java.util.ArrayList)13 UpdatingBInventoryButton (com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton)11 EditGUIValueString (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString)11 ValueRequestBuilder (com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder)11 StringListener (com.bencodez.advancedcore.api.valuerequest.listeners.StringListener)9 EditGUIValueList (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueList)7 VoteSite (com.bencodez.votingplugin.objects.VoteSite)7 EditGUIValueNumber (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueNumber)6 Reward (com.bencodez.advancedcore.api.rewards.Reward)6 AdvancedCoreUser (com.bencodez.advancedcore.api.user.AdvancedCoreUser)6 ValueRequest (com.bencodez.advancedcore.api.valuerequest.ValueRequest)6