use of com.bencodez.advancedcore.api.inventory.BInventoryButton in project VotingPlugin by Ben12345rocks.
the class VoteBest method onChest.
@Override
public void onChest(Player player) {
BInventory inv = new BInventory(plugin.getGui().getChestVoteBestName());
inv.addPlaceholder("player", user.getPlayerName());
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteBestDayBestItem()).addPlaceholder("Best", "" + user.getBestDayVoteStreak())) {
@Override
public void onClick(ClickEvent clickEvent) {
}
});
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteBestWeekBestItem()).addPlaceholder("Best", "" + user.getBestWeekVoteStreak())) {
@Override
public void onClick(ClickEvent clickEvent) {
}
});
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteBestMonthBestItem()).addPlaceholder("Best", "" + user.getBestMonthVoteStreak())) {
@Override
public void onClick(ClickEvent clickEvent) {
}
});
if (plugin.getGui().isChestVoteBestBackButton()) {
inv.addButton(plugin.getCommandLoader().getBackButton(user));
}
inv.openInventory(player);
}
use of com.bencodez.advancedcore.api.inventory.BInventoryButton 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.advancedcore.api.inventory.BInventoryButton in project AdvancedCore by BenCodez.
the class AdminGUI method openGUI.
/**
* Open GUI.
*
* @param player the player
*/
public void openGUI(Player player) {
if (!player.hasPermission(AdvancedCorePlugin.getInstance().getOptions().getPermPrefix() + ".Admin")) {
player.sendMessage("Not enough permissions");
return;
}
BInventory inv = new BInventory("AdminGUI");
inv.addButton(inv.getNextSlot(), new BInventoryButton("&cRewards", new String[] { "&cMiddle click to create" }, new ItemStack(Material.DIAMOND)) {
@Override
public void onClick(ClickEvent event) {
Player player = event.getWhoClicked();
if (event.getClick().equals(ClickType.MIDDLE)) {
new ValueRequest().requestString(player, new StringListener() {
@Override
public void onInput(Player player, String value) {
Reward reward = plugin.getRewardHandler().getReward(value);
player.sendMessage("Reward file created");
plugin.reloadAdvancedCore(false);
RewardEditGUI.getInstance().openRewardGUI(player, reward);
}
});
} else {
RewardEditGUI.getInstance().openRewardsGUI(player);
}
}
});
inv.addButton(inv.getNextSlot(), new BInventoryButton(new ItemBuilder("PLAYER_HEAD").setName("&cUsers")) {
@Override
public void onClick(ClickEvent event) {
Player player = event.getWhoClicked();
UserGUI.getInstance().openUsersGUI(player);
}
});
if (pluginGUIs != null) {
for (BInventoryButton b : pluginGUIs) {
inv.addButton(inv.getNextSlot(), b);
}
}
inv.openInventory(player);
}
use of com.bencodez.advancedcore.api.inventory.BInventoryButton in project AdvancedCore by BenCodez.
the class ChoiceGUI method openPreferenceReward.
public void openPreferenceReward(Player player, String rewardName) {
Reward reward = plugin.getRewardHandler().getReward(rewardName);
if (!reward.getConfig().getEnableChoices()) {
player.sendMessage("Choice rewards not enabled");
return;
}
AdvancedCoreUser user = plugin.getUserManager().getUser(player);
BInventory inv = new BInventory("Select Preference");
for (String choice : reward.getConfig().getChoices()) {
ItemBuilder builder = new ItemBuilder(reward.getConfig().getChoicesItem(choice));
if (user.getChoicePreference(rewardName).equalsIgnoreCase(choice)) {
builder.addLoreLine("&cCurrent preference");
builder.addLoreLine("&c&lClick to remove");
} else {
builder.addLoreLine("&aClick to set as preference");
}
builder.setName("&a" + choice);
inv.addButton(new BInventoryButton(builder) {
@Override
public void onClick(ClickEvent clickEvent) {
AdvancedCoreUser user = (AdvancedCoreUser) getInv().getData("User");
String rewardName = (String) getInv().getData("Reward");
String choice = (String) getData("Choice");
if (user.getChoicePreference(rewardName).equals(choice)) {
choice = "none";
}
user.setChoicePreference(rewardName, choice);
user.sendMessage(plugin.getOptions().getFormatChoiceRewardsPreferenceSet(), "choice", choice);
}
}.addData("Choice", choice));
}
inv.addData("User", user);
inv.addData("Reward", rewardName);
inv.openInventory(player);
}
use of com.bencodez.advancedcore.api.inventory.BInventoryButton in project AdvancedCore by BenCodez.
the class ChoiceGUI method openClaimChoices.
public void openClaimChoices(Player player, Reward reward) {
if (!reward.getConfig().getEnableChoices()) {
player.sendMessage("Choice rewards not enabled");
return;
}
AdvancedCoreUser user = plugin.getUserManager().getUser(player);
BInventory inv = new BInventory("Pick reward");
inv.dontClose();
for (String choice : reward.getConfig().getChoices()) {
ItemBuilder builder = new ItemBuilder(reward.getConfig().getChoicesItem(choice)).setNameIfNotExist("&a" + choice);
inv.addButton(new BInventoryButton(builder) {
@Override
public void onClick(ClickEvent clickEvent) {
Reward reward = (Reward) getInv().getData("Reward");
AdvancedCoreUser user = (AdvancedCoreUser) getInv().getData("User");
String choice = (String) getData("Choice");
user.removeUnClaimedChoiceReward(reward.getName());
plugin.getRewardHandler().giveChoicesReward(reward, user, choice);
if (user.getUnClaimedChoices().size() > 0) {
openClaimChoices(clickEvent.getPlayer());
} else {
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
clickEvent.getPlayer().closeInventory();
}
});
}
}
}.addData("Choice", choice));
}
inv.addData("User", user);
inv.addData("Reward", reward);
inv.openInventory(player);
}
Aggregations