use of com.bencodez.votingplugin.objects.VoteSite in project VotingPlugin by Ben12345rocks.
the class VoteLast method getChat.
@Override
public ArrayList<String> getChat(CommandSender sender) {
ArrayList<String> msg = new ArrayList<String>();
String playerName = user.getPlayerName();
msg.add(StringParser.getInstance().replaceIgnoreCase(plugin.getConfigFile().getFormatCommandsVoteLastTitle(), "%player%", playerName));
for (VoteSite voteSite : plugin.getVoteSites()) {
if (!voteSite.isHidden()) {
msg.add(user.voteCommandLastLine(voteSite));
}
}
return ArrayUtils.getInstance().colorize(msg);
}
use of com.bencodez.votingplugin.objects.VoteSite 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.votingplugin.objects.VoteSite in project VotingPlugin by Ben12345rocks.
the class AdminGUI method openAdminGUIVoteSiteSite.
/**
* Open admin GUI vote site site.
*
* @param player the player
* @param voteSite the vote site
*/
public void openAdminGUIVoteSiteSite(Player player, VoteSite voteSite) {
EditGUI inv = new EditGUI("VoteSite: " + voteSite.getDisplayName());
inv.setMeta(player, "VoteSite", voteSite);
inv.addButton(new BInventoryButton(voteSite.getItem().setName("&cForce vote")) {
@Override
public void onClick(ClickEvent event) {
ArrayList<String> playerNames = new ArrayList<String>();
for (Player p : Bukkit.getOnlinePlayers()) {
playerNames.add(p.getName());
}
new ValueRequestBuilder(new StringListener() {
@Override
public void onInput(Player player, String value) {
Object ob = PlayerUtils.getInstance().getPlayerMeta(player, "VoteSite");
if (ob != null) {
VoteSite site = (VoteSite) ob;
PlayerVoteEvent voteEvent = new PlayerVoteEvent(site, value, site.getServiceSite(), false);
plugin.getServer().getPluginManager().callEvent(voteEvent);
}
}
}, ArrayUtils.getInstance().convert(playerNames)).usingMethod(InputMethod.INVENTORY).allowCustomOption(true).request(event.getWhoClicked());
}
});
inv.addButton(new EditGUIButton(new EditGUIValueNumber("Priority", voteSite.getPriority()) {
@Override
public void setValue(Player player, Number num) {
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
plugin.getConfigVoteSites().setPriority(voteSite.getKey(), num.intValue());
plugin.reload();
}
}));
inv.addButton(new EditGUIButton(new EditGUIValueString("ServiceSite", voteSite.getServiceSite()) {
@Override
public void setValue(Player player, String value) {
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
String siteName = voteSite.getKey();
plugin.getConfigVoteSites().setServiceSite(siteName, value);
plugin.reload();
}
}));
inv.addButton(new EditGUIButton(new EditGUIValueString("Name", voteSite.getDisplayName()) {
@Override
public void setValue(Player player, String value) {
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
plugin.getConfigVoteSites().setDisplayName(voteSite.getKey(), value);
plugin.reload();
}
}));
inv.addButton(new EditGUIButton(new EditGUIValueString("VoteURL", voteSite.getVoteURL()) {
@Override
public void setValue(Player player, String value) {
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
String siteName = voteSite.getKey();
plugin.getConfigVoteSites().setVoteURL(siteName, value);
plugin.reload();
}
}));
inv.addButton(new EditGUIButton(new EditGUIValueNumber("VoteDelay", voteSite.getVoteDelay()) {
@Override
public void setValue(Player player, Number num) {
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
String siteName = voteSite.getKey();
plugin.getConfigVoteSites().setVoteDelay(siteName, num.intValue());
plugin.reload();
}
}));
inv.addButton(new EditGUIButton(new EditGUIValueNumber("VoteDelayMin", voteSite.getVoteDelay()) {
@Override
public void setValue(Player player, Number num) {
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
String siteName = voteSite.getKey();
plugin.getConfigVoteSites().setVoteDelay(siteName, num.intValue());
plugin.reload();
}
}));
inv.addButton(new EditGUIButton(new EditGUIValueBoolean("Enabled", voteSite.isEnabled()) {
@Override
public void setValue(Player player, boolean value) {
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
String siteName = voteSite.getKey();
plugin.getConfigVoteSites().setEnabled(siteName, value);
plugin.reload();
}
}));
inv.addButton(new EditGUIButton(new EditGUIValueBoolean("ForceOffline", voteSite.isGiveOffline()) {
@Override
public void setValue(Player player, boolean value) {
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
String siteName = voteSite.getKey();
plugin.getConfigVoteSites().setForceOffline(siteName, value);
plugin.reload();
}
}));
inv.addButton(new EditGUIButton(new EditGUIValueBoolean("VoteDelayDaily", voteSite.isVoteDelayDaily()) {
@Override
public void setValue(Player player, boolean value) {
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
String siteName = voteSite.getKey();
plugin.getConfigVoteSites().setVoteDelayDaily(siteName, value);
plugin.reload();
}
}));
if (voteSite.getSiteData().isList("Rewards")) {
inv.addButton(new EditGUIButton(new EditGUIValueList("Rewards", voteSite.getSiteData().getStringList("Rewards")) {
@Override
public void setValue(Player p, ArrayList<String> rewards) {
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
plugin.getConfigVoteSites().set(voteSite.getKey(), "Rewards", rewards);
plugin.reload();
}
}));
} else {
inv.addButton(new BInventoryButton(new ItemBuilder(Material.DISPENSER, 1).setName("&cRewards")) {
@Override
public void onClick(ClickEvent clickEvent) {
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(), RewardHandler.getInstance().getDirectlyDefined("VoteSites." + voteSite.getKey() + ".Rewards"));
}
});
}
inv.openInventory(player);
}
use of com.bencodez.votingplugin.objects.VoteSite in project VotingPlugin by Ben12345rocks.
the class AdminVoteVotePlayer method onChest.
@Override
public void onChest(Player player) {
EditGUI inv = new EditGUI("Trigger vote for " + playerName);
inv.requirePermission("VotingPlugin.Commands.AdminVote.Vote|VotingPlugin.Admin");
for (VoteSite site : plugin.getVoteSites()) {
inv.addButton(new BInventoryButton(site.getItem().setName(site.getKey())) {
@Override
public void onClick(ClickEvent clickEvent) {
VoteSite site = (VoteSite) getData("site");
PlayerVoteEvent voteEvent = new PlayerVoteEvent(site, playerName, site.getServiceSite(), false);
sendMessage(clickEvent.getPlayer(), "&cTriggering vote...");
if (voteEvent.getVoteSite() != null) {
if (!voteEvent.getVoteSite().isVaidServiceSite()) {
sendMessage(clickEvent.getPlayer(), "&cPossible issue with service site, has the server gotten the vote from " + voteEvent.getServiceSite() + "?");
}
}
plugin.getServer().getPluginManager().callEvent(voteEvent);
if (plugin.isYmlError()) {
sendMessage(clickEvent.getPlayer(), "&3Detected yml error, please check server log for details");
}
}
}.addData("site", site));
}
inv.openInventory(player);
}
use of com.bencodez.votingplugin.objects.VoteSite in project VotingPlugin by Ben12345rocks.
the class VoteToday method voteToday.
public String[] voteToday() {
ArrayList<String> msg = new ArrayList<String>();
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);
HashMap<String, String> placeholders = new HashMap<String, String>();
placeholders.put("player", user.getPlayerName());
placeholders.put("votesite", voteSite.getKey());
placeholders.put("time", timeString);
msg.add(StringParser.getInstance().replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteTodayLine(), placeholders));
// msg.add("&6" + user.getPlayerName() + " : " + voteSite.getKey() + " : " +
// timeString);
}
}
msg = ArrayUtils.getInstance().colorize(msg);
return ArrayUtils.getInstance().convert(msg);
}
Aggregations