use of com.bencodez.advancedcore.api.inventory.BInventoryButton in project AdvancedCore by BenCodez.
the class RewardEditGUI method openRewardGUIRequirements.
public void openRewardGUIRequirements(Player player, RewardEditData rewardEditData, String rewardName) {
EditGUI inv = new EditGUI("Requirements: " + rewardName);
inv.requirePermission(AdvancedCorePlugin.getInstance().getOptions().getPermPrefix() + ".RewardEdit");
inv.addData("Reward", rewardEditData);
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER), new EditGUIValueBoolean("ForceOffline", rewardEditData.getValue("ForceOffline")) {
@Override
public void setValue(Player player, boolean value) {
RewardEditData reward = (RewardEditData) getInv().getData("Reward");
reward.setValue(getKey(), value);
plugin.reloadAdvancedCore(false);
}
}.addLore("Force reward to execute to run while player is offline")));
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER), new EditGUIValueInventory("Delayed") {
@Override
public void openInventory(ClickEvent clickEvent) {
RewardEditData reward = (RewardEditData) getInv().getData("Reward");
new RewardEditDelayed() {
@Override
public void setVal(String key, Object value) {
RewardEditData reward = (RewardEditData) getInv().getData("Reward");
reward.setValue(key, value);
plugin.reloadAdvancedCore(false);
}
}.open(clickEvent.getPlayer(), reward);
}
}.addLore("Delay reward from being executed")));
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER), new EditGUIValueInventory("Timed") {
@Override
public void openInventory(ClickEvent clickEvent) {
RewardEditData reward = (RewardEditData) getInv().getData("Reward");
new RewardEditTimed() {
@Override
public void setVal(String key, Object value) {
RewardEditData reward = (RewardEditData) getInv().getData("Reward");
reward.setValue(key, value);
plugin.reloadAdvancedCore(false);
}
}.open(clickEvent.getPlayer(), reward);
}
}.addLore("Execute reward at certain time")));
for (RequirementInject injectReward : plugin.getRewardHandler().getInjectedRequirements()) {
if (injectReward.isEditable()) {
for (BInventoryButton b : injectReward.getEditButtons()) {
if (b instanceof EditGUIButton) {
EditGUIButton eb = (EditGUIButton) b;
if (eb.getEditor().isCanGetValue()) {
eb.getEditor().setCurrentValue(rewardEditData.getValue(eb.getEditor().getKey()));
}
inv.addButton(eb);
} else {
inv.addButton(b);
}
}
}
}
inv.sort();
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cGo back")) {
@Override
public void onClick(ClickEvent clickEvent) {
openRewardGUI(clickEvent.getPlayer(), rewardEditData, rewardName);
}
});
inv.openInventory(player);
}
use of com.bencodez.advancedcore.api.inventory.BInventoryButton in project AdvancedCore by BenCodez.
the class RewardEditGUI method openRewardsGUICopy.
public void openRewardsGUICopy(Player player, RewardEditData rewardEditData, String rewardName) {
if (!player.hasPermission(AdvancedCorePlugin.getInstance().getOptions().getPermPrefix() + ".RewardEdit")) {
player.sendMessage("You do not have enough permission to do this");
return;
}
BInventory inv = new BInventory("CopyRewards");
inv.addData("masterreward", rewardEditData);
for (Reward reward : plugin.getRewardHandler().getRewards()) {
if (!reward.getConfig().isDirectlyDefinedReward()) {
ArrayList<String> lore = new ArrayList<String>();
if (reward.getConfig().isDirectlyDefinedReward()) {
lore.add("&cReward is directly defined");
}
inv.addButton(new BInventoryButton(reward.getRewardName(), ArrayUtils.getInstance().convert(lore), new ItemStack(Material.STONE)) {
@Override
public void onClick(ClickEvent event) {
new RewardGUIConfirmation(plugin, player, "Confirm copy reward?") {
@Override
public void onDeny(Player p) {
RewardEditData rewardEditData = (RewardEditData) getInv().getData("masterreward");
rewardEditData.reOpenEditGUI(player);
}
@Override
public void onConfirm(Player p) {
Reward reward = (Reward) getButton().getData("Reward");
RewardEditData rewardEditData = (RewardEditData) getInv().getData("masterreward");
for (Entry<String, Object> entry : getAllValues(reward.getConfig().getConfigData()).entrySet()) {
rewardEditData.setValue(entry.getKey(), entry.getValue());
}
}
}.open();
}
}.addData("Reward", reward));
}
}
inv.openInventory(player);
}
use of com.bencodez.advancedcore.api.inventory.BInventoryButton in project AdvancedCore by BenCodez.
the class RewardEditGUI method openRewardGUI.
public void openRewardGUI(Player player, RewardEditData rewardEditData, String rewardName) {
EditGUI inv = new EditGUI("Reward: " + rewardName);
inv.requirePermission(AdvancedCorePlugin.getInstance().getOptions().getPermPrefix() + ".RewardEdit");
inv.addData("Reward", rewardEditData);
inv.addButton(new BInventoryButton(new ItemBuilder(Material.REDSTONE).setName("&cRequirements")) {
@Override
public void onClick(ClickEvent clickEvent) {
openRewardGUIRequirements(clickEvent.getPlayer(), rewardEditData, rewardName);
}
});
inv.addButton(new BInventoryButton(new ItemBuilder(Material.DIAMOND).setName("&cRewards").addLoreLine("&cOnly shows current set values for Rewards")) {
@Override
public void onClick(ClickEvent clickEvent) {
openRewardGUIRewards(clickEvent.getPlayer(), rewardEditData, rewardName, false);
}
});
inv.addButton(new BInventoryButton(new ItemBuilder(Material.DIAMOND).setName("&cAll Rewards").addLoreLine("&cShows all possible settings")) {
@Override
public void onClick(ClickEvent clickEvent) {
openRewardGUIRewards(clickEvent.getPlayer(), rewardEditData, rewardName, true);
}
});
inv.addButton(new BInventoryButton(new ItemBuilder(Material.ANVIL).setName("&cCopy from existing reward").addLoreLine("&cDoes not remove existing rewards currently set, unless they overlap")) {
@Override
public void onClick(ClickEvent clickEvent) {
openRewardsGUICopy(clickEvent.getPlayer(), rewardEditData, rewardName);
}
});
if (rewardEditData.getParent() != null) {
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cOpen parent reward edit GUI")) {
@Override
public void onClick(ClickEvent clickEvent) {
RewardEditData rewardEditData = (RewardEditData) getInv().getData("Reward");
rewardEditData.getParent().reOpenEditGUI(clickEvent.getPlayer());
}
}.setSlot(-2));
}
inv.openInventory(player);
}
use of com.bencodez.advancedcore.api.inventory.BInventoryButton in project AdvancedCore by BenCodez.
the class RewardEditGUI method openRewardsGUI.
/**
* Open rewards GUI.
*
* @param player the player
*/
public void openRewardsGUI(Player player) {
if (!player.hasPermission(AdvancedCorePlugin.getInstance().getOptions().getPermPrefix() + ".RewardEdit")) {
player.sendMessage("You do not have enough permission to do this");
return;
}
BInventory inv = new BInventory("Rewards");
for (Reward reward : plugin.getRewardHandler().getRewards()) {
if (!reward.getConfig().isDirectlyDefinedReward()) {
ArrayList<String> lore = new ArrayList<String>();
if (reward.getConfig().isDirectlyDefinedReward()) {
lore.add("&cReward is not directly defined, can not edit in GUI");
}
inv.addButton(new BInventoryButton(reward.getRewardName(), ArrayUtils.getInstance().convert(lore), new ItemStack(Material.STONE)) {
@Override
public void onClick(ClickEvent event) {
Player player = event.getWhoClicked();
Reward reward = (Reward) getData("Reward");
if (!reward.getConfig().isDirectlyDefinedReward()) {
openRewardGUI(player, new RewardEditData(reward), reward.getRewardName());
} else {
player.sendMessage("Can't edit this reward, directly defined reward");
}
}
}.addData("Reward", reward));
}
}
inv.openInventory(player);
}
use of com.bencodez.advancedcore.api.inventory.BInventoryButton in project AdvancedCore by BenCodez.
the class RewardGUIConfirmation method onChest.
@Override
public void onChest(Player player) {
BInventory inv = new BInventory(title);
inv.addButton(new BInventoryButton(new ItemBuilder(Material.EMERALD_BLOCK).setName("&aConfirm")) {
@Override
public void onClick(ClickEvent clickEvent) {
onConfirm(clickEvent.getPlayer());
}
});
inv.addButton(new BInventoryButton(new ItemBuilder(Material.REDSTONE_BLOCK).setName("&aCancel")) {
@Override
public void onClick(ClickEvent clickEvent) {
onDeny(clickEvent.getPlayer());
}
});
inv.openInventory(player);
}
Aggregations