Search in sources :

Example 1 with Job

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);
    });
}
Also used : GuiItem(com.github.stefvanschie.inventoryframework.gui.GuiItem) ItemBuilder(dte.employme.utils.items.ItemBuilder) Player(org.bukkit.entity.Player) OfflinePlayer(org.bukkit.OfflinePlayer) ItemBuilder(dte.employme.utils.items.ItemBuilder) Material(org.bukkit.Material) SimpleJob(dte.employme.job.SimpleJob) Job(dte.employme.job.Job)

Example 2 with 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();
}
Also used : PermissionUtils(dte.employme.utils.PermissionUtils) MaterialSubscriptionNotifier(dte.employme.job.addnotifiers.MaterialSubscriptionNotifier) SimpleJobSubscriptionService(dte.employme.job.subscription.SimpleJobSubscriptionService) RewardService(dte.employme.job.rewards.service.RewardService) Player(org.bukkit.entity.Player) ModernJavaPlugin(dte.modernjavaplugin.ModernJavaPlugin) ConfigFileFactory(dte.employme.config.ConfigFileFactory) PlayerContainerService(dte.employme.containers.service.PlayerContainerService) SimpleJobAddedNotifierService(dte.employme.job.addnotifiers.service.SimpleJobAddedNotifierService) SimpleRewardService(dte.employme.job.rewards.service.SimpleRewardService) PlayerContainerAbuseListener(dte.employme.listeners.PlayerContainerAbuseListener) MUST_BE_SUBSCRIBED_TO_GOAL(dte.employme.messages.MessageKey.MUST_BE_SUBSCRIBED_TO_GOAL) JobRewardGiveListener(dte.employme.board.listenable.JobRewardGiveListener) EmployerNotificationListener(dte.employme.board.listenable.EmployerNotificationListener) GLOBAL_JOB_BOARD_IS_FULL(dte.employme.messages.MessageKey.GLOBAL_JOB_BOARD_IS_FULL) ColoredMessageService(dte.employme.messages.service.ColoredMessageService) Material(org.bukkit.Material) Bukkit(org.bukkit.Bukkit) JobCompletedMessagesListener(dte.employme.board.listenable.JobCompletedMessagesListener) AutoUpdateListeners(dte.employme.listeners.AutoUpdateListeners) Metrics(org.bstats.bukkit.Metrics) JobAddedNotifierService(dte.employme.job.addnotifiers.service.JobAddedNotifierService) SimplePlayerContainerService(dte.employme.containers.service.SimplePlayerContainerService) JobAddedNotifier(dte.employme.job.addnotifiers.JobAddedNotifier) JOB_ADDED_NOTIFIER_NOT_FOUND(dte.employme.messages.MessageKey.JOB_ADDED_NOTIFIER_NOT_FOUND) EmploymentCommand(dte.employme.commands.EmploymentCommand) JobService(dte.employme.job.service.JobService) MessageService(dte.employme.messages.service.MessageService) List(java.util.List) Stream(java.util.stream.Stream) MUST_NOT_BE_CONVERSING(dte.employme.messages.MessageKey.MUST_NOT_BE_CONVERSING) SimpleListenableJobBoard(dte.employme.board.listenable.SimpleListenableJobBoard) TranslatedMessageService(dte.employme.messages.service.TranslatedMessageService) SimpleJobBoard(dte.employme.board.SimpleJobBoard) ConfigurationSerialization(org.bukkit.configuration.serialization.ConfigurationSerialization) SimpleJob(dte.employme.job.SimpleJob) RED(org.bukkit.ChatColor.RED) InvalidCommandArgument(co.aikar.commands.InvalidCommandArgument) Job(dte.employme.job.Job) YOU_OFFERED_TOO_MANY_JOBS(dte.employme.messages.MessageKey.YOU_OFFERED_TOO_MANY_JOBS) ArrayList(java.util.ArrayList) BukkitCommandManager(co.aikar.commands.BukkitCommandManager) InventoryBoardDisplayer(dte.employme.board.displayers.InventoryBoardDisplayer) AllJobsNotifier(dte.employme.job.addnotifiers.AllJobsNotifier) ConditionFailedException(co.aikar.commands.ConditionFailedException) ListenableJobBoard(dte.employme.board.listenable.ListenableJobBoard) ConfigFile(dte.employme.config.ConfigFile) Economy(net.milkbowl.vault.economy.Economy) Messages(dte.employme.config.Messages) MoneyReward(dte.employme.job.rewards.MoneyReward) JobAddNotificationListener(dte.employme.board.listenable.JobAddNotificationListener) ServiceLocator(dte.employme.utils.java.ServiceLocator) JobIconFactory(dte.employme.items.JobIconFactory) MATERIAL_NOT_FOUND(dte.employme.messages.MessageKey.MATERIAL_NOT_FOUND) JobGoalTransferListener(dte.employme.board.listenable.JobGoalTransferListener) JobSubscriptionService(dte.employme.job.subscription.JobSubscriptionService) SimpleJobService(dte.employme.job.service.SimpleJobService) ItemsReward(dte.employme.job.rewards.ItemsReward) RegisteredServiceProvider(org.bukkit.plugin.RegisteredServiceProvider) Placeholders(dte.employme.messages.Placeholders) Reloadable(dte.employme.reloadable.Reloadable) DoNotNotify(dte.employme.job.addnotifiers.DoNotNotify) AutoUpdater(dte.employme.utils.AutoUpdater) SimpleJobSubscriptionService(dte.employme.job.subscription.SimpleJobSubscriptionService) DoNotNotify(dte.employme.job.addnotifiers.DoNotNotify) SimpleJobAddedNotifierService(dte.employme.job.addnotifiers.service.SimpleJobAddedNotifierService) MoneyReward(dte.employme.job.rewards.MoneyReward) ItemsReward(dte.employme.job.rewards.ItemsReward) Metrics(org.bstats.bukkit.Metrics) SimpleJobBoard(dte.employme.board.SimpleJobBoard) EmployerNotificationListener(dte.employme.board.listenable.EmployerNotificationListener) SimplePlayerContainerService(dte.employme.containers.service.SimplePlayerContainerService) AutoUpdateListeners(dte.employme.listeners.AutoUpdateListeners) SimpleJob(dte.employme.job.SimpleJob) JobGoalTransferListener(dte.employme.board.listenable.JobGoalTransferListener) SimpleListenableJobBoard(dte.employme.board.listenable.SimpleListenableJobBoard) ConfigurationSerialization(org.bukkit.configuration.serialization.ConfigurationSerialization) SimpleJobService(dte.employme.job.service.SimpleJobService) JobIconFactory(dte.employme.items.JobIconFactory) ColoredMessageService(dte.employme.messages.service.ColoredMessageService) MaterialSubscriptionNotifier(dte.employme.job.addnotifiers.MaterialSubscriptionNotifier) JobCompletedMessagesListener(dte.employme.board.listenable.JobCompletedMessagesListener) TranslatedMessageService(dte.employme.messages.service.TranslatedMessageService) PlayerContainerAbuseListener(dte.employme.listeners.PlayerContainerAbuseListener) SimpleRewardService(dte.employme.job.rewards.service.SimpleRewardService) JobAddNotificationListener(dte.employme.board.listenable.JobAddNotificationListener) JobRewardGiveListener(dte.employme.board.listenable.JobRewardGiveListener) AllJobsNotifier(dte.employme.job.addnotifiers.AllJobsNotifier) ConfigFileFactory(dte.employme.config.ConfigFileFactory)

Example 3 with Job

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));
    });
}
Also used : PLAYER_COMPLETED_YOUR_JOB(dte.employme.messages.MessageKey.PLAYER_COMPLETED_YOUR_JOB) Text(net.md_5.bungee.api.chat.hover.content.Text) Job(dte.employme.job.Job) Player(org.bukkit.entity.Player) ChatColorUtils.colorize(dte.employme.utils.ChatColorUtils.colorize) OfflinePlayerUtils(dte.employme.utils.OfflinePlayerUtils) ComponentBuilder(net.md_5.bungee.api.chat.ComponentBuilder) Reward(dte.employme.job.rewards.Reward) ITEMS_JOB_COMPLETED(dte.employme.messages.MessageKey.ITEMS_JOB_COMPLETED) JOB_COMPLETED(dte.employme.messages.MessageKey.JOB_COMPLETED) PREFIX(dte.employme.messages.MessageKey.PREFIX) Action(net.md_5.bungee.api.chat.HoverEvent.Action) HoverEvent(net.md_5.bungee.api.chat.HoverEvent) JobBoard(dte.employme.board.JobBoard) MoneyReward(dte.employme.job.rewards.MoneyReward) MessageKey(dte.employme.messages.MessageKey) Collectors.joining(java.util.stream.Collectors.joining) MessageService(dte.employme.messages.service.MessageService) GET(dte.employme.messages.MessageKey.GET) ItemStackUtils(dte.employme.utils.ItemStackUtils) ItemsReward(dte.employme.job.rewards.ItemsReward) REWARD(dte.employme.messages.MessageKey.REWARD) COMPLETER(dte.employme.messages.Placeholders.COMPLETER) GOAL(dte.employme.messages.MessageKey.GOAL) JobCompleteListener(dte.employme.board.listenable.ListenableJobBoard.JobCompleteListener) ItemsReward(dte.employme.job.rewards.ItemsReward) HoverEvent(net.md_5.bungee.api.chat.HoverEvent) Text(net.md_5.bungee.api.chat.hover.content.Text) ComponentBuilder(net.md_5.bungee.api.chat.ComponentBuilder)

Example 4 with Job

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);
    });
}
Also used : ItemBuilder(dte.employme.utils.items.ItemBuilder) GuiItem(com.github.stefvanschie.inventoryframework.gui.GuiItem) ItemStack(org.bukkit.inventory.ItemStack) Job(dte.employme.job.Job)

Aggregations

Job (dte.employme.job.Job)4 Player (org.bukkit.entity.Player)3 GuiItem (com.github.stefvanschie.inventoryframework.gui.GuiItem)2 SimpleJob (dte.employme.job.SimpleJob)2 ItemsReward (dte.employme.job.rewards.ItemsReward)2 MoneyReward (dte.employme.job.rewards.MoneyReward)2 MessageService (dte.employme.messages.service.MessageService)2 Material (org.bukkit.Material)2 BukkitCommandManager (co.aikar.commands.BukkitCommandManager)1 ConditionFailedException (co.aikar.commands.ConditionFailedException)1 InvalidCommandArgument (co.aikar.commands.InvalidCommandArgument)1 JobBoard (dte.employme.board.JobBoard)1 SimpleJobBoard (dte.employme.board.SimpleJobBoard)1 InventoryBoardDisplayer (dte.employme.board.displayers.InventoryBoardDisplayer)1 EmployerNotificationListener (dte.employme.board.listenable.EmployerNotificationListener)1 JobAddNotificationListener (dte.employme.board.listenable.JobAddNotificationListener)1 JobCompletedMessagesListener (dte.employme.board.listenable.JobCompletedMessagesListener)1 JobGoalTransferListener (dte.employme.board.listenable.JobGoalTransferListener)1 JobRewardGiveListener (dte.employme.board.listenable.JobRewardGiveListener)1 ListenableJobBoard (dte.employme.board.listenable.ListenableJobBoard)1