use of com.gamingmesh.jobs.container.JobsPlayer in project Jobs by GamingMesh.
the class JobsCommands method demote.
@JobCommand
public boolean demote(CommandSender sender, String[] args) {
if (args.length < 3) {
sendUsage(sender, "demote");
return true;
}
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]);
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer);
Job job = Jobs.getJob(args[1]);
if (job == null) {
sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.job"));
return true;
}
try {
// check if player already has the job
if (jPlayer.isInJob(job)) {
Integer levelsLost = Integer.parseInt(args[2]);
Jobs.getPlayerManager().demoteJob(jPlayer, job, levelsLost);
Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId());
if (player != null) {
String message = Language.getMessage("command.demote.output.target");
message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE);
message = message.replace("%levelslost%", Integer.valueOf(levelsLost).toString());
player.sendMessage(message);
}
sender.sendMessage(Language.getMessage("command.admin.success"));
}
} catch (Exception e) {
sender.sendMessage(ChatColor.RED + Language.getMessage("command.admin.error"));
}
return true;
}
use of com.gamingmesh.jobs.container.JobsPlayer in project Jobs by GamingMesh.
the class JobsCommands method join.
@JobCommand
public boolean join(CommandSender sender, String[] args) {
if (!(sender instanceof Player))
return false;
if (args.length < 1) {
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);
String message = Language.getMessage("command.join.success");
message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE);
sender.sendMessage(message);
return true;
}
use of com.gamingmesh.jobs.container.JobsPlayer in project Jobs by GamingMesh.
the class JobsCommands method info.
@JobCommand
public boolean info(CommandSender sender, String[] args) {
if (!(sender instanceof Player))
return false;
if (args.length < 1) {
sendUsage(sender, "info");
sendValidActions(sender);
return true;
}
Player pSender = (Player) sender;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
String jobName = args[0];
Job job = Jobs.getJob(jobName);
if (job == null) {
sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.job"));
return true;
}
String type = "";
if (args.length >= 2) {
type = args[1];
}
sender.sendMessage(jobInfoMessage(jPlayer, job, type).split("\n"));
return true;
}
use of com.gamingmesh.jobs.container.JobsPlayer in project Jobs by GamingMesh.
the class JobsCommands method transfer.
@JobCommand
public boolean transfer(CommandSender sender, String[] args) {
if (args.length < 3) {
sendUsage(sender, "transfer");
return true;
}
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]);
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer);
Job oldjob = Jobs.getJob(args[1]);
Job newjob = Jobs.getJob(args[2]);
if (oldjob == null) {
sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.job"));
return true;
}
if (newjob == null) {
sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.job"));
return true;
}
try {
if (jPlayer.isInJob(oldjob) && !jPlayer.isInJob(newjob)) {
Jobs.getPlayerManager().transferJob(jPlayer, oldjob, newjob);
Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId());
if (player != null) {
String message = Language.getMessage("command.transfer.output.target");
message = message.replace("%oldjobname%", oldjob.getChatColor() + oldjob.getName() + ChatColor.WHITE);
message = message.replace("%newjobname%", newjob.getChatColor() + newjob.getName() + ChatColor.WHITE);
player.sendMessage(message);
}
sender.sendMessage(Language.getMessage("command.admin.success"));
}
} catch (Exception e) {
sender.sendMessage(ChatColor.RED + Language.getMessage("command.admin.error"));
}
return true;
}
use of com.gamingmesh.jobs.container.JobsPlayer in project Jobs by GamingMesh.
the class JobsCommands method fireall.
@JobCommand
public boolean fireall(CommandSender sender, String[] args) {
if (args.length < 1) {
sendUsage(sender, "fireall");
return true;
}
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]);
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer);
List<JobProgression> jobs = jPlayer.getJobProgression();
if (jobs.size() == 0) {
sender.sendMessage(Language.getMessage("command.fireall.error.nojobs"));
return true;
}
try {
Jobs.getPlayerManager().leaveAllJobs(jPlayer);
Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId());
if (player != null) {
player.sendMessage(Language.getMessage("command.fireall.output.target"));
}
sender.sendMessage(Language.getMessage("command.admin.success"));
} catch (Exception e) {
sender.sendMessage(ChatColor.RED + Language.getMessage("command.admin.error"));
}
return true;
}
Aggregations