use of dte.employme.messages.MessageKey.GLOBAL_JOB_BOARD_IS_FULL in project EmployMe by DavidTheExplorer.
the class EmployMe method registerCommands.
@SuppressWarnings("deprecation")
private void registerCommands() {
BukkitCommandManager commandManager = new BukkitCommandManager(this);
commandManager.enableUnstableAPI("help");
// register conditions
commandManager.getCommandConditions().addCondition(Player.class, "Not Conversing", (handler, context, payment) -> {
if (context.getPlayer().isConversing())
throw new InvalidCommandArgument(this.messageService.getMessage(MUST_NOT_BE_CONVERSING).first(), false);
});
commandManager.getCommandConditions().addCondition(Material.class, "Subscribed To Goal", (handler, context, material) -> {
if (!this.jobSubscriptionService.isSubscribedTo(context.getPlayer().getUniqueId(), material))
throw new InvalidCommandArgument(this.messageService.getMessage(MUST_BE_SUBSCRIBED_TO_GOAL).first(), false);
});
commandManager.getCommandConditions().addCondition("Global Jobs Board Not Full", context -> {
if (this.globalJobBoard.getOfferedJobs().size() == ((6 * 9) - 26))
throw new ConditionFailedException(this.messageService.getMessage(GLOBAL_JOB_BOARD_IS_FULL).first());
});
commandManager.getCommandConditions().addCondition(Player.class, "Can Offer More Jobs", (handler, context, player) -> {
String jobPermission = PermissionUtils.findPermission(player, permission -> permission.startsWith("employme.jobs.allowed.")).orElse("employme.jobs.allowed.3");
int allowedJobs = Integer.parseInt(jobPermission.split("\\.")[jobPermission.split("\\.").length - 1]);
if (this.globalJobBoard.getJobsOfferedBy(player.getUniqueId()).size() >= allowedJobs)
throw new ConditionFailedException(this.messageService.getMessage(YOU_OFFERED_TOO_MANY_JOBS).first());
});
// register contexts
commandManager.getCommandContexts().registerContext(Material.class, context -> {
Material material = Material.matchMaterial(context.popFirstArg());
if (material == null)
throw new InvalidCommandArgument(this.messageService.getMessage(MATERIAL_NOT_FOUND).first(), false);
return material;
});
commandManager.getCommandContexts().registerContext(JobAddedNotifier.class, context -> {
String notifierName = context.joinArgs();
JobAddedNotifier notifier = this.jobAddedNotifierService.getByName(notifierName);
if (notifier == null)
throw new InvalidCommandArgument(this.messageService.getMessage(JOB_ADDED_NOTIFIER_NOT_FOUND).inject(Placeholders.JOB_ADDED_NOTIFIER, notifierName).first(), false);
return notifier;
});
commandManager.getCommandContexts().registerIssuerOnlyContext(List.class, context -> {
if (!context.hasFlag("Jobs Able To Delete"))
return null;
Player player = context.getPlayer();
return player.hasPermission("employme.admin.delete") ? this.globalJobBoard.getOfferedJobs() : this.globalJobBoard.getJobsOfferedBy(player.getUniqueId());
});
// register commands
InventoryBoardDisplayer inventoryBoardDisplayer = new InventoryBoardDisplayer(Job.ORDER_BY_GOAL_NAME, this.jobService, this.messageService, this.jobIconFactory);
commandManager.registerCommand(new EmploymentCommand(this.globalJobBoard, this.playerContainerService, this.jobSubscriptionService, this.jobAddedNotifierService, this.messageService, inventoryBoardDisplayer, this.economy, this.jobIconFactory, this.rewardService, this.reloadables));
}
Aggregations