sendUsage(sender, "join");
return true;
}
Player pSender = (Player) sender;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
String jobName = args[0];
Job job = Jobs.getJob(jobName);
if (job == null) {
// job does not exist
sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.job"));
return true;
}
if (!hasJobPermission(pSender, job)) {
// you do not have permission to join the job
sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.permission"));
return true;
}
if (jPlayer.isInJob(job)) {
// already in job message
String message = ChatColor.RED + Language.getMessage("command.join.error.alreadyin");
message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.RED);
sender.sendMessage(message);
return true;
}
if (job.getMaxSlots() != null && Jobs.getUsedSlots(job) >= job.getMaxSlots()) {
String message = ChatColor.RED + Language.getMessage("command.join.error.fullslots");
message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.RED);
sender.sendMessage(message);
return true;
}
int confMaxJobs = ConfigManager.getJobsConfiguration().getMaxJobs();
if (confMaxJobs > 0 && jPlayer.getJobProgression().size() >= confMaxJobs) {
sender.sendMessage(ChatColor.RED + Language.getMessage("command.join.error.maxjobs"));
return true;
}
Jobs.getPlayerManager().joinJob(jPlayer, job);