use of com.bencodez.advancedcore.api.item.ItemBuilder in project AdvancedCore by BenCodez.
the class RewardEditLucky method openRemove.
public void openRemove(Player player, RewardEditData reward) {
EditGUI inv = new EditGUI("Edit Lucky Remove: " + reward.getName());
inv.addData("Reward", reward);
for (String key : reward.getData().getConfigurationSection("Lucky").getKeys(false)) {
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&c" + key).addLoreLine("&cClick to remove")) {
@Override
public void onClick(ClickEvent clickEvent) {
RewardEditData reward = (RewardEditData) getInv().getData("Reward");
reward.setValue("Lucky." + key, null);
reloadAdvancedCore();
open(player, 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.item.ItemBuilder 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.item.ItemBuilder 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.item.ItemBuilder 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.item.ItemBuilder in project AdvancedCore by BenCodez.
the class BInventory method openInventory.
/**
* Open inventory.
*
* @param player the player
* @param page the page
*/
public void openInventory(Player player, int page) {
BInventory inventory = this;
inv = Bukkit.createInventory(new GUISession(this, page), maxInvSize, StringParser.getInstance().replaceJavascript(player, StringParser.getInstance().replacePlaceHolder(inventory.getInventoryName(), getPlaceholders())));
this.page = page;
int startSlot = (page - 1) * (maxInvSize - 9);
for (Entry<Integer, BInventoryButton> pair : inventory.getButtons().entrySet()) {
int slot = pair.getKey();
if (slot >= startSlot) {
slot -= startSlot;
if (slot < (maxInvSize - 9)) {
ItemStack item = pair.getValue().getItem(player, getPlaceholders());
inv.setItem(slot, item);
BInventoryButton b = pair.getValue();
b.setInv(this);
b.setSlot(pair.getKey());
b.load(player);
}
}
}
for (BInventoryButton b : pageButtons) {
inv.setItem((maxInvSize - 9) + b.getSlot(), b.getItem(player, getPlaceholders()));
}
if (prevItem == null) {
if (AdvancedCorePlugin.getInstance().getOptions().getPrevItem() != null) {
prevItem = new ItemBuilder(AdvancedCorePlugin.getInstance().getOptions().getPrevItem()).addPlaceholder(getPlaceholders()).toItemStack(player);
} else {
prevItem = new ItemBuilder(Material.BLACK_STAINED_GLASS_PANE, 1).setName("&aPrevious Page").addPlaceholder(getPlaceholders()).toItemStack(player);
}
}
if (nextItem == null) {
if (AdvancedCorePlugin.getInstance().getOptions().getNextItem() != null) {
nextItem = new ItemBuilder(AdvancedCorePlugin.getInstance().getOptions().getNextItem()).addPlaceholder(getPlaceholders()).toItemStack(player);
} else {
nextItem = new ItemBuilder(Material.BLACK_STAINED_GLASS_PANE, 1).setName("&aNext Page").addPlaceholder(getPlaceholders()).toItemStack(player);
}
}
inv.setItem(maxInvSize - 9, prevItem);
inv.setItem(maxInvSize - 1, nextItem);
openInv(player, inv);
}
Aggregations