use of com.bencodez.advancedcore.api.inventory.BInventory 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);
}
use of com.bencodez.advancedcore.api.inventory.BInventory 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);
}
use of com.bencodez.advancedcore.api.inventory.BInventory in project VotingPlugin by Ben12345rocks.
the class VoteTopVoterLastMonth method onChest.
@Override
public void onChest(Player player) {
Set<Entry<TopVoterPlayer, Integer>> users = null;
users = plugin.getLastMonthTopVoter().entrySet();
BInventory inv = new BInventory(plugin.getGui().getChestVoteTopName());
inv.addPlaceholder("topvoter", "Last Month");
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
inv.dontClose();
}
int pos = 1;
for (Entry<TopVoterPlayer, Integer> entry : users) {
ItemBuilder playerItem;
if (plugin.getGui().isChestVoteTopUseSkull()) {
playerItem = new ItemBuilder(entry.getKey().getPlayerHead());
} else {
playerItem = new ItemBuilder(Material.valueOf(plugin.getGui().getChestVoteTopPlayerItemMaterial()));
}
playerItem.setLore(new ArrayList<String>());
inv.addButton(new BInventoryButton(playerItem.setName(plugin.getGui().getChestVoteTopItemName()).addLoreLine(plugin.getGui().getChestVoteTopItemLore()).addPlaceholder("position", "" + pos).addPlaceholder("player", entry.getKey().getPlayerName()).addPlaceholder("votes", "" + entry.getValue())) {
@Override
public void onClick(ClickEvent clickEvent) {
TopVoterPlayer user = (TopVoterPlayer) getData("User");
new VoteGUI(plugin, player, user.getUser()).open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
}
}.addData("player", entry.getKey().getPlayerName()).addData("User", entry.getKey()));
pos++;
}
if (plugin.getGui().getChestVoteTopBackButton()) {
inv.getPageButtons().add(plugin.getCommandLoader().getBackButton(user).setSlot(1));
}
inv.setPages(true);
inv.setMaxInvSize(plugin.getGui().getChestVoteTopSize());
inv.openInventory(player);
}
use of com.bencodez.advancedcore.api.inventory.BInventory in project VotingPlugin by Ben12345rocks.
the class VoteURL method onChest.
@Override
public void onChest(Player player) {
// normal GUI
BInventory inv = new BInventory(plugin.getGui().getChestVoteURLName());
if (plugin.getGui().getChestVoteURLViewAllUrlsButtonEnabled()) {
ItemBuilder builderAll = getItemAll();
inv.addButton(new UpdatingBInventoryButton(builderAll, 5000, 5000) {
@Override
public void onClick(ClickEvent event) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(event.getPlayer());
json = true;
user.sendMessage(getChat(player));
}
@Override
public ItemBuilder onUpdate(Player player) {
return getItemAll();
}
});
}
int startSlot = plugin.getGui().getChestVoteURLAllUrlsButtonStartSlot();
for (final VoteSite voteSite : plugin.getVoteSites()) {
if (!voteSite.isHidden()) {
ItemBuilder builder = getItemVoteSite(voteSite);
if (startSlot >= 0) {
builder.setSlot(startSlot);
startSlot++;
}
inv.addButton(new UpdatingBInventoryButton(builder, 5000, 5000) {
@Override
public void onClick(ClickEvent event) {
Player player = event.getPlayer();
if (player != null) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
user.sendMessage(StringParser.getInstance().replacePlaceHolder(StringParser.getInstance().replacePlaceHolder(StringParser.getInstance().replacePlaceHolder(plugin.getGui().getChestVoteURLURLText(), "voteurl", voteSite.getVoteURL()), "sitename", voteSite.getDisplayName()), "player", player.getName()));
}
}
@Override
public ItemBuilder onUpdate(Player player) {
return getItemVoteSite(voteSite);
}
});
}
}
for (final String str : plugin.getGui().getChestVoteURLExtraItems()) {
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteURLExtraItemsItem(str))) {
@Override
public void onClick(ClickEvent clickEvent) {
new RewardBuilder(plugin.getGui().getData(), "CHEST.VoteURL.ExtraItems." + str + ".Rewards").setGiveOffline(false).send(clickEvent.getPlayer());
}
});
}
if (plugin.getGui().getChestVoteURLBackButton()) {
inv.addButton(plugin.getCommandLoader().getBackButton(user));
}
inv.openInventory(player);
}
use of com.bencodez.advancedcore.api.inventory.BInventory in project VotingPlugin by Ben12345rocks.
the class AdminGUI method openAdminGUIVoteSites.
/**
* Open admin GUI vote sites.
*
* @param player the player
*/
public void openAdminGUIVoteSites(Player player) {
BInventory inv = new BInventory("VoteSites");
int count = 0;
for (VoteSite voteSite : plugin.getVoteSites()) {
ArrayList<String> lore = new ArrayList<String>();
lore.add("Priority: " + voteSite.getPriority());
lore.add("Name: " + voteSite.getDisplayName());
lore.add("ServiceSite: " + voteSite.getServiceSite());
lore.add("VoteURL: " + voteSite.getVoteURL());
lore.add("VoteDelay: " + voteSite.getVoteDelay());
lore.add("VoteDelayMin: " + voteSite.getVoteDelayMin());
inv.addButton(count, new BInventoryButton(voteSite.getKey(), ArrayUtils.getInstance().convert(lore), new ItemStack(Material.STONE)) {
@Override
public void onClick(ClickEvent event) {
Player player = event.getWhoClicked();
openAdminGUIVoteSiteSite(player, voteSite);
}
});
count++;
}
inv.openInventory(player);
}
Aggregations