use of com.github.stefvanschie.inventoryframework.gui.GuiItem in project EmployMe by DavidTheExplorer.
the class GoalCustomizationGUI method createEnchantmentsItem.
private GuiItem createEnchantmentsItem() {
ItemStack item = new ItemBuilder(Material.ENCHANTED_BOOK).named(this.messageService.getMessage(INVENTORY_GOAL_CUSTOMIZATION_ENCHANTMENTS_ITEM_NAME).first()).withLore(this.messageService.getMessage(INVENTORY_GOAL_CUSTOMIZATION_ENCHANTMENTS_ITEM_LORE).toArray()).glowing().createCopy();
return new GuiItem(item, event -> {
if (getType() == NO_ITEM_TYPE)
return;
closeWithoutRefund(event.getWhoClicked());
new GoalEnchantmentSelectionGUI(this.messageService, this, this.reward, this.rewardService).show(event.getWhoClicked());
});
}
use of com.github.stefvanschie.inventoryframework.gui.GuiItem in project EmployMe by DavidTheExplorer.
the class GoalCustomizationGUI method setEnchantmentsItemVisibility.
private void setEnchantmentsItemVisibility(boolean visible) {
GuiItem updatedItem = visible ? createEnchantmentsItem() : new GuiItem(createWall(Material.WHITE_STAINED_GLASS_PANE));
this.optionsPane.addItem(updatedItem, 6, 3);
}
use of com.github.stefvanschie.inventoryframework.gui.GuiItem in project EmployMe by DavidTheExplorer.
the class GoalCustomizationGUI method createTypeChoosingItem.
private GuiItem createTypeChoosingItem() {
return new GuiItem(new ItemBuilder(Material.ANVIL).named(this.messageService.getMessage(INVENTORY_GOAL_CUSTOMIZATION_TYPE_ITEM_NAME).first()).withLore(this.messageService.getMessage(INVENTORY_GOAL_CUSTOMIZATION_TYPE_ITEM_LORE).toArray()).glowing().createCopy(), event -> {
HumanEntity player = event.getWhoClicked();
closeWithoutRefund(player);
new ItemPaletteGUI(this, this.messageService, this.rewardService, this.reward).show(player);
});
}
use of com.github.stefvanschie.inventoryframework.gui.GuiItem in project EmployMe by DavidTheExplorer.
the class GoalCustomizationGUI method createFinishItem.
/*
* Items
*/
private GuiItem createFinishItem() {
return new GuiItem(new ItemBuilder(Material.GREEN_TERRACOTTA).named(this.messageService.getMessage(INVENTORY_GOAL_CUSTOMIZATION_FINISH_ITEM_NAME).first()).createCopy(), event -> {
Material type = this.currentItem.getItem().getType();
// the user didn't select an item
if (type == NO_ITEM_TYPE)
return;
// the goal is a non-enchanted enchanted book lmfao
if (type == Material.ENCHANTED_BOOK && getEnchantments(getCurrentItem()).isEmpty())
return;
Player player = (Player) event.getWhoClicked();
closeWithoutRefund(player);
Job job = new SimpleJob.Builder().by(player).of(createGoal()).thatOffers(this.reward).build();
this.jobBoard.addJob(job);
});
}
use of com.github.stefvanschie.inventoryframework.gui.GuiItem in project EmployMe by DavidTheExplorer.
the class GoalEnchantmentSelectionGUI method createEnchantedBook.
private GuiItem createEnchantedBook(Enchantment enchantment) {
ItemStack item = new ItemBuilder(Material.ENCHANTED_BOOK).named(GREEN + EnchantmentUtils.getDisplayName(enchantment)).withLore(this.messageService.getMessage(INVENTORY_GOAL_ENCHANTMENT_SELECTION_ITEM_LORE).toArray()).createCopy();
return new GuiItem(item, event -> {
this.showCustomizationGUIOnClose = false;
Player player = (Player) event.getWhoClicked();
player.closeInventory();
Conversations.createFactory(this.messageService).withFirstPrompt(new EnchantmentLevelPrompt(enchantment, this.messageService)).withInitialSessionData(new MapBuilder<Object, Object>().put("Reward", this.reward).build()).addConversationAbandonedListener(Conversations.refundRewardIfAbandoned(this.rewardService)).addConversationAbandonedListener(abandonedEvent -> {
if (!abandonedEvent.gracefulExit())
return;
int level = (int) abandonedEvent.getContext().getSessionData("level");
this.goalCustomizationGUI.addEnchantment(enchantment, level);
this.goalCustomizationGUI.setRefundRewardOnClose(true);
this.goalCustomizationGUI.show(player);
}).buildConversation(player).begin();
});
}
Aggregations