use of com.Ben12345rocks.VotingPlugin.Objects.VoteSite in project VotingPlugin by Ben12345rocks.
the class PlayerGUIs method openVoteURL.
public void openVoteURL(Player player, String voteSite) {
User user = UserManager.getInstance().getVotingPluginUser(player);
VoteSite site = plugin.getVoteSite(voteSite);
BInventory inv = new BInventory(StringUtils.getInstance().replacePlaceHolder(Config.getInstance().getGUIVoteURLSiteName(), "site", site.getDisplayName()));
inv.setMeta(player, "VoteSite", site);
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 BInventoryButton(new ItemBuilder(Material.COMPASS).setName("&4Next Vote").addLoreLine(Commands.getInstance().voteCommandNextInfo(user, site))) {
@Override
public void onClick(ClickEvent clickEvent) {
openVoteURL(clickEvent.getPlayer());
}
});
inv.addButton(new BInventoryButton(new ItemBuilder(Material.WATCH).setName("&4Last Vote").addLoreLine(Commands.getInstance().voteCommandLastLine(user, site))) {
@Override
public void onClick(ClickEvent clickEvent) {
openVoteURL(clickEvent.getPlayer());
}
});
if (Config.getInstance().getGUIVoteURLBackButton()) {
inv.addButton(new BInventoryButton(getBackButton()) {
@Override
public void onClick(ClickEvent event) {
openVoteGUI(event.getPlayer(), getSelectedPlayer(event.getPlayer()));
}
});
}
inv.openInventory(player);
}
use of com.Ben12345rocks.VotingPlugin.Objects.VoteSite in project VotingPlugin by Ben12345rocks.
the class PlayerGUIs method openVoteLast.
public void openVoteLast(Player player, User user) {
setSelectedPlayer(player, user);
BInventory inv = new BInventory(StringUtils.getInstance().replacePlaceHolder(Config.getInstance().getGUIVoteLastName(), "player", user.getPlayerName()));
for (VoteSite site : plugin.getVoteSites()) {
inv.addButton(inv.getNextSlot(), new BInventoryButton(site.getItem().setName(site.getDisplayName()).setLore(Commands.getInstance().voteCommandLastLine(user, site)).setAmountNone(1)) {
@Override
public void onClick(ClickEvent clickEvent) {
}
});
}
if (Config.getInstance().getGUIVoteLastBackButton()) {
inv.addButton(new BInventoryButton(getBackButton()) {
@Override
public void onClick(ClickEvent event) {
openVoteGUI(event.getPlayer(), getSelectedPlayer(event.getPlayer()));
}
});
}
inv.openInventory(player);
}
use of com.Ben12345rocks.VotingPlugin.Objects.VoteSite in project VotingPlugin by Ben12345rocks.
the class PlayerGUIs method openVoteToday.
public void openVoteToday(Player player) {
setSelectedPlayer(player, null);
BInventory inv = new BInventory(Config.getInstance().getGUIVoteTodayName());
for (User user : plugin.voteToday.keySet()) {
for (VoteSite voteSite : plugin.voteToday.get(user).keySet()) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(Config.getInstance().getFormatTimeFormat());
String timeString = plugin.voteToday.get(user).get(voteSite).format(formatter);
String msg = "&6" + user.getPlayerName() + " : " + voteSite.getDisplayName() + " : " + timeString;
inv.addButton(inv.getNextSlot(), new BInventoryButton(user.getPlayerName(), new String[] { msg }, MiscUtils.getInstance().setSkullOwner(user.getOfflinePlayer())) {
@Override
public void onClick(ClickEvent clickEvent) {
User user = UserManager.getInstance().getVotingPluginUser(clickEvent.getClickedItem().getItemMeta().getDisplayName());
openVoteGUI(player, user);
}
});
}
}
if (Config.getInstance().getGUIVoteTodayBackButton()) {
inv.addButton(new BInventoryButton(getBackButton()) {
@Override
public void onClick(ClickEvent event) {
openVoteGUI(event.getPlayer(), getSelectedPlayer(event.getPlayer()));
}
});
}
inv.openInventory(player);
}
use of com.Ben12345rocks.VotingPlugin.Objects.VoteSite in project VotingPlugin by Ben12345rocks.
the class ConfigVoteSites method getVoteSitesLoad.
/**
* Gets the vote sites load.
*
* @return the vote sites load
*/
public ArrayList<VoteSite> getVoteSitesLoad() {
ArrayList<VoteSite> voteSites = new ArrayList<VoteSite>();
ArrayList<String> voteSiteNames = getVoteSitesNames();
if (voteSiteNames != null) {
for (String site : voteSiteNames) {
if (getVoteSiteEnabled(site) && !site.equalsIgnoreCase("null")) {
if (!siteCheck(site)) {
plugin.getLogger().warning("Failed to load site " + site + ", see above");
} else {
voteSites.add(new VoteSite(site));
}
}
}
}
Collections.sort(voteSites, new Comparator<VoteSite>() {
@Override
public int compare(VoteSite v1, VoteSite v2) {
int v1P = v1.getPriority();
int v2P = v2.getPriority();
if (v1P < v2P) {
return 1;
}
if (v1P > v2P) {
return -1;
}
return 0;
}
});
return voteSites;
}
Aggregations