use of com.bencodez.advancedcore.api.inventory.BInventoryButton in project AdvancedCore by BenCodez.
the class RewardEditSpecialChance method openRename.
public void openRename(Player player, RewardEditData reward) {
EditGUI inv = new EditGUI("Edit SpecialChance Rename: " + reward.getName());
inv.addData("Reward", reward);
for (String key : reward.getData().getConfigurationSection("SpecialChance").getKeys(false)) {
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&a" + key).addLoreLine("&aClick to rename")) {
@Override
public void onClick(ClickEvent clickEvent) {
new ValueRequestBuilder(new NumberListener() {
@Override
public void onInput(Player player, Number value) {
RewardEditData reward = (RewardEditData) getInv().getData("Reward");
reward.setValue("SpecialChance." + value.intValue(), reward.getData().getConfigurationSection("SpecialChance." + key));
reward.setValue("SpecialChance." + key, null);
reloadAdvancedCore();
open(player, reward);
}
}, new Number[] {}).usingMethod(InputMethod.CHAT).request(clickEvent.getPlayer());
}
});
}
inv.addButton(getBackButtonCustom(reward, new EditGUIValueInventory("") {
@Override
public void openInventory(ClickEvent clickEvent) {
RewardEditData reward = (RewardEditData) getInv().getData("Reward");
open(player, reward);
}
}));
inv.openInventory(player);
}
use of com.bencodez.advancedcore.api.inventory.BInventoryButton in project AdvancedCore by BenCodez.
the class RewardEditSpecialChance method openEditSub.
public void openEditSub(Player player, RewardEditData reward) {
EditGUI inv = new EditGUI("Edit SpecialChance Edit Sub: " + reward.getName());
inv.addData("Reward", reward);
for (String key : reward.getData().getConfigurationSection("SpecialChance").getKeys(false)) {
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&a" + key).addLoreLine("&aClick to edit")) {
@Override
public void onClick(ClickEvent clickEvent) {
RewardEditData reward = (RewardEditData) getInv().getData("Reward");
openSubReward(clickEvent.getPlayer(), "SpecialChance." + key, reward);
}
});
}
inv.addButton(getBackButtonCustom(reward, new EditGUIValueInventory("") {
@Override
public void openInventory(ClickEvent clickEvent) {
RewardEditData reward = (RewardEditData) getInv().getData("Reward");
open(player, reward);
}
}));
inv.openInventory(player);
}
use of com.bencodez.advancedcore.api.inventory.BInventoryButton in project AdvancedCore by BenCodez.
the class EditGUIValueList method onClick.
@Override
public void onClick(ClickEvent clickEvent) {
if (getCurrentValue() == null) {
setCurrentValue(new ArrayList<String>());
}
BInventory inv = new BInventory("Edit list: " + getKey());
inv.setMeta(clickEvent.getPlayer(), "Value", getCurrentValue());
inv.addButton(new BInventoryButton(new ItemBuilder(Material.EMERALD_BLOCK).setName("&cAdd value")) {
@Override
public void onClick(ClickEvent clickEvent) {
new ValueRequestBuilder(new Listener<String>() {
@Override
public void onInput(Player player, String add) {
@SuppressWarnings("unchecked") ArrayList<String> list = (ArrayList<String>) getMeta(player, "Value");
if (list == null) {
list = new ArrayList<String>();
}
list.add(add);
setValue(player, list);
sendMessage(player, "&cAdded " + add + " to " + getKey());
}
}, new String[] {}).request(clickEvent.getPlayer());
}
});
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cRemove value")) {
@SuppressWarnings("unchecked")
@Override
public void onClick(ClickEvent clickEvent) {
ArrayList<String> list = (ArrayList<String>) getMeta(clickEvent.getPlayer(), "Value");
if (!list.isEmpty()) {
new ValueRequestBuilder(new Listener<String>() {
@Override
public void onInput(Player player, String add) {
ArrayList<String> list = (ArrayList<String>) getMeta(player, "Value");
list.remove(add);
setValue(player, list);
sendMessage(player, "&cRemoved " + add + " from " + getKey());
}
}, ArrayUtils.getInstance().convert((ArrayList<String>) getMeta(clickEvent.getPlayer(), "Value"))).usingMethod(InputMethod.INVENTORY).allowCustomOption(false).request(clickEvent.getPlayer());
} else {
clickEvent.getPlayer().sendMessage("No values to remove");
}
}
});
inv.openInventory(clickEvent.getPlayer());
}
use of com.bencodez.advancedcore.api.inventory.BInventoryButton in project VotingPlugin by Ben12345rocks.
the class VoteShopConfirm method onChest.
@Override
public void onChest(Player player) {
PlayerUtils.getInstance().setPlayerMeta(player, "ident", identifier);
BInventory inv = new BInventory(plugin.getGui().getChestShopConfirmPurchaseTitle());
inv.dontClose();
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestShopConfirmPurchaseYesItem())) {
@Override
public void onClick(ClickEvent event) {
user.clearCache();
int points = plugin.getGui().getChestShopIdentifierCost(identifier);
int limit = plugin.getGui().getChestShopIdentifierLimit(identifier);
HashMap<String, String> placeholders = new HashMap<String, String>();
placeholders.put("identifier", identifier);
placeholders.put("points", "" + points);
placeholders.put("limit", "" + limit);
if (user.removePoints(points)) {
plugin.getLogger().info("VoteShop: " + user.getPlayerName() + "/" + user.getUUID() + " bought " + identifier + " for " + points);
plugin.getRewardHandler().giveReward(user, plugin.getGui().getData(), plugin.getGui().getChestShopIdentifierRewardsPath(identifier), new RewardOptions().setPlaceholders(placeholders));
user.sendMessage(StringParser.getInstance().replacePlaceHolder(plugin.getGui().getCHESTVoteShopPurchase(identifier), placeholders));
if (limit > 0) {
user.setVoteShopIdentifierLimit(identifier, user.getVoteShopIdentifierLimit(identifier) + 1);
}
} else {
user.sendMessage(StringParser.getInstance().replacePlaceHolder(plugin.getConfigFile().getFormatShopFailedMsg(), placeholders));
}
if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
event.getButton().getInv().closeInv(player, null);
} else {
new VoteShop(plugin, event.getPlayer(), user).open();
}
}
});
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestShopConfirmPurchaseNoItem())) {
@Override
public void onClick(ClickEvent event) {
if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
event.getButton().getInv().closeInv(player, null);
} else {
new VoteShop(plugin, event.getPlayer(), user).open();
}
}
});
inv.openInventory(player);
}
use of com.bencodez.advancedcore.api.inventory.BInventoryButton in project VotingPlugin by Ben12345rocks.
the class VoteStreak method onChest.
@Override
public void onChest(Player player) {
BInventory inv = new BInventory(plugin.getGui().getChestVoteStreakName());
inv.addPlaceholder("player", user.getPlayerName());
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteStreakCurrentDayStreakItem()).addPlaceholder("Streak", "" + user.getDayVoteStreak())) {
@Override
public void onClick(ClickEvent clickEvent) {
}
});
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteStreakCurrentWeekStreakItem()).addPlaceholder("Streak", "" + user.getWeekVoteStreak())) {
@Override
public void onClick(ClickEvent clickEvent) {
}
});
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteStreakCurrentMonthStreakItem()).addPlaceholder("Streak", "" + user.getMonthVoteStreak())) {
@Override
public void onClick(ClickEvent clickEvent) {
}
});
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteStreakHighestDayStreakItem()).addPlaceholder("Streak", "" + user.getBestDayVoteStreak())) {
@Override
public void onClick(ClickEvent clickEvent) {
}
});
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteStreakHighestWeekStreakItem()).addPlaceholder("Streak", "" + user.getBestWeekVoteStreak())) {
@Override
public void onClick(ClickEvent clickEvent) {
}
});
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteStreakHighestMonthStreakItem()).addPlaceholder("Streak", "" + user.getBestMonthVoteStreak())) {
@Override
public void onClick(ClickEvent clickEvent) {
}
});
if (plugin.getGui().getChestVoteStreakBackButton()) {
inv.addButton(plugin.getCommandLoader().getBackButton(user));
}
inv.openInventory(player);
}
Aggregations