use of com.bencodez.advancedcore.api.item.ItemBuilder in project AdvancedCore by BenCodez.
the class UserGUI method openUserGUI.
/**
* Open user GUI.
*
* @param player the player
* @param playerName the player name
*/
public void openUserGUI(Player player, final String playerName) {
if (!player.hasPermission("AdvancedCore.UserEdit")) {
player.sendMessage("Not enough permissions");
return;
}
BInventory inv = new BInventory("UserGUI: " + playerName);
inv.addData("player", playerName);
inv.addButton(new BInventoryButton("Give Reward File", new String[] {}, new ItemStack(Material.STONE)) {
@Override
public void onClick(ClickEvent clickEvent) {
ArrayList<String> rewards = new ArrayList<String>();
for (Reward reward : plugin.getRewardHandler().getRewards()) {
rewards.add(reward.getRewardName());
}
new ValueRequest().requestString(clickEvent.getPlayer(), "", ArrayUtils.getInstance().convert(rewards), true, new StringListener() {
@Override
public void onInput(Player player, String value) {
AdvancedCoreUser user = plugin.getUserManager().getUser(UserGUI.getInstance().getCurrentPlayer(player));
plugin.getRewardHandler().giveReward(user, value, new RewardOptions());
player.sendMessage("Given " + user.getPlayerName() + " reward file " + value);
}
});
}
});
inv.addButton(new BInventoryButton(new ItemBuilder("WRITABLE_BOOK").setName("Edit Data")) {
@Override
public void onClick(ClickEvent clickEvent) {
Player player = clickEvent.getPlayer();
EditGUI inv = new EditGUI("Edit Data, click to change");
final AdvancedCoreUser user = plugin.getUserManager().getUser(playerName);
for (final String key : user.getData().getKeys()) {
String value = user.getData().getValue(key);
inv.addButton(new EditGUIButton(new ItemBuilder(Material.STONE).setName(key + " = " + value), new EditGUIValueString(key, value) {
@Override
public void setValue(Player player, String value) {
if (value.equals("\"\"")) {
value = "";
}
user.getData().setString(key, value);
openUserGUI(player, playerName);
}
}));
}
inv.openInventory(player);
}
});
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&cView player data")) {
@Override
public void onClick(ClickEvent clickEvent) {
AdvancedCoreUser user = plugin.getUserManager().getUser(playerName);
for (String key : user.getData().getKeys()) {
String str = user.getData().getValue(key);
user.sendMessage("&c&l" + key + " &c" + str);
}
}
});
for (BInventoryButton button : extraButtons.values()) {
inv.addButton(button);
}
inv.openInventory(player);
}
use of com.bencodez.advancedcore.api.item.ItemBuilder in project AdvancedCore by BenCodez.
the class RewardEditLucky method openRename.
public void openRename(Player player, RewardEditData reward) {
EditGUI inv = new EditGUI("Edit Lucky Rename: " + reward.getName());
inv.addData("Reward", reward);
for (String key : reward.getData().getConfigurationSection("Lucky").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("Lucky." + value.intValue(), reward.getData().getConfigurationSection("Lucky." + key));
reward.setValue("Lucky." + 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 RewardEditLucky method openEditSub.
public void openEditSub(Player player, RewardEditData reward) {
EditGUI inv = new EditGUI("Edit Lucky Edit Sub: " + reward.getName());
inv.addData("Reward", reward);
for (String key : reward.getData().getConfigurationSection("Lucky").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(), "Lucky." + 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 RewardEditPotions method openEditSub.
public void openEditSub(Player player, RewardEditData reward) {
EditGUI inv = new EditGUI("Edit Potions Edit Sub: " + reward.getName());
inv.addData("Reward", reward);
for (String key : reward.getData().getConfigurationSection("Potions").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");
openEditSub(player, reward, key);
}
});
}
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 RewardEditPotions method openRemove.
public void openRemove(Player player, RewardEditData reward) {
EditGUI inv = new EditGUI("Edit Potions Remove: " + reward.getName());
inv.addData("Reward", reward);
for (String key : reward.getData().getConfigurationSection("Potions").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("Potions." + 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);
}
Aggregations