Search in sources :

Example 11 with BInventoryButton

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

the class VoteBest method onChest.

@Override
public void onChest(Player player) {
    BInventory inv = new BInventory(plugin.getGui().getChestVoteBestName());
    inv.addPlaceholder("player", user.getPlayerName());
    inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteBestDayBestItem()).addPlaceholder("Best", "" + user.getBestDayVoteStreak())) {

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

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

        @Override
        public void onClick(ClickEvent clickEvent) {
        }
    });
    if (plugin.getGui().isChestVoteBestBackButton()) {
        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 12 with BInventoryButton

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

the class VoteURLVoteSite method onChest.

@Override
public void onChest(Player player) {
    if (!plugin.isVoteSite(voteSite)) {
        player.sendMessage("Not a valid votesite");
        return;
    }
    VoteSite site = plugin.getVoteSite(voteSite, true);
    BInventory inv = new BInventory(plugin.getGui().getChestVoteURLSiteName());
    inv.addPlaceholder("site", site.getDisplayName());
    inv.setMeta(player, "VoteSite", site);
    if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
        inv.dontClose();
    }
    inv.addButton(new BInventoryButton(new ItemBuilder(Material.BOW).setName("&4URL").addLoreLine("Click to see URL")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            VoteSite site = (VoteSite) clickEvent.getMeta("VoteSite");
            clickEvent.getWhoClicked().sendMessage(site.getVoteURL());
        }
    });
    inv.addButton(new UpdatingBInventoryButton(new ItemBuilder(Material.COMPASS).setName("&4Next Vote").addLoreLine(user.voteCommandNextInfo(site)), 1000, 1000) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            new VoteURL(plugin, clickEvent.getPlayer(), user, true).open();
        }

        @Override
        public ItemBuilder onUpdate(Player arg0) {
            return new ItemBuilder(Material.COMPASS).setName("&4Next Vote").addLoreLine(user.voteCommandNextInfo(site));
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder(Material.CLOCK).setName("&4Last Vote").addLoreLine(user.voteCommandLastLine(site))) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            new VoteURL(plugin, clickEvent.getPlayer(), user, true).open();
        }
    });
    if (plugin.getGui().getChestVoteURLBackButton()) {
        inv.addButton(plugin.getCommandLoader().getBackButton(user));
    }
    inv.openInventory(player);
}
Also used : VoteSite(com.bencodez.votingplugin.objects.VoteSite) UpdatingBInventoryButton(com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton) ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) Player(org.bukkit.entity.Player) BInventoryButton(com.bencodez.advancedcore.api.inventory.BInventoryButton) UpdatingBInventoryButton(com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) BInventory(com.bencodez.advancedcore.api.inventory.BInventory)

Example 13 with BInventoryButton

use of com.bencodez.advancedcore.api.inventory.BInventoryButton in project AdvancedCore by BenCodez.

the class AdminGUI method openGUI.

/**
 * Open GUI.
 *
 * @param player the player
 */
public void openGUI(Player player) {
    if (!player.hasPermission(AdvancedCorePlugin.getInstance().getOptions().getPermPrefix() + ".Admin")) {
        player.sendMessage("Not enough permissions");
        return;
    }
    BInventory inv = new BInventory("AdminGUI");
    inv.addButton(inv.getNextSlot(), new BInventoryButton("&cRewards", new String[] { "&cMiddle click to create" }, new ItemStack(Material.DIAMOND)) {

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

                    @Override
                    public void onInput(Player player, String value) {
                        Reward reward = plugin.getRewardHandler().getReward(value);
                        player.sendMessage("Reward file created");
                        plugin.reloadAdvancedCore(false);
                        RewardEditGUI.getInstance().openRewardGUI(player, reward);
                    }
                });
            } else {
                RewardEditGUI.getInstance().openRewardsGUI(player);
            }
        }
    });
    inv.addButton(inv.getNextSlot(), new BInventoryButton(new ItemBuilder("PLAYER_HEAD").setName("&cUsers")) {

        @Override
        public void onClick(ClickEvent event) {
            Player player = event.getWhoClicked();
            UserGUI.getInstance().openUsersGUI(player);
        }
    });
    if (pluginGUIs != null) {
        for (BInventoryButton b : pluginGUIs) {
            inv.addButton(inv.getNextSlot(), b);
        }
    }
    inv.openInventory(player);
}
Also used : Player(org.bukkit.entity.Player) 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) ValueRequest(com.bencodez.advancedcore.api.valuerequest.ValueRequest) StringListener(com.bencodez.advancedcore.api.valuerequest.listeners.StringListener) Reward(com.bencodez.advancedcore.api.rewards.Reward) ItemStack(org.bukkit.inventory.ItemStack)

Example 14 with BInventoryButton

use of com.bencodez.advancedcore.api.inventory.BInventoryButton in project AdvancedCore by BenCodez.

the class ChoiceGUI method openPreferenceReward.

public void openPreferenceReward(Player player, String rewardName) {
    Reward reward = plugin.getRewardHandler().getReward(rewardName);
    if (!reward.getConfig().getEnableChoices()) {
        player.sendMessage("Choice rewards not enabled");
        return;
    }
    AdvancedCoreUser user = plugin.getUserManager().getUser(player);
    BInventory inv = new BInventory("Select Preference");
    for (String choice : reward.getConfig().getChoices()) {
        ItemBuilder builder = new ItemBuilder(reward.getConfig().getChoicesItem(choice));
        if (user.getChoicePreference(rewardName).equalsIgnoreCase(choice)) {
            builder.addLoreLine("&cCurrent preference");
            builder.addLoreLine("&c&lClick to remove");
        } else {
            builder.addLoreLine("&aClick to set as preference");
        }
        builder.setName("&a" + choice);
        inv.addButton(new BInventoryButton(builder) {

            @Override
            public void onClick(ClickEvent clickEvent) {
                AdvancedCoreUser user = (AdvancedCoreUser) getInv().getData("User");
                String rewardName = (String) getInv().getData("Reward");
                String choice = (String) getData("Choice");
                if (user.getChoicePreference(rewardName).equals(choice)) {
                    choice = "none";
                }
                user.setChoicePreference(rewardName, choice);
                user.sendMessage(plugin.getOptions().getFormatChoiceRewardsPreferenceSet(), "choice", choice);
            }
        }.addData("Choice", choice));
    }
    inv.addData("User", user);
    inv.addData("Reward", rewardName);
    inv.openInventory(player);
}
Also used : AdvancedCoreUser(com.bencodez.advancedcore.api.user.AdvancedCoreUser) ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) BInventoryButton(com.bencodez.advancedcore.api.inventory.BInventoryButton) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) Reward(com.bencodez.advancedcore.api.rewards.Reward) BInventory(com.bencodez.advancedcore.api.inventory.BInventory)

Example 15 with BInventoryButton

use of com.bencodez.advancedcore.api.inventory.BInventoryButton in project AdvancedCore by BenCodez.

the class ChoiceGUI method openClaimChoices.

public void openClaimChoices(Player player, Reward reward) {
    if (!reward.getConfig().getEnableChoices()) {
        player.sendMessage("Choice rewards not enabled");
        return;
    }
    AdvancedCoreUser user = plugin.getUserManager().getUser(player);
    BInventory inv = new BInventory("Pick reward");
    inv.dontClose();
    for (String choice : reward.getConfig().getChoices()) {
        ItemBuilder builder = new ItemBuilder(reward.getConfig().getChoicesItem(choice)).setNameIfNotExist("&a" + choice);
        inv.addButton(new BInventoryButton(builder) {

            @Override
            public void onClick(ClickEvent clickEvent) {
                Reward reward = (Reward) getInv().getData("Reward");
                AdvancedCoreUser user = (AdvancedCoreUser) getInv().getData("User");
                String choice = (String) getData("Choice");
                user.removeUnClaimedChoiceReward(reward.getName());
                plugin.getRewardHandler().giveChoicesReward(reward, user, choice);
                if (user.getUnClaimedChoices().size() > 0) {
                    openClaimChoices(clickEvent.getPlayer());
                } else {
                    Bukkit.getScheduler().runTask(plugin, new Runnable() {

                        @Override
                        public void run() {
                            clickEvent.getPlayer().closeInventory();
                        }
                    });
                }
            }
        }.addData("Choice", choice));
    }
    inv.addData("User", user);
    inv.addData("Reward", reward);
    inv.openInventory(player);
}
Also used : AdvancedCoreUser(com.bencodez.advancedcore.api.user.AdvancedCoreUser) 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) Reward(com.bencodez.advancedcore.api.rewards.Reward)

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