use of dte.employme.job.Job 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 dte.employme.job.Job in project EmployMe by DavidTheExplorer.
the class EmployMe method onEnable.
@Override
public void onEnable() {
INSTANCE = this;
// init economy
this.economy = getEconomy();
if (this.economy == null) {
disableWithError(RED + "Economy wasn't found! Shutting Down...");
return;
}
ServiceLocator.register(Economy.class, this.economy);
// init the configs
Stream.of(SimpleJob.class, MoneyReward.class, ItemsReward.class).forEach(ConfigurationSerialization::registerClass);
ConfigFileFactory configFileFactory = new ConfigFileFactory.Builder().handleCreationException((exception, config) -> disableWithError(RED + String.format("Error while creating %s: %s", config.getFile().getName(), exception.getMessage()))).handleSaveException((exception, config) -> disableWithError(RED + String.format("Error while saving %s: %s", config.getFile().getName(), exception.getMessage()))).build();
this.subscriptionsConfig = configFileFactory.loadConfig("subscriptions");
this.jobAddNotifiersConfig = configFileFactory.loadConfig("job add notifiers");
this.itemsContainersConfig = configFileFactory.loadContainer("items");
this.rewardsContainersConfig = configFileFactory.loadContainer("rewards");
this.messagesConfig = configFileFactory.loadMessagesConfig(Messages.ENGLISH);
if (this.subscriptionsConfig == null || this.jobAddNotifiersConfig == null || this.itemsContainersConfig == null || this.rewardsContainersConfig == null || this.messagesConfig == null)
return;
// init the global job board, services, factories, etc.
this.globalJobBoard = new SimpleListenableJobBoard(new SimpleJobBoard());
TranslatedMessageService translatedMessageService = new TranslatedMessageService(this.messagesConfig);
this.reloadables.add(translatedMessageService);
this.messageService = new ColoredMessageService(translatedMessageService);
this.jobSubscriptionService = new SimpleJobSubscriptionService(this.subscriptionsConfig);
this.jobSubscriptionService.loadSubscriptions();
ServiceLocator.register(JobSubscriptionService.class, this.jobSubscriptionService);
this.playerContainerService = new SimplePlayerContainerService(this.itemsContainersConfig, this.rewardsContainersConfig, this.messageService);
this.playerContainerService.loadContainers();
ServiceLocator.register(PlayerContainerService.class, this.playerContainerService);
this.rewardService = new SimpleRewardService(this.messageService);
this.jobsConfig = configFileFactory.loadConfig("jobs");
if (this.jobsConfig == null)
return;
this.jobIconFactory = new JobIconFactory(this.messageService);
this.jobService = new SimpleJobService(this.globalJobBoard, this.jobsConfig);
this.jobService.loadJobs();
this.jobAddedNotifierService = new SimpleJobAddedNotifierService(this.jobAddNotifiersConfig);
this.jobAddedNotifierService.register(new DoNotNotify());
this.jobAddedNotifierService.register(new AllJobsNotifier(this.messageService));
this.jobAddedNotifierService.register(new MaterialSubscriptionNotifier(this.messageService, this.jobSubscriptionService));
this.jobAddedNotifierService.loadPlayersNotifiers();
this.globalJobBoard.registerCompleteListener(new JobRewardGiveListener(), new JobGoalTransferListener(this.playerContainerService), new JobCompletedMessagesListener(this.messageService));
this.globalJobBoard.registerAddListener(new EmployerNotificationListener(this.messageService), new JobAddNotificationListener(this.jobAddedNotifierService));
// register commands, listeners, metrics
registerCommands();
registerListeners(new PlayerContainerAbuseListener(this.playerContainerService));
setDisableListener(() -> {
this.jobService.saveJobs();
this.playerContainerService.saveContainers();
this.jobSubscriptionService.saveSubscriptions();
this.jobAddedNotifierService.savePlayersNotifiers();
});
new Metrics(this, 13423);
AutoUpdater.forPlugin(this, 96513).ifRequestFailed(exception -> logToConsole(RED + "There was an internet error while checking for an update!")).ifNewUpdate(newVersion -> registerListeners(new AutoUpdateListeners(this.messageService, newVersion))).check();
}
use of dte.employme.job.Job in project EmployMe by DavidTheExplorer.
the class JobCompletedMessagesListener method onJobCompleted.
@Override
public void onJobCompleted(JobBoard board, Job job, Player whoCompleted) {
this.messageService.getMessage((job.getReward() instanceof ItemsReward ? ITEMS_JOB_COMPLETED : JOB_COMPLETED)).prefixed(this.messageService.getMessage(PREFIX).first()).sendTo(whoCompleted);
OfflinePlayerUtils.ifOnline(job.getEmployer(), employer -> {
this.messageService.getMessage(PLAYER_COMPLETED_YOUR_JOB).prefixed(this.messageService.getMessage(PREFIX).first()).inject(COMPLETER, whoCompleted.getName()).stream().map(line -> new ComponentBuilder(line).event(new HoverEvent(Action.SHOW_TEXT, new Text(describe(job)))).create()).forEach(message -> employer.spigot().sendMessage(message));
});
}
use of dte.employme.job.Job in project EmployMe by DavidTheExplorer.
the class JobBoardGUI method createPersonalJobsItem.
private GuiItem createPersonalJobsItem() {
ItemStack item = new ItemBuilder(Material.PLAYER_HEAD).named(this.messageService.getMessage(INVENTORY_JOB_BOARD_PERSONAL_JOBS_ITEM_NAME).first()).withItemMeta(SkullMeta.class, meta -> meta.setOwningPlayer(this.player)).withLore(this.messageService.getMessage(INVENTORY_JOB_BOARD_PERSONAL_JOBS_ITEM_LORE).toArray()).createCopy();
return new GuiItem(item, event -> {
List<Job> playerJobs = this.jobBoard.getJobsOfferedBy(this.player.getUniqueId());
new PlayerJobsGUI(this, this.messageService, playerJobs, this.orderComparator, this.jobIconFactory).show(this.player);
});
}
Aggregations