use of com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory 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.AdvancedCore.Util.Inventory.BInventory in project VotingPlugin by Ben12345rocks.
the class PlayerGUIs method openVoteGUI.
public void openVoteGUI(Player player, User user) {
if (user == null) {
user = UserManager.getInstance().getVotingPluginUser(player);
setSelectedPlayer(player, user);
}
if ((!player.getName().equals(user.getPlayerName()) && !player.hasPermission("VotingPlugin.Commands.Vote.GUI.Other") && !player.hasPermission("VotingPlugin.Mod")) || (!player.hasPermission("VotingPlugin.Commands.Vote.GUI") && !player.hasPermission("VotingPlugin.Player"))) {
player.sendMessage(StringUtils.getInstance().colorize(AdvancedCoreHook.getInstance().getFormatNoPerms()));
return;
}
setSelectedPlayer(player, user);
BInventory inv = new BInventory(StringUtils.getInstance().replacePlaceHolder(Config.getInstance().getGUIVoteGUIName(), "player", user.getPlayerName()));
for (String slot : Config.getInstance().getVoteGUISlots()) {
ItemBuilder builder = new ItemBuilder(Config.getInstance().getVoteGUISlotSection(slot));
String[] lore = new String[1];
lore = ArrayUtils.getInstance().convert(Config.getInstance().getVoteGUISlotLore(slot));
if (lore.length == 0) {
if (slot.equalsIgnoreCase("url")) {
lore = Commands.getInstance().voteURLs(user);
} else if (slot.equalsIgnoreCase("next")) {
lore = Commands.getInstance().voteCommandNext(user);
} else if (slot.equalsIgnoreCase("last")) {
lore = Commands.getInstance().voteCommandLast(user);
} else if (slot.equalsIgnoreCase("total")) {
lore = Commands.getInstance().voteCommandTotal(user);
} else if (slot.equalsIgnoreCase("top")) {
String str = Config.getInstance().getVoteTopDefault();
if (str.equalsIgnoreCase("monthly")) {
lore = TopVoterHandler.getInstance().topVoterMonthly(1);
} else if (str.equalsIgnoreCase("weekly")) {
lore = TopVoterHandler.getInstance().topVoterWeekly(1);
} else if (str.equalsIgnoreCase("daily")) {
lore = TopVoterHandler.getInstance().topVoterDaily(1);
} else {
lore = TopVoterHandler.getInstance().topVoterAllTime(1);
}
} else if (slot.equalsIgnoreCase("today")) {
lore = Commands.getInstance().voteToday();
} else if (slot.equalsIgnoreCase("help")) {
lore = new String[] { "Click to view help" };
}
}
HashMap<String, String> placeholders = new HashMap<String, String>();
placeholders.put("points", "" + user.getPoints());
builder.setPlaceholders(placeholders);
builder.setLore(ArrayUtils.getInstance().convert(lore));
inv.addButton(Config.getInstance().getVoteGUISlotSlot(slot), new BInventoryButton(builder) {
@Override
public void onClick(ClickEvent event) {
Player player = event.getWhoClicked();
String cmd = Config.getInstance().getVoteGUISlotCommand(slot);
User user = getSelectedPlayer(player);
if (!cmd.equals("")) {
player.performCommand(cmd);
} else {
if (slot.equalsIgnoreCase("url")) {
openVoteURL(player);
} else if (slot.equalsIgnoreCase("next")) {
openVoteNext(player, user);
} else if (slot.equalsIgnoreCase("last")) {
openVoteLast(player, user);
} else if (slot.equalsIgnoreCase("total")) {
openVoteTotal(player, user);
} else if (slot.equalsIgnoreCase("top")) {
openVoteTop(player, null);
} else if (slot.equalsIgnoreCase("today")) {
openVoteToday(player);
} else if (slot.equalsIgnoreCase("help")) {
player.performCommand("vote help");
} else if (slot.equalsIgnoreCase("shop")) {
VoteShop.getInstance().voteShop(player);
}
}
}
});
}
inv.openInventory(player);
}
use of com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory 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.AdvancedCore.Util.Inventory.BInventory 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.AdvancedCore.Util.Inventory.BInventory in project VotingPlugin by Ben12345rocks.
the class VoteShop method voteShop.
public void voteShop(Player player) {
BInventory inv = new BInventory(Config.getInstance().getVoteShopName());
for (String identifier : Config.getInstance().getIdentifiers()) {
ItemBuilder builder = new ItemBuilder(Config.getInstance().getIdentifierSection(identifier));
inv.addButton(Config.getInstance().getIdentifierSlot(identifier), new BInventoryButton(builder) {
@Override
public void onClick(ClickEvent event) {
Player player = event.getWhoClicked();
User user = UserManager.getInstance().getVotingPluginUser(player);
int points = Config.getInstance().getIdentifierCost(identifier);
String identifier = Config.getInstance().getIdentifierFromSlot(event.getSlot());
if (identifier != null) {
if (user.removePoints(points)) {
RewardHandler.getInstance().giveReward(user, Config.getInstance().getData(), Config.getInstance().getIdentifierRewardsPath(identifier));
user.sendMessage(Config.getInstance().getFormatShopPurchaseMsg().replace("%Identifier%", identifier).replace("%Points%", "" + points));
} else {
user.sendMessage(Config.getInstance().getFormatShopFailedMsg().replace("%Identifier%", identifier).replace("%Points%", "" + points));
}
}
}
});
}
if (Config.getInstance().getVoteShopBackButton()) {
inv.addButton(new BInventoryButton(PlayerGUIs.getInstance().getBackButton()) {
@Override
public void onClick(ClickEvent event) {
PlayerGUIs.getInstance().openVoteGUI(event.getPlayer(), UserManager.getInstance().getVotingPluginUser(player));
}
});
}
inv.openInventory(player);
}
Aggregations