use of com.bencodez.advancedcore.api.item.ItemBuilder in project VotingPlugin by Ben12345rocks.
the class VoteTopVoter method onChest.
@Override
public void onChest(Player player) {
try {
if (top == null) {
top = TopVoter.getDefault();
}
Set<Entry<TopVoterPlayer, Integer>> users = null;
String topVoter = top.getName();
@SuppressWarnings("unchecked") LinkedHashMap<TopVoterPlayer, Integer> topVotes = (LinkedHashMap<TopVoterPlayer, Integer>) plugin.getTopVoter(top).clone();
users = topVotes.entrySet();
BInventory inv = new BInventory(plugin.getGui().getChestVoteTopName());
inv.addPlaceholder("topvoter", topVoter);
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
inv.dontClose();
}
int pos = 1;
for (Entry<TopVoterPlayer, Integer> entry : users) {
ItemBuilder playerItem = new ItemBuilder(Material.PAPER);
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) {
if (plugin.getGui().getChestVoteTopOpenMainGUIOnClick()) {
TopVoterPlayer user = (TopVoterPlayer) getData("User");
new VoteGUI(plugin, player, user.getUser()).open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
} else {
getInv().forceClose(clickEvent.getPlayer());
}
}
}.addData("player", entry.getKey().getPlayerName()).addData("User", entry.getKey()));
pos++;
}
final TopVoter cur = top;
inv.getPageButtons().add(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteTopSwitchItem()).addPlaceholder("Top", topVoter)) {
@Override
public void onClick(ClickEvent clickEvent) {
if (!clickEvent.getClick().equals(ClickType.RIGHT)) {
new VoteTopVoter(plugin, player, user, cur.next(), 0).open(GUIMethod.CHEST);
} else {
new VoteTopVoter(plugin, player, user, cur.prev(), 0).open(GUIMethod.CHEST);
}
}
});
if (plugin.getGui().getChestVoteTopBackButton()) {
inv.getPageButtons().add(plugin.getCommandLoader().getBackButton(user).setSlot(1));
}
inv.setPages(true);
inv.setMaxInvSize(plugin.getGui().getChestVoteTopSize());
inv.openInventory(player);
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.bencodez.advancedcore.api.item.ItemBuilder 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.item.ItemBuilder 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.item.ItemBuilder in project VotingPlugin by Ben12345rocks.
the class VoteURL method getItemAll.
private ItemBuilder getItemAll() {
ItemBuilder builderAll = new ItemBuilder(plugin.getGui().getChestVoteURLAlreadyVotedAllUrlsButtonItemSection());
if (plugin.getGui().isChestVoteURLAllUrlsButtonrequireAllSitesVoted()) {
if (user.canVoteAny()) {
builderAll = new ItemBuilder(plugin.getGui().getChestVoteURLCanVoteAllUrlsButtonItemSection());
}
} else {
if (user.canVoteAll()) {
builderAll = new ItemBuilder(plugin.getGui().getChestVoteURLCanVoteAllUrlsButtonItemSection());
}
}
if (!builderAll.hasCustomDisplayName()) {
builderAll.setName("&4All Voting Sites");
}
if (!builderAll.hasCustomLore()) {
builderAll.setLore("&cClick Me");
}
int slot = plugin.getGui().getChestVoteURLAllUrlsButtonSlot();
if (slot >= 0) {
builderAll.setSlot(slot);
}
return builderAll;
}
use of com.bencodez.advancedcore.api.item.ItemBuilder in project VotingPlugin by Ben12345rocks.
the class AdminVoteVoteShopItem method onChest.
@Override
public void onChest(Player player) {
EditGUI inv = new EditGUI("Edit VoteShop Item: " + identifier);
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.VoteShop");
// to add
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueString("Identifier_Name", plugin.getGui().getChestShopIdentifierIdentifierName(identifier)) {
@Override
public void setValue(Player player, String name) {
setPathData(getKey(), name);
}
}));
inv.addButton(new EditGUIButton(new ItemBuilder(Material.OAK_DOOR, 1), new EditGUIValueString("Permission", plugin.getGui().getChestVoteShopPermission(identifier)) {
@Override
public void setValue(Player player, String name) {
setPathData(getKey(), name);
}
}));
inv.addButton(new EditGUIButton(new ItemBuilder(Material.EMERALD, 1), new EditGUIValueNumber("Cost", plugin.getGui().getChestShopIdentifierCost(identifier)) {
@Override
public void setValue(Player player, Number num) {
setPathData(getKey(), num.intValue());
}
}));
inv.addButton(new EditGUIButton(new ItemBuilder(Material.BARRIER, 1), new EditGUIValueNumber("Limit", plugin.getGui().getChestShopIdentifierLimit(identifier)) {
@Override
public void setValue(Player player, Number num) {
setPathData(getKey(), num.intValue());
}
}));
// display item
ConfigurationSection displayItemData = plugin.getGui().getChestShopIdentifierSection(identifier);
inv.addButton(new EditGUIButton(new ItemBuilder(Material.valueOf(displayItemData.getString("Material")), 1), new EditGUIValueString("Material", displayItemData.getString("Material")) {
@Override
public void setValue(Player player, String name) {
setPathData(getKey(), name);
}
}));
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueString("Name", displayItemData.getString("Name")) {
@Override
public void setValue(Player player, String name) {
setPathData(getKey(), name);
}
}));
inv.addButton(new EditGUIButton(new ItemBuilder(Material.BOOK, 1), new EditGUIValueList("Lore", displayItemData.getStringList("Lore")) {
@Override
public void setValue(Player player, ArrayList<String> value) {
setPathData(getKey(), value);
}
}));
inv.addButton(new BInventoryButton(new ItemBuilder(Material.DISPENSER, 1).setName("&cRewards")) {
@Override
public void onClick(ClickEvent clickEvent) {
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(), plugin.getRewardHandler().getDirectlyDefined("CHEST.Shop." + identifier + ".Rewards"));
}
});
// implement item reward?
inv.openInventory(player);
}
Aggregations