Search in sources :

Example 11 with ItemBuilder

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

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

the class VoteGUI method onChest.

@Override
public void onChest(Player player) {
    if (this.user == null) {
        user = UserManager.getInstance().getVotingPluginUser(player);
    }
    BInventory inv = new BInventory(plugin.getGui().getChestVoteGUIName());
    if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
        inv.dontClose();
    }
    if (player.getUniqueId().toString().equals(user.getUUID())) {
        inv.requirePermission("VotingPlugin.Commands.Vote.GUI");
    } else {
        inv.requirePermission("VotingPlugin.Commands.Vote.GUI.Other");
    }
    inv.addPlaceholder("points", "" + user.getPoints());
    inv.addPlaceholder("player", user.getPlayerName());
    inv.addPlaceholder("top", plugin.getConfigFile().getVoteTopDefault());
    for (String slot : plugin.getGui().getChestVoteGUISlots()) {
        ItemBuilder builder = getItemSlot(slot, player);
        inv.addButton(new UpdatingBInventoryButton(builder, 1000, 1000) {

            @Override
            public void onClick(ClickEvent event) {
                Player player = event.getWhoClicked();
                String cmd = plugin.getGui().getChestVoteGUISlotCommand(slot);
                if (cmd.equalsIgnoreCase("none")) {
                    return;
                } else if (!cmd.equals("")) {
                    event.runSync(new Runnable() {

                        @Override
                        public void run() {
                            player.performCommand(cmd);
                        }
                    });
                } else {
                    if (slot.equalsIgnoreCase("url")) {
                        new VoteURL(plugin, player, user, true).open();
                    } else if (slot.equalsIgnoreCase("next")) {
                        new VoteNext(plugin, player, user).open(GUIMethod.CHEST);
                    } else if (slot.equalsIgnoreCase("last")) {
                        new VoteLast(plugin, player, user).open(GUIMethod.CHEST);
                    } else if (slot.equalsIgnoreCase("total")) {
                        new VoteTotal(plugin, player, user).open(GUIMethod.CHEST);
                    } else if (slot.equalsIgnoreCase("top")) {
                        new VoteTopVoter(plugin, player, user, TopVoter.getDefault(), 1).open(GUIMethod.CHEST);
                    } else if (slot.equalsIgnoreCase("today")) {
                        new VoteToday(plugin, player, user, 1).open(GUIMethod.CHEST);
                    } else if (slot.equalsIgnoreCase("help")) {
                        player.performCommand("vote help");
                    } else if (slot.equalsIgnoreCase("shop")) {
                        new VoteShop(plugin, player, user).open(GUIMethod.CHEST);
                    } else if (slot.equalsIgnoreCase("lastmonth")) {
                        new VoteTopVoterLastMonth(plugin, player, user).open(GUIMethod.CHEST);
                    } else if (slot.equalsIgnoreCase("best")) {
                        new VoteBest(plugin, player, user).open(GUIMethod.CHEST);
                    } else if (slot.equalsIgnoreCase("streak")) {
                        new VoteStreak(plugin, player, user).open(GUIMethod.CHEST);
                    }
                }
                if (plugin.getRewardHandler().hasRewards(plugin.getGui().getData(), plugin.getGui().getChestVoteGUISlotRewardsPath(slot))) {
                    plugin.getRewardHandler().giveReward(UserManager.getInstance().getVotingPluginUser(player), plugin.getGui().getData(), plugin.getGui().getChestVoteGUISlotRewardsPath(slot), new RewardOptions().addPlaceholder("identifier", slot));
                }
            }

            @Override
            public ItemBuilder onUpdate(Player player) {
                ItemBuilder item = getItemSlot(slot, player);
                VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
                item.addPlaceholder("points", "" + user.getPoints());
                item.addPlaceholder("player", user.getPlayerName());
                item.addPlaceholder("top", plugin.getConfigFile().getVoteTopDefault());
                return item;
            }
        });
    }
    inv.openInventory(player);
}
Also used : UpdatingBInventoryButton(com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton) Player(org.bukkit.entity.Player) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) BInventory(com.bencodez.advancedcore.api.inventory.BInventory) RewardOptions(com.bencodez.advancedcore.api.rewards.RewardOptions) ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) VotingPluginUser(com.bencodez.votingplugin.user.VotingPluginUser)

Example 13 with ItemBuilder

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

the class VoteGUI method getItemSlot.

private ItemBuilder getItemSlot(String slot, Player player) {
    ItemBuilder builder = new ItemBuilder(plugin.getGui().getChestVoteGUISlotSection(slot));
    String[] lore = new String[1];
    lore = ArrayUtils.getInstance().convert(plugin.getGui().getChestVoteGUISlotLore(slot));
    String str = plugin.getConfigFile().getVoteTopDefault();
    if (lore.length == 0) {
        if (slot.equalsIgnoreCase("url")) {
            lore = new String[] { "&aClick me" };
        } else if (slot.equalsIgnoreCase("next")) {
            lore = ArrayUtils.getInstance().convert(new VoteNext(plugin, player, user).getChat(player));
        } else if (slot.equalsIgnoreCase("last")) {
            lore = ArrayUtils.getInstance().convert(new VoteLast(plugin, player, user).getChat(player));
        } else if (slot.equalsIgnoreCase("total")) {
            lore = ArrayUtils.getInstance().convert(new VoteTotal(plugin, player, user).getChat(player));
        } else if (slot.equalsIgnoreCase("top")) {
            if (str.equalsIgnoreCase("monthly")) {
                lore = plugin.getTopVoterHandler().topVoterMonthly(1);
            } else if (str.equalsIgnoreCase("weekly")) {
                lore = plugin.getTopVoterHandler().topVoterWeekly(1);
            } else if (str.equalsIgnoreCase("daily")) {
                lore = plugin.getTopVoterHandler().topVoterDaily(1);
            } else {
                lore = plugin.getTopVoterHandler().topVoterAllTime(1);
            }
        } else if (slot.equalsIgnoreCase("today")) {
            String[] today = new VoteToday(plugin, player, user, 1).voteTodayGUI();
            ArrayList<String> list = new ArrayList<String>();
            if (today.length > 0) {
                for (int i = today.length - 1; i < today.length && list.size() < 10 && i >= 0; i--) {
                    list.add(today[i]);
                }
            }
            lore = ArrayUtils.getInstance().convert(list);
        } else if (slot.equalsIgnoreCase("help")) {
            lore = new String[] { "Click to view help" };
        }
    }
    builder.setLore(ArrayUtils.getInstance().convert(lore));
    return builder;
}
Also used : ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) ArrayList(java.util.ArrayList)

Example 14 with ItemBuilder

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

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

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