use of com.Ben12345rocks.VotingPlugin.Objects.TopVoter in project VotingPlugin by Ben12345rocks.
the class PlayerGUIs method openVoteTop.
public void openVoteTop(Player player, TopVoter top) {
if (top == null) {
top = TopVoter.getDefault();
}
BInventory inv = null;
Set<Entry<User, Integer>> users = null;
String topVoter = "";
if (top.equals(TopVoter.Monthly)) {
topVoter = Config.getInstance().getFormatTopVoterMonthly();
users = plugin.topVoterMonthly.entrySet();
} else if (top.equals(TopVoter.Weekly)) {
topVoter = Config.getInstance().getFormatTopVoterWeekly();
users = plugin.topVoterWeekly.entrySet();
} else if (top.equals(TopVoter.Daily)) {
topVoter = Config.getInstance().getFormatTopVoterDaily();
users = plugin.topVoterDaily.entrySet();
} else {
topVoter = Config.getInstance().getFormatTopVoterAllTime();
users = plugin.topVoterAllTime.entrySet();
}
inv = new BInventory(StringUtils.getInstance().replacePlaceHolder(Config.getInstance().getGUIVoteTopName(), "topvoter", topVoter));
int pos = 1;
for (Entry<User, Integer> entry : users) {
inv.addButton(new BInventoryButton(new ItemBuilder(MiscUtils.getInstance().setSkullOwner(entry.getKey().getOfflinePlayer())).setName(Config.getInstance().getGUIVoteTopItemName()).addLoreLine(Config.getInstance().getGUIVoteTopItemLore()).addPlaceholder("position", "" + pos).addPlaceholder("player", entry.getKey().getPlayerName()).addPlaceholder("votes", "" + entry.getValue())) {
@Override
public void onClick(ClickEvent clickEvent) {
// ItemBuilder item = new ItemBuilder(clickEvent.getClickedItem());
// String name = ChatColor.stripColor(item.getName()).split(":")[1].trim();
String name = (String) clickEvent.getButton().getData("player");
User user = UserManager.getInstance().getVotingPluginUser(name);
openVoteGUI(player, user);
}
}.addData("player", entry.getKey().getPlayerName()));
pos++;
}
final TopVoter cur = top;
inv.getPageButtons().add(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteTopSwitchItem()).addPlaceholder("Top", topVoter)) {
@Override
public void onClick(ClickEvent clickEvent) {
if (!clickEvent.getClick().equals(ClickType.RIGHT)) {
openVoteTop(player, cur.next());
} else {
openVoteTop(player, cur.prev());
}
}
});
if (Config.getInstance().getGUIVoteTopBackButton()) {
inv.getPageButtons().add(new BInventoryButton(getBackButton().setSlot(1)) {
@Override
public void onClick(ClickEvent event) {
openVoteGUI(event.getPlayer(), getSelectedPlayer(event.getPlayer()));
}
});
}
inv.setPages(true);
inv.setMaxInvSize(Config.getInstance().getGUIVoteTopSize());
inv.openInventory(player);
}
Aggregations