use of com.bencodez.votingplugin.objects.VoteSite in project VotingPlugin by Ben12345rocks.
the class VoteToday method onChest.
@Override
public void onChest(Player player) {
BInventory inv = new BInventory(plugin.getGui().getChestVoteTodayName());
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
inv.dontClose();
}
for (TopVoterPlayer user : plugin.getVoteToday().keySet()) {
for (VoteSite voteSite : plugin.getVoteToday().get(user).keySet()) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(plugin.getConfigFile().getFormatTimeFormat());
String timeString = plugin.getVoteToday().get(user).get(voteSite).format(formatter);
String msg = plugin.getGui().getChestVoteTodayLine();
HashMap<String, String> placeholders = new HashMap<String, String>();
placeholders.put("VoteSite", voteSite.getDisplayName());
placeholders.put("Time", timeString);
msg = StringParser.getInstance().replacePlaceHolder(msg, placeholders);
ItemBuilder item = null;
if (plugin.getGui().isChestVoteTodayUseSkull() && !NMSManager.getInstance().isVersion("1.12")) {
item = new ItemBuilder(user.getPlayerHead());
} else {
item = new ItemBuilder(plugin.getGui().getChestVoteTodayPlayerItem());
}
item.setName(StringParser.getInstance().replacePlaceHolder(plugin.getGui().getChestVoteTodayIconTitle(), "player", user.getPlayerName()));
item.setLore(msg);
final UUID uuid = user.getUuid();
inv.addButton(inv.getNextSlot(), new BInventoryButton(item) {
@Override
public void onClick(ClickEvent clickEvent) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(uuid);
new VoteGUI(plugin, player, user).open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
}
});
}
}
if (plugin.getGui().getChestVoteTodayBackButton()) {
inv.addButton(plugin.getCommandLoader().getBackButton(user));
}
inv.openInventory(player);
}
use of com.bencodez.votingplugin.objects.VoteSite in project VotingPlugin by Ben12345rocks.
the class VoteURL method getChat.
@Override
public ArrayList<String> getChat(CommandSender arg0) {
ArrayList<String> sites = new ArrayList<String>();
List<String> title = plugin.getConfigFile().getFormatCommandsVoteText();
if (title != null) {
sites.addAll(title);
}
if (plugin.getConfigFile().getFormatCommandsVoteAutoInputSites()) {
int counter = 0;
for (VoteSite voteSite : plugin.getVoteSites()) {
if (!voteSite.isHidden()) {
counter++;
String voteURL = voteSite.getVoteURL(json);
MessageBuilder message = new MessageBuilder(plugin.getConfigFile().getFormatCommandsVoteURLS());
message.replacePlaceholder("num", Integer.toString(counter)).replacePlaceholder("url", voteURL).replacePlaceholder("SiteName", voteSite.getDisplayName());
if (user != null && user.getPlayerName() != null) {
message.replacePlaceholder("player", "" + user.getPlayerName()).replacePlaceholder("Next", "" + user.voteCommandNextInfo(voteSite));
}
sites.add(message.colorize().getText());
}
}
}
if (user != null) {
HashMap<String, String> phs = new HashMap<String, String>();
phs.put("DailyTotal", "" + user.getTotal(TopVoter.Daily));
phs.put("WeekTotal", "" + user.getTotal(TopVoter.Weekly));
phs.put("MonthTotal", "" + user.getTotal(TopVoter.Monthly));
phs.put("Total", "" + user.getTotal(TopVoter.AllTime));
sites = ArrayUtils.getInstance().replacePlaceHolder(sites, phs);
}
return ArrayUtils.getInstance().colorize(sites);
}
use of com.bencodez.votingplugin.objects.VoteSite in project VotingPlugin by Ben12345rocks.
the class VoteURL method onBook.
@Override
public void onBook(Player player) {
BookWrapper book = new BookWrapper(plugin.getGui().getBookVoteURLBookGUITitle());
for (VoteSite site : plugin.getVoteSites()) {
Layout layout = new Layout(plugin.getGui().getBookVoteURLBookGUILayout()).addPlaceholder("sitename", site.getDisplayName());
String text = plugin.getGui().getBookVoteURLBookGUIAlreadyVotedText();
ChatColor color = ChatColor.valueOf(plugin.getGui().getBookVoteURLBookGUIAlreadyVotedColor());
if (user.canVoteSite(site)) {
color = ChatColor.valueOf(plugin.getGui().getBookVoteURLBookGUICanVoteColor());
text = plugin.getGui().getBookVoteURLBookGUICanVoteText();
}
String url = StringParser.getInstance().replacePlaceHolder(site.getVoteURLJsonStrip(), "player", user.getPlayerName());
layout.replaceTextComponent("[UrlText]", BookUtil.TextBuilder.of(text).color(color).onClick(BookUtil.ClickAction.openUrl(url)).onHover(BookUtil.HoverAction.showText(url)).build());
book.addLayout(layout);
}
book.open(player);
}
Aggregations