use of com.bencodez.advancedcore.api.item.ItemBuilder 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.item.ItemBuilder 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);
}
use of com.bencodez.advancedcore.api.item.ItemBuilder 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.item.ItemBuilder 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.item.ItemBuilder 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