Search in sources :

Example 1 with NumberListener

use of com.bencodez.advancedcore.api.valuerequest.listeners.NumberListener in project VotingPlugin by Ben12345rocks.

the class AdminVoteVoteParty method onChest.

@Override
public void onChest(Player player) {
    EditGUI inv = new EditGUI("Edit VoteParty");
    inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.VoteParty");
    // to add
    inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueBoolean("Enabled", plugin.getSpecialRewardsConfig().getVotePartyEnabled()) {

        @Override
        public void setValue(Player player, boolean name) {
            setPathData(getKey(), name);
        }
    }));
    inv.addButton(new EditGUIButton(new ItemBuilder(Material.EMERALD, 1), new EditGUIValueNumber("VotesRequired", plugin.getSpecialRewardsConfig().getVotePartyVotesRequired()) {

        @Override
        public void setValue(Player player, Number num) {
            setPathData(getKey(), num.intValue());
        }
    }));
    inv.addButton(new EditGUIButton(new ItemBuilder(Material.LADDER, 1), new EditGUIValueNumber("IncreaseVotesRquired", plugin.getSpecialRewardsConfig().getVotePartyIncreaseVotesRquired()) {

        @Override
        public void setValue(Player player, Number num) {
            setPathData(getKey(), num.intValue());
        }
    }));
    inv.addButton(new BInventoryButton(new ItemBuilder(Material.LADDER).setName("&cCurrent increase amount").addLoreLine("&cCurrent value: " + plugin.getServerData().getVotePartyExtraRequired())) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            new ValueRequestBuilder(new NumberListener() {

                @Override
                public void onInput(Player player, Number value) {
                    plugin.getServerData().setVotePartyExtraRequired(value.intValue());
                }
            }, new Number[] { 0, 10, 50, 100 }).currentValue("" + plugin.getServerData().getVotePartyExtraRequired()).allowCustomOption(true).request(clickEvent.getPlayer());
        }
    });
    inv.addButton(new EditGUIButton(new ItemBuilder(Material.EMERALD, 1), new EditGUIValueNumber("UserVotesRequired", plugin.getSpecialRewardsConfig().getVotePartyUserVotesRequired()) {

        @Override
        public void setValue(Player player, Number num) {
            setPathData(getKey(), num.intValue());
        }
    }));
    inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueBoolean("GiveAllPlayers", plugin.getSpecialRewardsConfig().getVotePartyGiveAllPlayers()) {

        @Override
        public void setValue(Player player, boolean name) {
            setPathData(getKey(), name);
        }
    }));
    inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueBoolean("GiveOnlinePlayersOnly", plugin.getSpecialRewardsConfig().isVotePartyGiveOnlinePlayersOnly()) {

        @Override
        public void setValue(Player player, boolean name) {
            setPathData(getKey(), name);
        }
    }));
    inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueBoolean("ResetEachDay", plugin.getSpecialRewardsConfig().getVotePartyResetEachDay()) {

        @Override
        public void setValue(Player player, boolean name) {
            setPathData(getKey(), name);
        }
    }));
    inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueBoolean("ResetWeekly", plugin.getSpecialRewardsConfig().getVotePartyResetWeekly()) {

        @Override
        public void setValue(Player player, boolean name) {
            setPathData(getKey(), name);
        }
    }));
    inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueBoolean("ResetMonthly", plugin.getSpecialRewardsConfig().getVotePartyResetMontly()) {

        @Override
        public void setValue(Player player, boolean name) {
            setPathData(getKey(), name);
        }
    }));
    inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueBoolean("OnlyOncePerDay", plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerDay()) {

        @Override
        public void setValue(Player player, boolean name) {
            setPathData(getKey(), name);
        }
    }));
    inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueBoolean("ResetExtraVotesMonthly", plugin.getSpecialRewardsConfig().isVotePartyResetExtraVotesMonthly()) {

        @Override
        public void setValue(Player player, boolean name) {
            setPathData(getKey(), name);
        }
    }));
    inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueBoolean("CountFakeVotes", plugin.getSpecialRewardsConfig().getVotePartyCountFakeVotes()) {

        @Override
        public void setValue(Player player, boolean name) {
            setPathData(getKey(), name);
        }
    }));
    inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueBoolean("CountOfflineVotes", plugin.getSpecialRewardsConfig().getVotePartyCountOfflineVotes()) {

        @Override
        public void setValue(Player player, boolean name) {
            setPathData(getKey(), name);
        }
    }));
    inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueString("Broadcast", plugin.getSpecialRewardsConfig().getVotePartyBroadcast()) {

        @Override
        public void setValue(Player player, String name) {
            setPathData(getKey(), name);
        }
    }));
    inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueList("Commands", plugin.getSpecialRewardsConfig().getVotePartyCommands()) {

        @Override
        public void setValue(Player player, ArrayList<String> value) {
            setPathData(getKey(), value);
        }
    }));
    inv.addButton(new BInventoryButton(new ItemBuilder(Material.DISPENSER, 1).setName("&cRewards").addLoreLine("&aUse this for per player rewards, also set online only rewards here as well").addLoreLine("&cTo set rewards to be given to players online only, set RewardType to ONLINE")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(), RewardHandler.getInstance().getDirectlyDefined("VoteParty.Rewards"));
        }
    });
    // implement item reward?
    inv.openInventory(player);
}
Also used : EditGUI(com.bencodez.advancedcore.api.inventory.editgui.EditGUI) RewardEditGUI(com.bencodez.advancedcore.command.gui.RewardEditGUI) EditGUIValueBoolean(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueBoolean) Player(org.bukkit.entity.Player) BInventoryButton(com.bencodez.advancedcore.api.inventory.BInventoryButton) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) ArrayList(java.util.ArrayList) EditGUIValueString(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString) EditGUIValueString(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString) ValueRequestBuilder(com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder) ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) NumberListener(com.bencodez.advancedcore.api.valuerequest.listeners.NumberListener) EditGUIValueList(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueList) EditGUIValueNumber(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueNumber) EditGUIButton(com.bencodez.advancedcore.api.inventory.editgui.EditGUIButton) EditGUIValueNumber(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueNumber)

Example 2 with NumberListener

use of com.bencodez.advancedcore.api.valuerequest.listeners.NumberListener in project VotingPlugin by Ben12345rocks.

the class AdminVoteCumulative method onChest.

@Override
public void onChest(Player player) {
    BInventory inv = new BInventory("Edit Cumulative");
    inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.Cumulative");
    inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&cEdit existing cumulative rewards")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            ArrayList<Integer> nums = new ArrayList<Integer>();
            for (String num : plugin.getSpecialRewardsConfig().getCumulativeVotes()) {
                if (StringParser.getInstance().isInt(num)) {
                    nums.add(Integer.parseInt(num));
                }
            }
            Number[] options = new Number[nums.size()];
            for (int i = 0; i < nums.size(); i++) {
                options[i] = nums.get(i);
            }
            new ValueRequestBuilder(new NumberListener() {

                @Override
                public void onInput(Player player, Number value) {
                    RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(), RewardHandler.getInstance().getDirectlyDefined("Cumulative." + value.intValue() + ".Rewards"));
                }
            }, options).allowCustomOption(false).usingMethod(InputMethod.INVENTORY).request(clickEvent.getPlayer());
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder(Material.EMERALD_BLOCK).setName("&aAdd cumulative reward")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            new ValueRequest().requestNumber(player, new NumberListener() {

                @Override
                public void onInput(Player player, Number value) {
                    plugin.getSpecialRewardsConfig().setCumulative(value.intValue());
                    plugin.reload();
                }
            });
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder(Material.REDSTONE_BLOCK).setName("&cRemove cumulative")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            new AdminVoteCumulativeRemove(plugin, clickEvent.getPlayer()).open();
        }
    });
    inv.openInventory(player);
}
Also used : Player(org.bukkit.entity.Player) BInventoryButton(com.bencodez.advancedcore.api.inventory.BInventoryButton) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) ArrayList(java.util.ArrayList) BInventory(com.bencodez.advancedcore.api.inventory.BInventory) ValueRequest(com.bencodez.advancedcore.api.valuerequest.ValueRequest) ValueRequestBuilder(com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder) ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) NumberListener(com.bencodez.advancedcore.api.valuerequest.listeners.NumberListener)

Example 3 with NumberListener

use of com.bencodez.advancedcore.api.valuerequest.listeners.NumberListener in project VotingPlugin by Ben12345rocks.

the class AdminVoteMilestones method onChest.

@Override
public void onChest(Player player) {
    BInventory inv = new BInventory("Edit MileStones");
    inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.MileStones");
    inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&cEdit existing milestone rewards")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            ArrayList<Integer> nums = new ArrayList<Integer>();
            for (String num : plugin.getSpecialRewardsConfig().getMilestoneVotes()) {
                if (StringParser.getInstance().isInt(num)) {
                    nums.add(Integer.parseInt(num));
                }
            }
            Number[] options = new Number[nums.size()];
            for (int i = 0; i < nums.size(); i++) {
                options[i] = nums.get(i);
            }
            new ValueRequestBuilder(new NumberListener() {

                @Override
                public void onInput(Player player, Number value) {
                    RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(), RewardHandler.getInstance().getDirectlyDefined("MileStones." + value.intValue() + ".Rewards"));
                }
            }, options).allowCustomOption(false).usingMethod(InputMethod.INVENTORY).request(clickEvent.getPlayer());
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder(Material.EMERALD_BLOCK).setName("&aAdd milestone")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            new ValueRequest().requestNumber(player, new NumberListener() {

                @Override
                public void onInput(Player player, Number value) {
                    plugin.getSpecialRewardsConfig().setMilestone(value.intValue());
                    plugin.reload();
                }
            });
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder(Material.REDSTONE_BLOCK).setName("&cRemove milestone")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            new AdminVoteMilestoneRemove(plugin, clickEvent.getPlayer()).open();
        }
    });
    inv.openInventory(player);
}
Also used : Player(org.bukkit.entity.Player) BInventoryButton(com.bencodez.advancedcore.api.inventory.BInventoryButton) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) ArrayList(java.util.ArrayList) BInventory(com.bencodez.advancedcore.api.inventory.BInventory) ValueRequest(com.bencodez.advancedcore.api.valuerequest.ValueRequest) ValueRequestBuilder(com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder) ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) NumberListener(com.bencodez.advancedcore.api.valuerequest.listeners.NumberListener)

Aggregations

ClickEvent (com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent)3 BInventoryButton (com.bencodez.advancedcore.api.inventory.BInventoryButton)3 ItemBuilder (com.bencodez.advancedcore.api.item.ItemBuilder)3 ValueRequestBuilder (com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder)3 NumberListener (com.bencodez.advancedcore.api.valuerequest.listeners.NumberListener)3 ArrayList (java.util.ArrayList)3 Player (org.bukkit.entity.Player)3 BInventory (com.bencodez.advancedcore.api.inventory.BInventory)2 ValueRequest (com.bencodez.advancedcore.api.valuerequest.ValueRequest)2 EditGUI (com.bencodez.advancedcore.api.inventory.editgui.EditGUI)1 EditGUIButton (com.bencodez.advancedcore.api.inventory.editgui.EditGUIButton)1 EditGUIValueBoolean (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueBoolean)1 EditGUIValueList (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueList)1 EditGUIValueNumber (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueNumber)1 EditGUIValueString (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString)1 RewardEditGUI (com.bencodez.advancedcore.command.gui.RewardEditGUI)1