use of com.bencodez.advancedcore.api.rewards.editbuttons.RewardEditDelayed 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);
}
Aggregations