use of com.github.stefvanschie.inventoryframework.gui.GuiItem in project EmployMe by DavidTheExplorer.
the class ItemsRewardPreviewGUI method createItemsPane.
private Pane createItemsPane() {
OutlinePane pane = new OutlinePane(0, 0, 9, 6, Priority.LOWEST);
this.itemsReward.getItems().stream().map(item -> new GuiItem(new ItemStack(item))).forEach(pane::addItem);
return pane;
}
use of com.github.stefvanschie.inventoryframework.gui.GuiItem in project EmployMe by DavidTheExplorer.
the class JobBoardGUI method createOfferIcon.
private GuiItem createOfferIcon(Job job) {
ItemStack basicIcon = this.jobIconFactory.createFor(job);
boolean finished = this.jobService.hasFinished(this.player, job);
// add the status and ID to the lore
String separator = createSeparationLine(finished ? WHITE : DARK_RED, finished ? 25 : 29);
String finishMessage = this.messageService.getMessage(finished ? INVENTORY_JOB_BOARD_OFFER_COMPLETED : INVENTORY_JOB_BOARD_OFFER_NOT_COMPLETED).first();
List<String> lore = basicIcon.getItemMeta().getLore();
lore.add(separator);
lore.add(StringUtils.repeat(" ", finished ? 8 : 4) + finishMessage);
lore.add(separator);
ItemStack item = new ItemBuilder(basicIcon).withLore(lore.toArray(new String[0])).createCopy();
return new GuiItem(item, event -> {
// Right click = preview mode for jobs that offer items
if (event.isRightClick() && job.getReward() instanceof ItemsReward) {
ItemsRewardPreviewGUI gui = new ItemsRewardPreviewGUI((ItemsReward) job.getReward(), this.messageService);
gui.setOnClose(closeEvent -> this.player.openInventory(event.getInventory()));
gui.show(this.player);
} else // the user wants to finish the job
if (this.jobService.hasFinished(this.player, job)) {
this.player.closeInventory();
this.jobBoard.completeJob(job, this.player);
}
});
}
use of com.github.stefvanschie.inventoryframework.gui.GuiItem in project EmployMe by DavidTheExplorer.
the class JobCreationGUI method createOptionsPane.
private Pane createOptionsPane() {
OutlinePane pane = new OutlinePane(2, 1, 6, 1, Priority.LOW);
pane.setOrientation(HORIZONTAL);
pane.setGap(3);
// add the money job icon
pane.addItem(new GuiItem(new ItemBuilder(Material.GOLD_INGOT).named(this.messageService.getMessage(INVENTORY_JOB_CREATION_MONEY_JOB_ICON_NAME).first()).withLore(this.messageService.getMessage(INVENTORY_JOB_CREATION_MONEY_JOB_ICON_LORE).toArray()).createCopy(), event -> {
Player player = (Player) event.getWhoClicked();
player.closeInventory();
this.moneyJobConversationFactory.buildConversation(player).begin();
}));
// add the items job icon
pane.addItem(new GuiItem(new ItemBuilder(Material.CHEST).named(this.messageService.getMessage(INVENTORY_JOB_CREATION_ITEMS_JOB_ICON_NAME).first()).withLore(this.messageService.getMessage(INVENTORY_JOB_CREATION_ITEMS_JOB_ICON_LORE).toArray()).createCopy(), event -> new ItemsRewardOfferGUI(this.jobBoard, this.messageService, this.playerContainerService, this.rewardService).show(event.getWhoClicked())));
return pane;
}
use of com.github.stefvanschie.inventoryframework.gui.GuiItem in project EmployMe by DavidTheExplorer.
the class JobDeletionGUI method createDeletionIcon.
private GuiItem createDeletionIcon(Job job) {
ItemStack item = new ItemBuilder(this.jobIconFactory.createFor(job)).addToLore(true, createSeparationLine(GRAY, 23), this.messageService.getMessage(INVENTORY_JOB_DELETION_DELETE_INSTRUCTION).first(), createSeparationLine(GRAY, 23)).createCopy();
return new GuiItem(item, event -> {
Player player = (Player) event.getWhoClicked();
// Right click = preview mode for jobs that offer items
if (event.isRightClick() && job.getReward() instanceof ItemsReward) {
ItemsRewardPreviewGUI gui = new ItemsRewardPreviewGUI((ItemsReward) job.getReward(), this.messageService);
gui.setOnClose(closeEvent -> show(player));
gui.show(player);
} else // delete the job
{
player.closeInventory();
this.jobBoard.removeJob(job);
this.rewardService.refund(job.getEmployer(), job.getReward());
this.messageService.getMessage(JOB_SUCCESSFULLY_DELETED).sendTo(player);
}
});
}
use of com.github.stefvanschie.inventoryframework.gui.GuiItem in project EmployMe by DavidTheExplorer.
the class InventoryFrameworkUtils method createWalls.
public static Pane createWalls(ChestGui gui, Priority priority) {
PatternPane background = new PatternPane(0, 0, 9, 6, createWallsPattern(gui));
background.bindItem('W', new GuiItem(createWall(Material.BLACK_STAINED_GLASS_PANE)));
return background;
}
Aggregations